internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: fossasia/open-event-server

Issue:
Enhance admin sales tab with date and links
In the tables of the admin sales tab please enhance as follows:
* [ ] add event dates in the second column
* [ ] in first column make event name itself link to the specific event dashboard and add in brackets "(View Live Site)"

![screenshot from 2017-01-19 13-35-22](https://cloud.githubusercontent.com/assets/1583873/22107206/d4e02652-de4c-11e6-9a90-f9b44e9197ee.png)



Discussion:
Can I work on this, please?


Resolving patch:
diff --git a/app/views/super_admin/sales.py b/app/views/super_admin/sales.py
--- a/app/views/super_admin/sales.py
+++ b/app/views/super_admin/sales.py
@@ -290,6 +290,10 @@ def sales_by_events_view(path):
             'payment_currency': event.payment_currency,
             'marketer': '',
             'discount_code': '',
+            'live_url': url_for('event_detail.display_event_detail_home', identifier=event.identifier).replace('events', 'e'),
+            'event_url': url_for('events.details_view', event_id=event.id),
+            'start_time': event.start_time,
+            'end_time': event.end_time,
             'completed': {
                 'tickets_count': 0,
                 'sales': 0
@@ -362,7 +366,6 @@ def sales_by_events_view(path):
                     tickets_summary_event_wise[str(order.event_id)][str(order.status)]['sales']  += order_ticket.quantity * ticket.price
                     tickets_summary_organizer_wise[str(order.event.creator_id)][str(order.status)]['sales']  += order_ticket.quantity * ticket.price
                     tickets_summary_location_wise[str(order.event.searchable_location_name)][str(order.status)]['sales']  += order_ticket.quantity * ticket.price
-
     if path == 'events' or path == 'discounted-events':
         return render_template('gentelella/admin/super_admin/sales/by_events.html',
                                tickets_summary=tickets_summary_event_wise,


Test patch:
Repository: fossasia/open-event-server

Issue:
Auto delete pending orders after 72 hours
Currently pending orders seem to be kept in the system forever. Please delete pending orders and pending attendees automatically after 72 hours.

![screenshot from 2017-01-19 17-08-56](https://cloud.githubusercontent.com/assets/1583873/22114524/19d1df86-de6a-11e6-81a6-8a58e861004b.png)



Discussion:
Do we change it to "Expired" ? And what about the "Expired"? Should we let them stay?

> Do we change it to "Expired"

Yes, good idea.
@SaptakS Are you currently working on this, if not i'd like to take this up.
@shubham-padia you can continue on this after completing https://github.com/fossasia/open-event-orga-server/pull/3026 if I don't solve it by then. :smiley: 

Resolving patch:
diff --git a/app/__init__.py b/app/__init__.py
--- a/app/__init__.py
+++ b/app/__init__.py
@@ -535,8 +535,8 @@ def integrate_socketio():
 
 scheduler = BackgroundScheduler(timezone=utc)
 scheduler.add_job(send_mail_to_expired_orders, 'interval', hours=5)
-scheduler.add_job(empty_trash, 'cron', day_of_week='mon-fri', hour=5, minute=30)
-scheduler.add_job(send_after_event_mail, 'cron', day_of_week='mon-fri', hour=5, minute=30)
+scheduler.add_job(empty_trash, 'cron', hour=5, minute=30)
+scheduler.add_job(send_after_event_mail, 'cron', hour=5, minute=30)
 scheduler.add_job(send_event_fee_notification, 'cron', day=1)
 scheduler.add_job(send_event_fee_notification_followup, 'cron', day=15)
 scheduler.start()
diff --git a/app/helpers/scheduled_jobs.py b/app/helpers/scheduled_jobs.py
--- a/app/helpers/scheduled_jobs.py
+++ b/app/helpers/scheduled_jobs.py
@@ -24,6 +24,8 @@ def empty_trash():
         users = User.query.filter_by(in_trash=True)
         sessions = Session.query.filter_by(in_trash=True)
         orders = Order.query.filter_by(status="deleted")
+        pending_orders = Order.query.filter_by(status="pending")
+        expired_orders = Order.query.filter_by(status="expired")
         for event in events:
             if datetime.now() - event.trash_date >= timedelta(days=30):
                 DataManager.delete_event(event.id)
@@ -42,6 +44,17 @@ def empty_trash():
             if datetime.now() - order.trashed_at >= timedelta(days=30):
                 delete_from_db(order, "Order deleted permanently")
 
+        for pending_order in pending_orders:
+            if datetime.now() - pending_order.created_at >= timedelta(days=3):
+                pending_order.status = "expired"
+                save_to_db(pending_order, "Pending order expired.")
+
+        for expired_order in expired_orders:
+            if datetime.now() - expired_order.created_at >= timedelta(days=6):
+                expired_order.status = "deleted"
+                expired_order.trashed_at = datetime.now()
+                save_to_db(expired_order, "Expired order deleted")
+
 
 def send_after_event_mail():
     from app import current_app as app


Test patch:
Repository: fossasia/open-event-server

Issue:
Only show sessions when schedule has been published
There are issues with the public sessions page:
* [x] Sessions that have not a time show up at the beginning of the program
* [x] The session page shows up even though the schedule has not been published

![screenshot from 2017-01-28 19-13-05](https://cloud.githubusercontent.com/assets/1583873/22398703/0bc9dd78-e58e-11e6-923f-a84edc55f6f5.png)



Discussion:

Resolving patch:
diff --git a/app/views/public/event_detail.py b/app/views/public/event_detail.py
--- a/app/views/public/event_detail.py
+++ b/app/views/public/event_detail.py
@@ -65,7 +65,7 @@ def display_event_detail_home(identifier):
     speakers = []
     for session in accepted_sessions:
         for speaker in session.speakers:
-            if speaker not in speakers:
+            if speaker not in speakers and session.microlocation_id:
                 speakers.append(speaker)
 
     '''Timezone aware current datetime object according to event timezone'''


Test patch:
Repository: fossasia/open-event-server

Issue:
Speakers no longer on the page after they have been approved
In issue https://github.com/fossasia/open-event-orga-server/issues/3054 we defined that the schedule should not show up as long as it is not published. However, as soon as speakers are approved, they can be shown on the page. This was the case until the PR for issue https://github.com/fossasia/open-event-orga-server/issues/3054.

Please re-enable to show speakers on the event page as soon as they have been approved.

![screenshot from 2017-01-30 11-10-42](https://cloud.githubusercontent.com/assets/1583873/22419227/c2ad8a7c-e6dc-11e6-9771-01d086e01bb6.png)




Discussion:

Resolving patch:
diff --git a/app/views/public/event_detail.py b/app/views/public/event_detail.py
--- a/app/views/public/event_detail.py
+++ b/app/views/public/event_detail.py
@@ -65,7 +65,7 @@ def display_event_detail_home(identifier):
     speakers = []
     for session in accepted_sessions:
         for speaker in session.speakers:
-            if speaker not in speakers and session.microlocation_id:
+            if speaker not in speakers:
                 speakers.append(speaker)
 
     '''Timezone aware current datetime object according to event timezone'''


Test patch:
Repository: fossasia/open-event-server

Issue:
Do not show deleted orders in organiser ui and do not auto delete expired orders



Discussion:

Resolving patch:
diff --git a/app/helpers/scheduled_jobs.py b/app/helpers/scheduled_jobs.py
--- a/app/helpers/scheduled_jobs.py
+++ b/app/helpers/scheduled_jobs.py
@@ -23,9 +23,8 @@ def empty_trash():
         events = Event.query.filter_by(in_trash=True)
         users = User.query.filter_by(in_trash=True)
         sessions = Session.query.filter_by(in_trash=True)
-        orders = Order.query.filter_by(status="deleted")
         pending_orders = Order.query.filter_by(status="pending")
-        expired_orders = Order.query.filter_by(status="expired")
+
         for event in events:
             if datetime.now() - event.trash_date >= timedelta(days=30):
                 DataManager.delete_event(event.id)
@@ -40,21 +39,11 @@ def empty_trash():
             if datetime.now() - session_.trash_date >= timedelta(days=30):
                 delete_from_db(session_, "Session deleted permanently")
 
-        for order in orders:
-            if datetime.now() - order.trashed_at >= timedelta(days=30):
-                delete_from_db(order, "Order deleted permanently")
-
         for pending_order in pending_orders:
             if datetime.now() - pending_order.created_at >= timedelta(days=3):
                 pending_order.status = "expired"
                 save_to_db(pending_order, "Pending order expired.")
 
-        for expired_order in expired_orders:
-            if datetime.now() - expired_order.created_at >= timedelta(days=6):
-                expired_order.status = "deleted"
-                expired_order.trashed_at = datetime.now()
-                save_to_db(expired_order, "Expired order deleted")
-
 
 def send_after_event_mail():
     from app import current_app as app


Test patch:
Repository: fossasia/open-event-server

Issue:
Tickets and Orders: Show latest orders first
In the event orders and tickets tab (e.g. `events/event-id/tickets/orders/`) and admin sales tab (`/admin/sales/events/`) please sort to show new order/tickets/events on top and older orders/tickets/events on the bottom.

![screenshot from 2017-02-02 08-49-46](https://cloud.githubusercontent.com/assets/1583873/22541227/5d7c1466-e925-11e6-99cc-0fdf65df2476.png)



Discussion:

Resolving patch:
diff --git a/app/helpers/data_getter.py b/app/helpers/data_getter.py
--- a/app/helpers/data_getter.py
+++ b/app/helpers/data_getter.py
@@ -98,7 +98,7 @@ def get_invite_by_user_id(user_id):
     @staticmethod
     def get_all_events():
         """Method return all events"""
-        return Event.query.order_by(desc(Event.id)).filter_by(in_trash=False).all()
+        return Event.query.order_by(desc(Event.created_at)).filter_by(in_trash=False).all()
 
     @staticmethod
     def get_all_events_with_discounts():


Test patch:
Repository: fossasia/open-event-server

Issue:
Admin Panel: Show detailed user numbers
In the admin panel there is a widget with a table "System Roles". Please improve as follows:

* [x] Add Row "Unverified User"
* [x] On the last row show "Total No. of Users"

![screenshot from 2017-02-01 11-25-18](https://cloud.githubusercontent.com/assets/1583873/22503343/99f8450e-e871-11e6-8f22-59ba0537ea2c.png)



Discussion:
I am on it :)
@mariobehling @niranjan94 @SaptakS  issue solved !! 
![screenshot from 2017-02-03 12 24 25](https://cloud.githubusercontent.com/assets/17119462/22582289/f410c958-ea0b-11e6-9a4b-9cc51965a874.png)

@Himanshi-Khandelwal PR? #?

Resolving patch:
diff --git a/app/helpers/data_getter.py b/app/helpers/data_getter.py
--- a/app/helpers/data_getter.py
+++ b/app/helpers/data_getter.py
@@ -788,6 +788,10 @@ def get_all_admins():
     def get_all_registered_users():
         return get_count(User.query.filter_by(is_verified=True))
 
+    @staticmethod
+    def get_all_unverified_users():
+        return get_count(User.query.filter_by(is_verified=False))
+
     @staticmethod
     def get_all_user_roles(role_name):
         role = Role.query.filter_by(name=role_name).first()
diff --git a/app/views/super_admin/super_admin.py b/app/views/super_admin/super_admin.py
--- a/app/views/super_admin/super_admin.py
+++ b/app/views/super_admin/super_admin.py
@@ -27,6 +27,7 @@ def index_view():
     super_admins = DataGetter.get_all_super_admins()
     admins = DataGetter.get_all_admins()
     registered_users = DataGetter.get_all_registered_users()
+    unverified_users = DataGetter.get_all_unverified_users()
     organizers = get_count(DataGetter.get_all_user_roles(ORGANIZER))
     co_organizers = get_count(DataGetter.get_all_user_roles(COORGANIZER))
     track_organizers = get_count(DataGetter.get_all_user_roles(TRACK_ORGANIZER))
@@ -36,6 +37,7 @@ def index_view():
     draft_sessions = get_count(DataGetter.get_all_draft_sessions())
     email_times = DataGetter.get_email_by_times()
 
+
     commit_info = None
     heroku_release = None
     on_kubernetes = False
@@ -80,6 +82,7 @@ def index_view():
                            super_admins=super_admins,
                            admins=admins,
                            registered_users=registered_users,
+                           unverified_users=unverified_users,
                            repository=repository,
                            branch=branch,
                            organizers=organizers,


Test patch:
Repository: fossasia/open-event-server

Issue:
Tickets and Orders: Show latest orders first
In the event orders and tickets tab (e.g. `events/event-id/tickets/orders/`) and admin sales tab (`/admin/sales/events/`) please sort to show new order/tickets/events on top and older orders/tickets/events on the bottom.

![screenshot from 2017-02-02 08-49-46](https://cloud.githubusercontent.com/assets/1583873/22541227/5d7c1466-e925-11e6-99cc-0fdf65df2476.png)



Discussion:
Cannot confirm this is solved after merging to live page. 

![screenshot from 2017-02-02 22-39-40](https://cloud.githubusercontent.com/assets/1583873/22569611/8532d4ae-e998-11e6-9587-eb6f1cf67ada.png)


Resolving patch:
diff --git a/app/helpers/ticketing.py b/app/helpers/ticketing.py
--- a/app/helpers/ticketing.py
+++ b/app/helpers/ticketing.py
@@ -3,7 +3,7 @@
 
 from flask import url_for, flash
 from flask.ext import login
-from sqlalchemy import asc
+from sqlalchemy import desc
 from sqlalchemy import or_
 
 from app.helpers.cache import cache
@@ -69,8 +69,7 @@ def get_orders(event_id=None, status=None, from_date=None, to_date=None, markete
         if promoted_event:
             orders = orders.join(Order.event).filter(Event.discount_code_id != None)
 
-            orders = orders.order_by(asc(Order.created_at))
-
+        orders = orders.order_by(desc(Order.id))
         return orders.all()
 
     @staticmethod


Test patch:
Repository: fossasia/open-event-server

Issue:
Specify from "Name" for emails in admin dashboard
The system emails that are sent out from eventyay currently show "info" as the name. Please implement a field in the email settings to specify a "Name" so when people get an email from the system this name shows up in their inbox.

![screenshot from 2017-02-01 12-49-24](https://cloud.githubusercontent.com/assets/1583873/22505728/4c3c80ee-e87d-11e6-922f-c470e4c1a6e6.png)



Discussion:

Resolving patch:
diff --git a/app/helpers/helpers.py b/app/helpers/helpers.py
--- a/app/helpers/helpers.py
+++ b/app/helpers/helpers.py
@@ -391,7 +391,11 @@ def send_email(to, action, subject, html):
     """
     if not string_empty(to):
         email_service = get_settings()['email_service']
-        email_from = get_settings()['email_from']
+        email_from_name = get_settings()['email_from_name']
+        if email_service == 'smtp':
+            email_from = email_from_name + '<' + get_settings()['email_from'] + '>'
+        else:
+            email_from = get_settings()['email_from']
         payload = {
             'to': to,
             'from': email_from,
@@ -422,6 +426,7 @@ def send_email(to, action, subject, html):
                 from tasks import send_mail_via_smtp_task
                 send_mail_via_smtp_task.delay(config, payload)
             else:
+                payload['fromname'] = email_from_name
                 key = get_settings()['sendgrid_key']
                 if not key and not current_app.config['TESTING']:
                     print 'Sendgrid key not defined'


Test patch:
Repository: fossasia/open-event-server

Issue:
Add speakers fields to API/JSON
There have been recent additions to the form in the speakers form. Please check all fields in the create event wizard step 3 and ensure they are covered in the API and JSON.

Implement the missing fields in the API.

![screenshot from 2017-01-30 15-39-15](https://cloud.githubusercontent.com/assets/1583873/22427155/53bc1da6-e702-11e6-9f49-d26e2045a158.png)



Discussion:
I want to work on this. Can you please assign this to me?
@vaishnavit drop in a comment here once you have setup the server locally, then the issue will be assigned to you :smile: 
@niranjan94 I am running server locally now. Can you please assign.
@vaishnavit you can proceed. 

Resolving patch:
diff --git a/app/api/speakers.py b/app/api/speakers.py
--- a/app/api/speakers.py
+++ b/app/api/speakers.py
@@ -45,7 +45,8 @@
     'city': fields.String(),
     'heard_from': fields.String(),
     'speaking_experience': fields.String(),
-    'sponsorship_required': fields.String()
+    'sponsorship_required': fields.String(),
+    'gender': fields.String()
 })
 
 SPEAKER_PAGINATED = api.clone('SpeakerPaginated', PAGINATED_MODEL, {


Test patch:
diff --git a/tests/unittests/api/utils_post_data.py b/tests/unittests/api/utils_post_data.py
--- a/tests/unittests/api/utils_post_data.py
+++ b/tests/unittests/api/utils_post_data.py
@@ -102,7 +102,8 @@
     "city": "TestCity",
     "heard_from": "TestSource",
     "speaking_experience": "TestExperience",
-    "sponsorship_required": "Yes"
+    "sponsorship_required": "Yes",
+    "gender": "Male"
 }
 
 POST_SPONSOR_DATA = {
Repository: fossasia/open-event-server

Issue:
Implement "Resend Confirmation" form in the ticketing dashboard
At points users will contact organizers, that they have not received their ticket. Please implement a form to "Resend Confirmation" similar to screenshot below. This action item will be linked from the ticketing dashboard and should be part of that dashboard keeping the menu on the left.

This is a subissue to https://github.com/fossasia/open-event-orga-server/issues/2996

![screenshot from 2017-01-19 23-07-39](https://cloud.githubusercontent.com/assets/1583873/22127614/eb78563c-de9c-11e6-9cf1-b3365594f7b3.png)



Discussion:
@mariobehling  can I work on this?
@yasirunilan sure. Go ahead.  Thanks
@mariobehling just to be clear the this should be a seperate page right?
And also do I need to implement the menu as metioned in #2996 to link it to this particular page?
@yasirunilan Yes, both issues are related.

Yes, this would be a separate page (like in screenshot above), that shows the ticket data just like when the user orders a ticket.

Resolving patch:
diff --git a/app/helpers/ticketing.py b/app/helpers/ticketing.py
--- a/app/helpers/ticketing.py
+++ b/app/helpers/ticketing.py
@@ -542,3 +542,16 @@ def delete_order(form):
                 save_to_db(order)
             return True
         return False
+
+    @staticmethod
+    def resend_confirmation(form):
+        order = TicketingManager.get_and_set_expiry(form.get('identifier'))
+        email = form.get('email')
+        event_id = order.event_id
+        invoice_id = order.get_invoice_number()
+        order_url = url_for('ticketing.view_order_after_payment', order_identifier=order.identifier, _external=True)
+        if login.current_user.is_organizer(event_id):
+            trigger_after_purchase_notifications(email, order.event_id, order.event, invoice_id, order_url)
+            send_email_for_after_purchase(email, invoice_id, order_url, order.event.name, order.event.organizer_name)
+            return True
+        return False
diff --git a/app/views/users/ticket_sales.py b/app/views/users/ticket_sales.py
--- a/app/views/users/ticket_sales.py
+++ b/app/views/users/ticket_sales.py
@@ -405,3 +405,12 @@ def delete_order(event_id):
         return redirect(url_for('.display_orders', event_id=event_id))
     else:
         abort(403)
+
+
+@event_ticket_sales.route('/resend-confirmation/', methods=('POST',))
+def resend_confirmation(event_id):
+    return_status = TicketingManager.resend_confirmation(request.form)
+    if return_status:
+        return redirect(url_for('.display_orders', event_id=event_id))
+    else:
+        abort(403)


Test patch:
Repository: fossasia/open-event-server

Issue:
Mail: New Session Proposals not Sent out to Organizers and Co-organizers
After the submission of several people the new Session Proposals have not been sent out to Organizers and Co-organizers. One reason could be, that these people did not verify their email address.

Please check configuration and ensure all emails of all submissions are sent to organizers/co-organizers.


Discussion:

Resolving patch:
diff --git a/app/helpers/notification_email_triggers.py b/app/helpers/notification_email_triggers.py
--- a/app/helpers/notification_email_triggers.py
+++ b/app/helpers/notification_email_triggers.py
@@ -19,7 +19,7 @@ def trigger_new_session_notifications(session_id, event_id=None, event=None):
     admin_msg_setting = DataGetter.get_message_setting_by_action(NEW_SESSION)
     organizers = DataGetter.get_user_event_roles_by_role_name(event.id, 'organizer')
     for organizer in organizers:
-        email_notification_setting = DataGetter.get_email_notification_settings_by_event_id(organizer.user.id, event_id)
+        email_notification_setting = DataGetter.get_email_notification_settings_by_event_id(organizer.user.id, event.id)
         if not admin_msg_setting or \
             (email_notification_setting and email_notification_setting.new_paper == 1 and
              admin_msg_setting.user_control_status == 1) or admin_msg_setting.user_control_status == 0:


Test patch:
Repository: fossasia/open-event-server

Issue:
Deleting ticket not executed
After the user deletes a ticket, it is not shown anymore and when the user continues and saves it it shows as successfully done. However going back to the editing of the event shows: the ticket is still there. It also shows up on "Access Code" creation if it is a hidden ticket.

Expected: If no purchase has been made, tickets it should be possible to delete a ticket successfully.

![screenshot from 2017-02-11 23-23-33](https://cloud.githubusercontent.com/assets/1583873/22857984/7171ec00-f0b1-11e6-8723-7147c6d61ca5.png)



Discussion:
I'm on this.

Resolving patch:
diff --git a/app/models/order.py b/app/models/order.py
--- a/app/models/order.py
+++ b/app/models/order.py
@@ -9,8 +9,6 @@ class OrderTicket(db.Model):
     order_id = db.Column(db.Integer, db.ForeignKey('orders.id', ondelete='CASCADE'), primary_key=True)
     ticket_id = db.Column(db.Integer, db.ForeignKey('ticket.id', ondelete='CASCADE'), primary_key=True)
     quantity = db.Column(db.Integer)
-    ticket = db.relationship('Ticket', backref='order_tickets')
-
 
 class Order(db.Model):
     __tablename__ = "orders"
diff --git a/app/models/ticket.py b/app/models/ticket.py
--- a/app/models/ticket.py
+++ b/app/models/ticket.py
@@ -31,6 +31,7 @@ class Ticket(db.Model):
     event = db.relationship('Event', backref='tickets')
 
     tags = db.relationship('TicketTag', secondary=ticket_tags_table, backref='tickets')
+    order_ticket = db.relationship('OrderTicket', backref="ticket", passive_deletes=True)
 
     def __init__(self,
                  name=None,
@@ -70,8 +71,10 @@ def has_order_tickets(self):
         Else False.
         """
         from app.helpers.helpers import get_count
-        count = get_count(OrderTicket.query.filter_by(ticket_id=self.id))
-        return bool(count > 0)
+        orders = Order.id.in_( OrderTicket.query.with_entities(OrderTicket.order_id).filter_by(ticket_id=self.id).all() )
+        count =  get_count( Order.query.filter(orders).filter(Order.status != 'deleted') )
+        # Count is zero if no completed orders are present
+        return bool( count > 0)
 
     def has_completed_order_tickets(self):
         """Returns True if ticket has already placed orders.


Test patch:
Repository: fossasia/open-event-server

Issue:
Add Albania to the list of Countries for Currency
Paypal does not accept the local Albanian currency, but it accepts it as a country for account holders.

https://www.paypal.com/al/cgi-bin/webscr?cmd=_display-xborder-fees-outside&countries=

Please add Albania to the list of countries, where payments are accepted (dropdown menu).


Discussion:

Resolving patch:
diff --git a/app/helpers/static.py b/app/helpers/static.py
--- a/app/helpers/static.py
+++ b/app/helpers/static.py
@@ -153,6 +153,7 @@
 }
 PAYMENT_COUNTRIES = {
     'United States',
+    'Albania'
     'Argentina',
     'Australia',
     'Austria',


Test patch: