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

Issue:
Export speaker images with their full names
https://github.com/fossasia/open-event/issues/61#issuecomment-239312104

> Another point is that I see photos are not saved according to names of speakers in the speaker folder for example and there is also an svg file in the speaker folder. Could you export the files as -SpeakergivennameSpeakerfamilyname.png/jpg, please? Please open a dedicated issue.

Since ID of an object is also important when exporting, I propose to export speaker images as 
`ID_FirstnameLastname.ext` . Eg > `2_MarioBehling.jpg` . Also there can be cases where names of 2 speakers are same. This implementation will cover that as well. 
@mariobehling What do you think ?



Discussion:
Ok, but please add the ID at the end e.g. HongPhucDang_2.ext. Cheers.

Please change this also in the open event sample files. Check that you do not overwrite changes that others have made, please.


Resolving patch:
diff --git a/app/api/helpers/export_helpers.py b/app/api/helpers/export_helpers.py
--- a/app/api/helpers/export_helpers.py
+++ b/app/api/helpers/export_helpers.py
@@ -72,7 +72,7 @@
         'slides': ['document', '/slides/session_%d']
     },
     'speakers': {
-        'photo': ['image', '/images/speakers/photo_%d']
+        'photo': ['image', '/images/speakers/%s_%d']
     },
     'event': {
         'logo': ['image', '/images/logo'],
@@ -118,7 +118,9 @@ def _download_media(data, srv, dir_path, settings):
         if not settings[DOWNLOAD_FIEDLS[srv][i][0]]:
             continue
         path = DOWNLOAD_FIEDLS[srv][i][1]
-        if srv != 'event':
+        if srv == 'speakers':
+            path = path % (make_speaker_name(data['name']), data['id'])
+        elif srv != 'event':
             path = path % (data['id'])
         if data[i].find('.') > -1:  # add extension
             ext = data[i].rsplit('.', 1)[1]
@@ -220,3 +222,10 @@ def send_export_mail(event_id, result):
     else:
         event_name = event.name
     send_email_after_export(job.user_email, event_name, result)
+
+
+# FIELD DATA FORMATTERS
+
+def make_speaker_name(name):
+    """Make speaker image filename for export"""
+    return ''.join(s.title() for s in name.split() if s)


Test patch:
diff --git a/tests/api/test_export_import.py b/tests/api/test_export_import.py
--- a/tests/api/test_export_import.py
+++ b/tests/api/test_export_import.py
@@ -113,6 +113,8 @@ def test_export_media(self):
         """
         resp = self._put(get_path(1), {'logo': 'https://placehold.it/350x150'})
         self.assertIn('placehold', resp.data, resp.data)
+        # set speaker photo so that its export is checked
+        resp = self._put(get_path(1, 'speakers', 1), {'photo': 'https://placehold.it/350x150'})
         self._create_set()
         dr = 'static/temp/test_event_import'
         data = open(dr + '/event', 'r').read()
Repository: fossasia/open-event-server

Issue:
OSError when exporting event with speaker name having quotes
Eg > Andreas"Andz"Müller

When the speaker image is exported, it should remove any filesystem non-friendly characters that the speaker name has. 



Discussion:

Resolving patch:
diff --git a/app/api/helpers/export_helpers.py b/app/api/helpers/export_helpers.py
--- a/app/api/helpers/export_helpers.py
+++ b/app/api/helpers/export_helpers.py
@@ -86,6 +86,9 @@
     }
 }
 
+# strings to remove in a filename
+FILENAME_EXCLUDE = '<>:"/\|?*;'
+
 
 # FUNCTIONS
 
@@ -228,4 +231,6 @@ def send_export_mail(event_id, result):
 
 def make_speaker_name(name):
     """Make speaker image filename for export"""
+    for _ in FILENAME_EXCLUDE:
+        name = name.replace(_, ' ')
     return ''.join(s.title() for s in name.split() if s)


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

Issue:
Ordering new tickets gives IntegrityError
IntegrityError: (raised as a result of Query-invoked autoflush; consider using a session.no_autoflush block if this flush is occurring prematurely) (psycopg2.IntegrityError) null value in column "order_id" violates not-null constraint
DETAIL:  Failing row contains (null, 1, 4).
 [SQL: 'INSERT INTO orders_tickets (ticket_id, quantity) VALUES (%(ticket_id)s, %(quantity)s) RETURNING orders_tickets.order_id'] [parameters: {'ticket_id': 1, 'quantity': 4}]



Discussion:

Resolving patch:
diff --git a/app/helpers/ticketing.py b/app/helpers/ticketing.py
--- a/app/helpers/ticketing.py
+++ b/app/helpers/ticketing.py
@@ -9,6 +9,7 @@
 
 from flask.ext import login
 
+from app.models import db
 from app.helpers.cache import cache
 from app.helpers.data import save_to_db
 from app.helpers.helpers import string_empty, send_email_for_after_purchase, get_count
@@ -183,15 +184,16 @@ def create_order(form, from_organizer=False):
         amount = 0
         for index, id in enumerate(ticket_ids):
             if not string_empty(id) and int(ticket_quantity[index]) > 0:
-                order_ticket = OrderTicket()
-                order_ticket.ticket = TicketingManager.get_ticket(id)
-                order_ticket.quantity = int(ticket_quantity[index])
-                order.tickets.append(order_ticket)
-
-                if from_organizer:
-                    amount += int(ticket_subtotals[index])
-                else:
-                    amount += (order_ticket.ticket.price * order_ticket.quantity)
+                with db.session.no_autoflush:
+                    order_ticket = OrderTicket()
+                    order_ticket.ticket = TicketingManager.get_ticket(id)
+                    order_ticket.quantity = int(ticket_quantity[index])
+                    order.tickets.append(order_ticket)
+
+                    if from_organizer:
+                        amount += int(ticket_subtotals[index])
+                    else:
+                        amount += (order_ticket.ticket.price * order_ticket.quantity)
 
         order.amount = amount
 


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

Issue:
Admin: Sorting of time/dates not correct
The sorting of time and dates in admin tables where this is relevant are not correct, e.g. in the users section if I sort according to "member since" the top result is "10 days ago". People who have just registered yesterday appear on a lower point in the list.

Please fix this on all admin tabs and tables.

![screenshot from 2016-08-17 09 35 05](https://cloud.githubusercontent.com/assets/1583873/17728157/2d79afc2-645e-11e6-9c82-ac2c7e66edd4.png)



Discussion:

Resolving patch:
diff --git a/app/__init__.py b/app/__init__.py
--- a/app/__init__.py
+++ b/app/__init__.py
@@ -231,6 +231,13 @@ def humanize_alt_filter(time):
     return humanize.naturaltime(datetime.now() - time)
 
 
+@app.template_filter('time_format')
+def time_filter(time):
+    if not time:
+        return "N/A"
+    return time
+
+
 @app.template_filter('firstname')
 def firstname_filter(string):
     if string:


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

Issue:
Simplify Admin Sections and Description and enhance Admin Dashboard
Let's keep it more simple, please:
- [x] In Admin section rename tab heading as follows: 
  - Manage All Users -> Users; 
  - Manage All Permissions -> Permissions; 
  - See System Messages -> System Messages; 
  - Manage All Reports -> Reports;
  - Manage All Settings -> Settings; 
  - Manage All Modules -> Modules; 
- [x] Move Logs to become a subtab in "Report" and implement as follows
  - [x] Subtab a) System Logs
  - [x] Subtab b) Server Logs (currently Heroku) 
- [x] In admin dashboard in `/admin/` take out "Recent Events"
- [x] In admin dashboard implement the following widgets
  - [x] Add Widget "Events" with the information: Number of Events a) Live, b) Draft, c) Past
  - [x] Add Widget "Users" with information: a) System Roles: Number of Super Admins, Admins and Registered Users and b) Event Roles: Number of Organizers, Co-Organizers, Track Organizers, Attendees of all events
  - [x] Add Widget "Sessions" with number of Accepted and Draft Sessions
  - [x] Add Widget "Messages" with information "Number of sent out emails in the last 24 hours, last 3 days, last 7 days, last month and number of all emails sent out since installation.



Discussion:
- [x] The admin dashboard is leaving white spaces between sections. Please implement without white spaces. Compare to event dashboard for ideas.

![screenshot from 2016-08-16 10 43 08](https://cloud.githubusercontent.com/assets/1583873/17693292/676f891a-639e-11e6-91f6-93cd7e1cccb1.png)

- [x] Number of event organizers and other event roles is 0. It should not be.

![screenshot from 2016-08-16 10 46 01](https://cloud.githubusercontent.com/assets/1583873/17693351/b0b5ae6a-639e-11e6-865a-516c6a383232.png)

@aditya1702 I will do this

Thank you for fixing this.

Currently the panel shows 108 organizers and 11 co-organizers. The event section shows - including live, draft, past events - 99 events.

Please explain how the numbers are calculated.

![screenshot from 2016-08-17 09 29 48](https://cloud.githubusercontent.com/assets/1583873/17728060/7cc376d6-645d-11e6-8927-f38a5ff06799.png)

@mariobehling definitely it is a mistake, i've checked it. 108 organizer because there are events wchi don't exist. I will fix it 


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
@@ -774,7 +774,7 @@ def get_all_registered_users():
     @staticmethod
     def get_all_user_roles(role_name):
         role = Role.query.filter_by(name=role_name).first()
-        uers = UsersEventsRoles.query.filter_by(role=role)
+        uers = UsersEventsRoles.query.join(UsersEventsRoles.event).join(UsersEventsRoles.role).filter(Event.in_trash == False).filter(UsersEventsRoles.role==role)
         return uers
 
     @staticmethod


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

Issue:
Add column with time/date or sent out of messages to admin message tab
On http://open-event-dev.herokuapp.com/admin/messages/
- [x] Add column "Time/Date of Sent out" information, e.g. Monthly Payment Follow Up Email "15th day of the month",  Monthly Payment Email "1st day of the month", After Event mail "2 days after event"



Discussion:

Resolving patch:
diff --git a/app/helpers/system_mails.py b/app/helpers/system_mails.py
--- a/app/helpers/system_mails.py
+++ b/app/helpers/system_mails.py
@@ -62,7 +62,8 @@
             "Thank You for participating in our event. We hope you enjoyed it. "
             "Please check the list of more upcoming events" +
             "Here are the upcoming events: {up_coming_events} .Get ready!! "
-        )
+        ),
+        'sent_at': '1 day after the event'
     },
     NEW_SESSION: {
         'recipient': 'Organizer',
@@ -165,7 +166,8 @@
             "<br/> That payment for the same has to be made in two weeks. <a href='{payment_url}'>Click here</a> to "
             "view your invoice and complete the payment."
             "<br><br><em>Thank you for using Open Event.</em>"
-        )
+        ),
+        'sent_at': '1st day of the month'
     },
     MONTHLY_PAYMENT_FOLLOWUP_EMAIL: {
         'recipient': 'Organizer',
@@ -175,6 +177,7 @@
             "<br/> That payment for the same is past the due date. <a href='{payment_url}'>Click here</a> to "
             "view your invoice and complete the payment to prevent loss of functionality."
             "<br><br><em>Thank you for using Open Event.</em>"
-        )
-    },
+        ),
+        'sent_at': '15th day of the month'
+    }
 }


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

Issue:
Only show ticket box, if tickets are on sale (except if they are sold out etc.)
Currently the ticket box seems to show up, if no tickets were defined for sale. 

![screenshot from 2016-08-20 10 13 41](https://cloud.githubusercontent.com/assets/1583873/17829948/0421d2d6-66bf-11e6-8385-34e068654277.png)

Please implement as follows:
- [x] If no tickets were defined show: no ticket box
- [x] if ticket sale has ended show information in box about the end of the ticket sales (like eventbrite)
- [x] if ticket sale has not started show information in box when it will start (like eventbrite)
- [x] if URL has been defined and ticket system is not used, show: Ticket URL



Discussion:

Resolving patch:
diff --git a/app/__init__.py b/app/__init__.py
--- a/app/__init__.py
+++ b/app/__init__.py
@@ -185,6 +185,10 @@ def pages():
     pages = DataGetter.get_all_pages()
     return dict(system_pages=pages)
 
+@app.context_processor
+def datetime_now():
+    return dict(datetime_now=datetime.now())
+
 @app.context_processor
 def social_settings():
     settings = get_settings()
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
@@ -735,7 +735,9 @@ def get_locations_of_events():
             return names
 
     @staticmethod
-    def get_sales_open_tickets(event_id):
+    def get_sales_open_tickets(event_id, give_all=False):
+        if give_all:
+            return Ticket.query.filter(Ticket.event_id == event_id)
         return Ticket.query.filter(Ticket.event_id == event_id).filter(
             Ticket.sales_start <= datetime.datetime.now()).filter(
             Ticket.sales_end >= datetime.datetime.now())
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
@@ -49,7 +49,7 @@ def display_event_detail_home(self, identifier):
             licence_details = None
 
         module = DataGetter.get_module()
-        tickets = DataGetter.get_sales_open_tickets(event.id)
+        tickets = DataGetter.get_sales_open_tickets(event.id, True)
         return self.render('/gentelella/guest/event/details.html',
                            event=event,
                            placeholder_images=placeholder_images,
@@ -168,7 +168,7 @@ def display_event_tickets(self, identifier):
         else:
             licence_details = None
         module = DataGetter.get_module()
-        tickets = DataGetter.get_sales_open_tickets(event.id)
+        tickets = DataGetter.get_sales_open_tickets(event.id, True)
         return self.render('/gentelella/guest/event/details.html',
                            event=event,
                            placeholder_images=placeholder_images,


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

Issue:
Export sponsor logos with sponsor names
Export sponsor logos in zip as `SponsorName_ID.ext` instead of `logo_ID.ext` 

Gitter link: https://gitter.im/fossasia/open-event-orga-server?at=57b7680e5ffbca3e3cf77f31



Discussion:

Resolving patch:
diff --git a/app/api/helpers/export_helpers.py b/app/api/helpers/export_helpers.py
--- a/app/api/helpers/export_helpers.py
+++ b/app/api/helpers/export_helpers.py
@@ -79,7 +79,7 @@
         'background_image': ['image', '/images/background']
     },
     'sponsors': {
-        'logo': ['image', '/images/sponsors/logo_%d']
+        'logo': ['image', '/images/sponsors/%s_%d']
     },
     'tracks': {
         'track_image_url': ['image', '/images/tracks/image_%d']
@@ -122,7 +122,9 @@ def _download_media(data, srv, dir_path, settings):
             continue
         path = DOWNLOAD_FIEDLS[srv][i][1]
         if srv == 'speakers':
-            path = path % (make_speaker_name(data['name']), data['id'])
+            path = path % (make_filename(data['name']), data['id'])
+        elif srv == 'sponsors':
+            path = path % (make_filename(data['name']), data['id'])
         elif srv != 'event':
             path = path % (data['id'])
         if data[i].find('.') > -1:  # add extension
@@ -232,7 +234,7 @@ def send_export_mail(event_id, result):
 
 # FIELD DATA FORMATTERS
 
-def make_speaker_name(name):
+def make_filename(name):
     """Make speaker image filename for export"""
     for _ in FILENAME_EXCLUDE:
         name = name.replace(_, ' ')


Test patch:
diff --git a/tests/unittests/api/test_export_import.py b/tests/unittests/api/test_export_import.py
--- a/tests/unittests/api/test_export_import.py
+++ b/tests/unittests/api/test_export_import.py
@@ -119,6 +119,8 @@ def test_export_media(self):
         self.assertIn('placehold', resp.data, resp.data)
         # set speaker photo so that its export is checked
         resp = self._put(get_path(1, 'speakers', 1), {'photo': 'https://placehold.it/350x150'})
+        # set sponsor photo so that its export is checked
+        resp = self._put(get_path(1, 'sponsors', 1), {'photo': 'https://placehold.it/350x150'})
         # set event title as unicode
         resp = self._put(get_path(1), {'organizer_name': 'SandraMüllrick'})
         # export and unzip files
Repository: fossasia/open-event-server

Issue:
Event -> has_session_speakers missing in API and Import/Export
That field is responsible for turning on/off the sessions-speakers module.  



Discussion:

Resolving patch:
diff --git a/app/api/events.py b/app/api/events.py
--- a/app/api/events.py
+++ b/app/api/events.py
@@ -96,7 +96,8 @@
     'code_of_conduct': fields.String(),
     'social_links': fields.List(fields.Nested(SOCIAL_LINK), attribute='social_link'),
     'call_for_papers': fields.Nested(EVENT_CFS, allow_null=True),
-    'version': fields.Nested(EVENT_VERSION)
+    'version': fields.Nested(EVENT_VERSION),
+    'has_session_speakers': fields.Boolean(default=False)
 })
 
 EVENT_COMPLETE = api.clone('EventComplete', EVENT, {
diff --git a/app/api/helpers/custom_fields.py b/app/api/helpers/custom_fields.py
--- a/app/api/helpers/custom_fields.py
+++ b/app/api/helpers/custom_fields.py
@@ -2,7 +2,7 @@
 import colour
 from datetime import datetime
 from flask import request
-from flask.ext.restplus.fields import Raw, Nested, List, Boolean
+from flask.ext.restplus.fields import Raw, Nested, List
 
 
 EMAIL_REGEX = re.compile(r'\S+@\S+\.\S+')
@@ -223,6 +223,18 @@ def validate(self, value):
             return False
 
 
+class Boolean(CustomField):
+    """Custom Boolean Field"""
+    __schema_type__ = 'boolean'
+    __schema_example__ = False
+
+    def validate(self, value):
+        if type(value) != bool:
+            return False
+        else:
+            return True
+
+
 class ChoiceString(String):
     """
     Choice String Field. Allow only one of the given options


Test patch:
diff --git a/tests/unittests/api/test_post_api_validation.py b/tests/unittests/api/test_post_api_validation.py
--- a/tests/unittests/api/test_post_api_validation.py
+++ b/tests/unittests/api/test_post_api_validation.py
@@ -19,7 +19,7 @@ def test_event_api(self):
             'event',
             POST_EVENT_DATA,
             ['email', 'logo', 'event_url', 'background_image',
-                'type', 'topic', 'privacy', 'sub_topic', 'state']
+                'type', 'topic', 'privacy', 'sub_topic', 'state', 'has_session_speakers']
         )
 
     def test_speaker_api(self):
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
@@ -41,7 +41,8 @@
         "start_date": "2016-06-29T19:30:00",
         "timezone": "UTC"
     },
-    "identifier": "23c0644e"
+    "identifier": "23c0644e",
+    "has_session_speakers": True
 }
 
 POST_SOCIAL_LINK_DATA = {
Repository: fossasia/open-event-server

Issue:
Locations missing in panel after migrations
Same as with social links locations often get deleted after migrations.

![screenshot from 2016-08-20 13 23 09](https://cloud.githubusercontent.com/assets/1583873/17830854/65f64da6-66d9-11e6-83ea-4b76d2f5bc87.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
@@ -497,17 +497,12 @@ def get_all_live_events():
 
     @staticmethod
     def get_live_and_public_events():
-        return DataGetter.get_all_live_events().filter(Event.privacy != 'private').filter(Event.in_trash == False)\
-            .filter_by(in_trash=False)
+        return DataGetter.get_all_live_events().filter(Event.privacy != 'private')
 
     @staticmethod
     def get_all_draft_events():
         return Event.query.filter_by(state='Draft', in_trash=False)
 
-    @staticmethod
-    def get_live_and_public_events():
-        return DataGetter.get_all_live_events().filter(Event.privacy != 'private').filter(not Event.in_trash)
-
     @staticmethod
     def get_all_past_events():
         return Event.query.filter(Event.end_time <= datetime.datetime.now(),


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

Issue:
Ensure social links are taken care of in migrations
Currently social links often disappear after updates. Please ensure they are part of migrations.



Discussion:
Social links still getting lost after updates.


Resolving patch:
diff --git a/app/__init__.py b/app/__init__.py
--- a/app/__init__.py
+++ b/app/__init__.py
@@ -27,7 +27,7 @@
 import json
 from flask import Flask, session
 from flask.ext.autodoc import Autodoc
-from app.settings import get_settings
+from app.settings import get_settings, get_setts
 from flask.ext.cors import CORS
 from flask.ext.migrate import Migrate, MigrateCommand
 from flask.ext.script import Manager
@@ -218,8 +218,8 @@ def datetime_now():
 
 @app.context_processor
 def social_settings():
-    settings = get_settings()
-    return dict(settings=settings)
+    settings = get_setts()
+    return dict(settes=settings)
 
 
 @app.template_filter('pretty_name')
diff --git a/app/settings/__init__.py b/app/settings/__init__.py
--- a/app/settings/__init__.py
+++ b/app/settings/__init__.py
@@ -1,6 +1,6 @@
 import stripe
 from flask import current_app
-from sqlalchemy import desc
+from sqlalchemy import asc, desc
 from app.models.setting import Setting
 from app.models.fees import TicketFees
 
@@ -18,6 +18,8 @@ def get_settings():
         current_app.config['custom_settings'] = make_dict(s)
     return current_app.config['custom_settings']
 
+def get_setts():
+    return Setting.query.order_by(desc(Setting.id)).first()
 
 def set_settings(**kwargs):
     """
@@ -50,7 +52,7 @@ def set_settings(**kwargs):
                 save_to_db(fee, "Fee Options Updated")
                 i += 1
     else:
-        setting = Setting.query.first()
+        setting = Setting.query.order_by(desc(Setting.id)).first()
         if not setting:
             setting = Setting(**kwargs)
         else:
diff --git a/app/views/admin/super_admin/content.py b/app/views/admin/super_admin/content.py
--- a/app/views/admin/super_admin/content.py
+++ b/app/views/admin/super_admin/content.py
@@ -37,7 +37,6 @@ def placeholder_upload(self):
         if request.method == 'POST':
             placeholder_image = request.form['placeholder']
             filename = request.form['file_name']
-            print filename
             if placeholder_image:
                 placeholder_file = uploaded_file(file_content=placeholder_image)
                 placeholder = upload(
@@ -77,7 +76,6 @@ def placeholder_upload(self):
     @expose('/update_placeholder', methods=('POST',))
     def placeholder_upload_details(self):
         if request.method == 'POST':
-            print request.form
             copyright_info = request.form['copyright']
             origin_info = request.form['origin']
             placeholder_id = request.form['placeholder_id']


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

Issue:
Internal error in settings
http://open-event-dev.herokuapp.com/admin/settings/



Discussion:

Resolving patch:
diff --git a/migrations/versions/81fe5a689259_.py b/migrations/versions/81fe5a689259_.py
new file mode 100644
--- /dev/null
+++ b/migrations/versions/81fe5a689259_.py
@@ -0,0 +1,23 @@
+"""empty message
+
+Revision ID: 81fe5a689259
+Revises: ('4891e2b124f8', '59d045580f02')
+Create Date: 2016-08-26 11:03:45.791789
+
+"""
+
+# revision identifiers, used by Alembic.
+revision = '81fe5a689259'
+down_revision = ('4891e2b124f8', '59d045580f02')
+
+from alembic import op
+import sqlalchemy as sa
+import sqlalchemy_utils
+
+
+def upgrade():
+    pass
+
+
+def downgrade():
+    pass


Test patch: