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

Issue:
Organizers of OSCAL getting Internal Server Error



Discussion:

Resolving patch:
diff --git a/app/helpers/permission_decorators.py b/app/helpers/permission_decorators.py
--- a/app/helpers/permission_decorators.py
+++ b/app/helpers/permission_decorators.py
@@ -169,14 +169,6 @@ def decorated_function(*args, **kwargs):
 
         if user.is_staff:
             return f(*args, **kwargs)
-        if 'events/' + str(event_id) + '/' in url:
-            if not user.has_role(event_id):
-                abort(403)
-            if user.is_registrar(event_id):
-                if '/attendees' in url:
-                    return f(*args, **kwargs)
-                else:
-                    abort(403)
         if '/create/' in url or '/new/' in url:
             if '/events/create/' in url:
                 return f(*args, **kwargs)
@@ -239,5 +231,14 @@ def decorated_function(*args, **kwargs):
                 if user.can_delete(Microlocation, event_id):
                     return f(*args, **kwargs)
             abort(403)
+        if 'events/' + str(event_id) + '/' in url:
+            if not user.has_role(event_id):
+                abort(403)
+            if user.is_registrar(event_id):
+                if '/attendees' in url:
+                    return f(*args, **kwargs)
+                else:
+                    abort(403)
+            return f(*args, **kwargs)
 
     return decorated_function


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

Issue:
Organizer get error when trying to download csv or pdf list of attendees
OSCAL organizers encounter this issue.

![screenshot from 2017-04-13 18-32-54](https://cloud.githubusercontent.com/assets/1583873/25026747/64a4acb6-20a8-11e7-9a4b-e24671a17392.png)



Discussion:

Resolving patch:
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
@@ -276,7 +276,7 @@ def display_attendees(event_id, pdf=None):
 @event_ticket_sales.route('/attendees/pdf')
 @can_access
 def download_as_pdf(event_id):
-    (event, event_id, holders, orders, ticket_names, selected_ticket) = display_attendees(event_id, pdf='print_pdf')
+    (event, event_id, holders, orders, ticket_names, selected_ticket) = display_attendees(event_id=event_id, pdf='print_pdf')
     pdf = create_pdf(render_template('gentelella/users/events/tickets/download_attendees.html', event=event,
                                      event_id=event_id, holders=holders, ticket_names=ticket_names,
                                      selected_ticket=selected_ticket))
@@ -290,7 +290,7 @@ def download_as_pdf(event_id):
 @event_ticket_sales.route('/attendees/csv')
 @can_access
 def download_as_csv(event_id):
-    (event, event_id, holders, orders, ticket_names, selected_ticket) = display_attendees(event_id, pdf='print_csv')
+    (event, event_id, holders, orders, ticket_names, selected_ticket) = display_attendees(event_id=event_id, pdf='print_csv')
     value = 'Order#,Order Date, Status, First Name, Last Name, Email, Country,' \
             'Payment Type, Ticket Name, Ticket Price, Ticket Type \n'
 
@@ -342,7 +342,7 @@ def download_as_csv(event_id):
 @event_ticket_sales.route('/orders/pdf')
 @can_access
 def download_orders_as_pdf(event_id):
-    (event, event_id, orders, discount_code) = display_orders(event_id, pdf='print_pdf')
+    (event, event_id, orders, discount_code) = display_orders(event_id=event_id, pdf='print_pdf')
     pdf = create_pdf(render_template('gentelella/users/events/tickets/download_orders.html', event=event, event_id=event_id,
                                      orders=orders, discount_code=discount_code))
     response = make_response(pdf.getvalue())
@@ -355,7 +355,7 @@ def download_orders_as_pdf(event_id):
 @event_ticket_sales.route('/orders/csv')
 @can_access
 def download_orders_as_csv(event_id):
-    (event, event_id, holders, orders, ticket_names, selected_ticket) = display_attendees(event_id, pdf='print_csv')
+    (event, event_id, holders, orders, ticket_names, selected_ticket) = display_attendees(event_id=event_id, pdf='print_csv')
     value = 'Order#,Order Date, Status, Payment Type, Quantity,Total Amount,Discount Code,' \
             'First Name, Last Name, Email \n'
 


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

Issue:
Order Details: Billing details don't show name.
The information in the billing details for an order isn't shown properly. The name is not shown in any cases and many of the time the other details are also not shown and instead `none` is shown.


Discussion:

Resolving patch:
diff --git a/app/views/public/ticketing.py b/app/views/public/ticketing.py
--- a/app/views/public/ticketing.py
+++ b/app/views/public/ticketing.py
@@ -105,7 +105,7 @@ def view_order_after_payment(order_identifier):
 @ticketing.route('/<order_identifier>/view/pdf/')
 def view_order_after_payment_pdf(order_identifier):
     order = TicketingManager.get_and_set_expiry(order_identifier)
-    if not order or order.status != 'completed':
+    if not order or (order.status != 'completed' and order.status != 'placed'):
         abort(404)
     pdf = create_pdf(render_template('gentelella/guest/ticketing/invoice_pdf.html',
                                      order=order, event=order.event))
@@ -119,7 +119,7 @@ def view_order_after_payment_pdf(order_identifier):
 @ticketing.route('/<order_identifier>/view/tickets/pdf/')
 def view_order_tickets_after_payment_pdf(order_identifier):
     order = TicketingManager.get_and_set_expiry(order_identifier)
-    if not order or order.status != 'completed':
+    if not order or (order.status != 'completed' and order.status != 'placed'):
         abort(404)
     pdf = create_pdf(render_template('gentelella/guest/ticketing/pdf/ticket.html', order=order))
     response = make_response(pdf.getvalue())


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

Issue:
Ticket email alert remains on the ticket view page
When we navigate to ticket view page through **My Tickets**, the ticket email alert remains on the top.

Expected: It should only appear when user buys a ticket and he is redirected to ticket view page.

![screenshot 33](https://cloud.githubusercontent.com/assets/13533840/25249667/44287dc2-2630-11e7-83b7-ff808693ada9.png)



Discussion:
I will work on this.

Resolving patch:
diff --git a/app/views/public/ticketing.py b/app/views/public/ticketing.py
--- a/app/views/public/ticketing.py
+++ b/app/views/public/ticketing.py
@@ -76,6 +76,7 @@ def view_order(order_identifier):
     if not order or order.status == 'expired':
         abort(404)
     if order.status == 'completed' or order.status == 'placed':
+        flash("An email with the ticket has also been sent to your email account.")
         return redirect(url_for('ticketing.view_order_after_payment', order_identifier=order_identifier))
 
     if order.event.stripe:
@@ -94,7 +95,6 @@ def view_order_after_payment(order_identifier):
     order = TicketingManager.get_and_set_expiry(order_identifier)
     if not order or (order.status != 'completed' and order.status != 'placed'):
         abort(404)
-    flash("An email with the ticket has also been sent to your email account.")
     fees = DataGetter.get_fee_settings_by_currency(order.event.payment_currency)
     return render_template('gentelella/guest/ticketing/order_post_payment.html',
                            order=order,


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

Issue:
If speaker edit their profile or session they are unassigned
If speaker edit their profile or session they are unassigned from their session. Result: Organizer needs to re-add them to the session.

Expected: If speaker edit profile or session nothing should change. Sessions should still have the same speaker and same status.


Discussion:

Resolving patch:
diff --git a/app/views/users/my_sessions.py b/app/views/users/my_sessions.py
--- a/app/views/users/my_sessions.py
+++ b/app/views/users/my_sessions.py
@@ -81,12 +81,14 @@ def process_session_view(session_id):
             return redirect(url_for('.display_my_sessions_view', event_id=session.event_id))
         session_form = json.loads(form_elems.session_form)
         event = DataGetter.get_event(session.event_id)
+        speakers = DataGetter.get_speakers(session.event_id).all()
         return render_template(
             'gentelella/users/mysessions/mysession_session_edit.html',
             session=session,
             speaker=speaker,
             session_form=session_form,
-            event=event)
+            event=event,
+            speakers=speakers)
 
     if request.method == 'POST':
         session = DataGetter.get_sessions_of_user_by_id(session_id)


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

Issue:
Call for speakers section shows all live events
The call for speakers section on the home page, shows all live events irrespective of whether they have an active call for speakers or not.

**Expected:** 
Show only events that have a call for speakers open right now.


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
@@ -424,11 +424,11 @@ def get_all_published_events(include_private=False):
     def get_call_for_speakers_events(include_private=False):
         events = DataGetter.get_all_published_events(include_private)
         return [event for event in events
-                if DataGetter.get_call_for_papers(event.id)
+                if DataGetter.get_open_call_for_papers(event.id)
                 and not event.deleted_at][:12]
 
     @staticmethod
-    def get_call_for_papers(event_id):
+    def get_open_call_for_papers(event_id):
         datetime_now = datetime.datetime.now()
         return CallForPaper.query.filter_by(
             event_id=event_id


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

Issue:
Entering and saving a ticket should result in immediate ticket display
If the user enters a new ticket, the ticket time is set to the time the ticket is created. However, the ticket does not display immediately. Apparently the time zone of the server or system or user is not aligned.

Please ensure the ticket is immediately displayed (if the user does not set another start time).


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
@@ -735,8 +735,8 @@ def get_locations_of_events():
     @staticmethod
     def get_sales_open_tickets(event_id, event_timezone='UTC'):
         tickets = Ticket.query.filter(Ticket.event_id == event_id).filter(
-            Ticket.sales_start <= datetime.datetime.now(pytz.timezone(event_timezone))).filter(
-            Ticket.sales_end >= datetime.datetime.now(pytz.timezone(event_timezone)))
+            Ticket.sales_start <= datetime.datetime.now(pytz.timezone(event_timezone)).replace(tzinfo=None)).filter(
+            Ticket.sales_end >= datetime.datetime.now(pytz.timezone(event_timezone)).replace(tzinfo=None))
         open_tickets = []
         for ticket in tickets:
             orders = OrderTicket.query.filter(OrderTicket.ticket_id == ticket.id)


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

Issue:
Ticket ordering does not work for existing events
Related issue: #2853
Caused by: #3527

Ticket ordering now works for events that were created after implementation of the ordering functionality. But we need it to work for events created before too. 

**Expected:**
Ticket ordering should work for all events.


Discussion:

Resolving patch:
diff --git a/app/helpers/wizard/event.py b/app/helpers/wizard/event.py
--- a/app/helpers/wizard/event.py
+++ b/app/helpers/wizard/event.py
@@ -93,7 +93,9 @@ def get_event_json(event_id):
             result["social_links"].append(social_link.serialize)
 
     sorted_tickets = sorted(event.tickets, key=lambda x: x.position)
-    for ticket in sorted_tickets:
+    for index, ticket in enumerate(sorted_tickets):
+        if not ticket.position:
+            ticket.position = index + 1
         result["tickets"].append(ticket.serialize)
 
     if event.stripe:


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

Issue:
Updating system images through UI resulting in error and eternal upload screen
Trying to update system images is not successful at https://eventyay.com/admin/content/#

![screenshot from 2017-04-28 10-56-33](https://cloud.githubusercontent.com/assets/1583873/25521875/818881e0-2c01-11e7-823b-2995a898853f.png)



Discussion:

Resolving patch:
diff --git a/app/views/super_admin/content.py b/app/views/super_admin/content.py
--- a/app/views/super_admin/content.py
+++ b/app/views/super_admin/content.py
@@ -15,7 +15,7 @@
 from app.helpers.data import DataManager, delete_from_db, save_to_db
 from app.helpers.data_getter import DataGetter
 from app.helpers.helpers import uploaded_file
-from app.helpers.storage import upload, UploadedFile
+from app.helpers.storage import upload, upload_local, UploadedFile
 from app.models.custom_placeholder import CustomPlaceholder
 from app.settings import get_settings, set_settings
 from app.views.super_admin import check_accessible, CONTENT, list_navbar
@@ -67,23 +67,26 @@ def placeholder_upload():
                 placeholder_file,
                 'placeholders/original/' + filename
             )
-            temp_img_file = placeholder.replace('/serve_', '')
 
-            basewidth = 300
-            img = Image.open(temp_img_file)
-            wpercent = (basewidth / float(img.size[0]))
-            hsize = int((float(img.size[1]) * float(wpercent)))
-            img = img.resize((basewidth, hsize), PIL.Image.ANTIALIAS)
             try:
                 os.mkdir(app.config['TEMP_UPLOADS_FOLDER'])
             except OSError as exc:
                 if exc.errno != errno.EEXIST:
                     raise exc
                 pass
+
+            placeholder_local = upload_local(placeholder_file, app.config['TEMP_UPLOADS_FOLDER'] + filename)
+            temp_img_file = placeholder_local.replace('/serve_', '')
+            basewidth = 300
+            img = Image.open(temp_img_file)
+            wpercent = (basewidth / float(img.size[0]))
+            hsize = int((float(img.size[1]) * float(wpercent)))
+            img = img.resize((basewidth, hsize), PIL.Image.ANTIALIAS)
+
             img.save(app.config['TEMP_UPLOADS_FOLDER'] + '/temp.png')
             file_name = temp_img_file.rsplit('/', 1)[1]
             thumbnail_file = UploadedFile(file_path=temp_img_file, filename=file_name)
-            background_thumbnail_url = upload(
+            background_thumbnail_url = upload_local(
                 thumbnail_file,
                 'placeholders/thumbnail/' + filename
             )


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

Issue:
Events showing in location "P" on bottom bar and search
A number of search results are showing events for the search "P". And it is showing Singapore results as well.

![screenshot from 2017-02-19 07-04-44](https://cloud.githubusercontent.com/assets/1583873/23097568/b8c4eb3c-f671-11e6-8a32-51d1ceb7d2ed.png)

Also on the page bottom it shows "P". The location of the OpenTechSumit is Potsdam actually.
![screenshot from 2017-02-19 07-03-16](https://cloud.githubusercontent.com/assets/1583873/23097566/a8c15a36-f671-11e6-84fe-2cfd87b67daa.png)



Discussion:
Hello @mariobehling .
I would like to work on this issue.
@sj29-innovate you can proceed if you have set up the server locally on your PC
@niranjan94 @mariobehling 
SInce no work has been done as of now , I would like to work on this.
Also what exactly do you think it should be displaying , when looking for **'P'** , should it be showing events with the name **P** or should it show events in the **location P** ?
@mariobehling this error happens because of the response from google maps based on the latitude and longitude of the event. Right now the response received for the latitude and longitude for the specific key we are using for Potsdam is P, so it is showing P. And in search you will see that if it's just a single character, then it matches all events. I am trying to find a workaround.

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
@@ -709,26 +709,18 @@ def get_message_setting_by_action(action):
         return MessageSettings.query.filter_by(action=action).first()
 
     @staticmethod
-    @cache.cached(timeout=21600, key_prefix='event_locations')
     def get_locations_of_events():
         names = []
         try:
             for event in DataGetter.get_live_and_public_events():
                 if not string_empty(event.location_name) and not string_empty(event.latitude) and not string_empty(
                      event.longitude):
-
-                    response = requests.get(
-                        "https://maps.googleapis.com/maps/api/geocode/json?latlng=" + str(event.latitude) + "," + str(
-                            event.longitude)).json()
-                    if response['status'] == u'OK':
-                        for addr in response['results'][0]['address_components']:
-                            if addr['types'] == ['locality', 'political']:
-                                names.append(addr['short_name'])
+                    names.append(event.location_name.split(',')[0])
 
             cnt = Counter()
             for location in names:
                 cnt[location] += 1
-            return [v for v, __ in cnt.most_common()][:10]
+            return sorted([v for v, __ in cnt.most_common()][:10])
         except:
             return names
 


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

Issue:
Export of Documents leads to 404
When Trying to export the event as Documents (json files) the page reports that my request was completed successfully.  
However, when clicking on the download link I get a 404.   
In this case, the exact link visited was:  
https://eventyay.com/notifications/opev/open_eventhttps://storage.googleapis.com/eventyay.com/exports/69/aVllSlAvdk/event69.zip



Discussion:
Only taking the second part of the link works.
The only problem seems to be, that the link is not generated correctly.

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
@@ -217,7 +217,7 @@ def export_event_json(event_id, settings):
     uploaded_file = UploadedFile(dir_path, dir_path.rsplit('/', 1)[1])
     storage_url = upload(uploaded_file, storage_path)
 
-    if get_settings()['storage_place'] != "s3" or get_settings()['storage_place'] != 'gs':
+    if get_settings()['storage_place'] != "s3" and get_settings()['storage_place'] != 'gs':
         storage_url = app.config['BASE_DIR'] + storage_url.replace("/serve_","/")
     return storage_url
 


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

Issue:
Scheduling: Bug when two or more co organizers edit the session together.
**I'm submitting a ...** 
- [X] bug report
- [ ] feature request
- [ ] support request => Please do not submit support requests here, instead ask your query in out Gitter channel at https://gitter.im/fossasia/open-event-orga-server

**Current behavior:**
Right now all the organizers and co-organizers are able to edit the scheduling and it is causing error when more than one co-organizers are editing schedule.

**Expected behavior:**
Allow only the organizer to edit schedule.



Discussion:

Resolving patch:
diff --git a/app/views/users/scheduler.py b/app/views/users/scheduler.py
--- a/app/views/users/scheduler.py
+++ b/app/views/users/scheduler.py
@@ -3,6 +3,8 @@
 from flask import Blueprint
 from flask import render_template
 from flask import url_for, flash
+from flask.ext import login
+from flask.ext.restplus import abort
 from werkzeug.utils import redirect
 
 from app.helpers.data import save_to_db
@@ -15,6 +17,8 @@
 @event_scheduler.route('/')
 @can_access
 def display_view(event_id):
+    if login.current_user.is_coorganizer(event_id):
+        abort(404)
     sessions = DataGetter.get_sessions_by_event_id(event_id)
     event = DataGetter.get_event(event_id)
     if not event.has_session_speakers:
@@ -26,6 +30,8 @@ def display_view(event_id):
 @event_scheduler.route('/publish/')
 @can_access
 def publish(event_id):
+    if login.current_user.is_coorganizer(event_id):
+        abort(404)
     event = DataGetter.get_event(event_id)
     event.schedule_published_on = datetime.now()
     save_to_db(event, "Event schedule published")
@@ -36,6 +42,8 @@ def publish(event_id):
 @event_scheduler.route('/unpublish/')
 @can_access
 def unpublish(event_id):
+    if login.current_user.is_coorganizer(event_id):
+        abort(404)
     event = DataGetter.get_event(event_id)
     event.schedule_published_on = None
     save_to_db(event, "Event schedule unpublished")


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

Issue:
Migration: multiple heads
**I'm submitting a ...**  (check one with "x")
- [x] bug report
- [ ] feature request
- [ ] support request => Please do not submit support requests here, instead ask your query in out Gitter channel at https://gitter.im/fossasia/open-event-orga-server

**Current behavior:**
<!-- Describe how the bug manifests. -->
Migrations: There are two heads currently
652f5bf2e030 (head)
a1c17effff1d (head)

**Expected behavior:**
<!-- Describe what the behavior would be without the bug. -->
Keep only one head

**Steps to reproduce:**
<!-- If you are able to illustrate the bug or feature request with an example, please provide steps to reproduce -->

**Related code:**

```
insert any relevant code here else remove this section
```

**Other information:**
<!-- List any other information that is relevant to your issue. Stack traces, related issues, suggestions on how to fix, Stack Overflow links, forum links, etc. -->

**System information:** 

<!-- Add information about the system your facing this bug on. If you think this is irrelevant or if it's a UI bug or a feature request, please remove this section -->

```
Your operating system
```

```
output of `python --version`
```



Discussion:

Resolving patch:
diff --git a/migrations/versions/a1c17effff1d_.py b/migrations/versions/a1c17effff1d_.py
--- a/migrations/versions/a1c17effff1d_.py
+++ b/migrations/versions/a1c17effff1d_.py
@@ -8,7 +8,7 @@
 
 # revision identifiers, used by Alembic.
 revision = 'a1c17effff1d'
-down_revision = 'ddaa6df27340'
+down_revision = '652f5bf2e030'
 
 from alembic import op
 import sqlalchemy as sa


Test patch: