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

Issue:
Add fields in speaker-session in API
Speaker Form
- [ ] City
- [ ] Sponsorship Required
- [ ] Speaking Experience
- [ ] WHERE DID YOU HEAR ABOUT OUR EVENT?

Session Form
- [ ] Level of Session

API version for issue #2782 #2784 #2785 #2786 


Discussion:
@aviaryan @SaptakS Shall I work on this issue?
@satwikkansal Yes, please proceed.
@SaptakS 
Is there a need to add these fields to Speakers API? IMO we should add them for completeness. 
If not, then maybe this issue can be closed. 
@aviaryan I think the speaker fields should be added for completeness.
@SaptakS ok, will do it. I will also write some tests for them. 

Resolving patch:
diff --git a/app/api/sessions.py b/app/api/sessions.py
--- a/app/api/sessions.py
+++ b/app/api/sessions.py
@@ -37,10 +37,10 @@
     'id': fields.Integer(required=True),
     'name': fields.String(),
     'organisation': fields.String(),
-    'city' : fields.String(),
-    'heard_from' : fields.String(),
-    'speaking_experience' : fields.String(),
-    'sponsorship_required' : fields.String()
+    'city': fields.String(),
+    'heard_from': fields.String(),
+    'speaking_experience': fields.String(),
+    'sponsorship_required': fields.String()
 })
 
 SESSION_MICROLOCATION = api.model('SessionMicrolocation', {
@@ -61,7 +61,7 @@
     'id': fields.Integer(required=True),
     'title': fields.String(required=True),
     'subtitle': fields.String(),
-    'level' : fields.String(),
+    'level': fields.String(),
     'short_abstract': fields.String(),
     'long_abstract': fields.String(),
     'comments': fields.String(),
diff --git a/app/api/speakers.py b/app/api/speakers.py
--- a/app/api/speakers.py
+++ b/app/api/speakers.py
@@ -42,6 +42,10 @@
     'position': fields.String(),
     'country': fields.String(required=True),
     'sessions': fields.List(fields.Nested(SPEAKER_SESSION)),
+    'city': fields.String(),
+    'heard_from': fields.String(),
+    'speaking_experience': fields.String(),
+    'sponsorship_required': 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
@@ -74,7 +74,8 @@
     "video": "http://example.com/video",
     "audio": "http://example.com/audio",
     "signup_url": "http://example.com/signup",
-    "session_type_id": None
+    "session_type_id": None,
+    "level": "TestSessionLevel"
 }
 
 POST_SESSION_TYPE_DATA = {
@@ -97,7 +98,11 @@
     "photo": "http://imgur.com/skds.png",
     "position": "TestSession",
     "twitter": "http://twitter.com/user",
-    "website": "http://website.com"
+    "website": "http://website.com",
+    "city": "TestCity",
+    "heard_from": "TestSource",
+    "speaking_experience": "TestExperience",
+    "sponsorship_required": "Yes"
 }
 
 POST_SPONSOR_DATA = {
Repository: fossasia/open-event-server

Issue:
Cannot save changes in profile
Trying to save any changes in the profile result in an error page.

![screenshot from 2017-01-10 06-25-43](https://cloud.githubusercontent.com/assets/1583873/21794781/ba2e31ba-d6fd-11e6-866c-38778ff3b878.png)

Cannot save changes in profile
Trying to save any changes in the profile result in an error page.

![screenshot from 2017-01-10 06-25-43](https://cloud.githubusercontent.com/assets/1583873/21794781/ba2e31ba-d6fd-11e6-866c-38778ff3b878.png)



Discussion:
I will have a look at it. 
I will have a look at it. 

Resolving patch:
diff --git a/app/helpers/data.py b/app/helpers/data.py
--- a/app/helpers/data.py
+++ b/app/helpers/data.py
@@ -704,22 +704,22 @@ def update_user(form, user_id, contacts_only_update=False):
             user_detail.firstname = form['firstname']
             user_detail.lastname = form['lastname']
 
-            if form['facebook'].strip() != '':
+            if form.get('facebook', '').strip() != '':
                 user_detail.facebook = 'https://facebook.com/' + form['facebook'].strip()
             else:
                 user_detail.facebook = ''
 
-            if form['twitter'].strip() != '':
+            if form.get('twitter', '').strip() != '':
                 user_detail.twitter = 'https://twitter.com/' + form['twitter'].strip()
             else:
                 user_detail.twitter = ''
 
-            if form['instagram'].strip() != '':
+            if form.get('instagram', '').strip() != '':
                 user_detail.instagram = 'https://instagram.com/' + form['instagram'].strip()
             else:
                 user_detail.instagram = ''
 
-            if form['google'].strip() != '':
+            if form.get('google', '').strip() != '':
                 user_detail.google = 'https://plus.google.com/' + form['google'].strip()
             else:
                 user_detail.google = ''


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

Issue:
Implement "Apply" Promotional Code on event site itself
Our promotional code/discount gets applied only after the user advances to the next page.

Expected: 
* [x] There should be an "Apply" button on the right hand side of the promotion field (when it is expanded).
![screenshot from 2017-01-07 19-33-17](https://cloud.githubusercontent.com/assets/1583873/21744213/9ed3ba18-d511-11e6-9eef-06cb652f6cdf.png)

* [ ] After the user hits "Apply":
    * [ ] Display below the ticket type the applied discount, e.g. Discounted 50%
    * [ ] Display the new (discounted) ticket price in the price column and the old ticket price crossed

Compare:

![screenshot from 2017-01-07 19-41-23](https://cloud.githubusercontent.com/assets/1583873/21744210/93941abc-d511-11e6-987c-002254742874.png)



Discussion:
I'd like to 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
@@ -35,6 +35,20 @@ def create_order():
     return redirect(url_for('.view_order', order_identifier=order.identifier))
 
 
+@ticketing.route('/apply_discount/', methods=('POST',))
+def apply_discount():
+    discount = TicketingManager.get_discount_code(request.form.get('event_id'), request.form.get('promo_code', ''))
+    if discount:
+        return jsonify({
+            'discount_type': discount.type,
+            'discount_amount': discount.value,
+            'discount_status': True
+        })
+    else:
+        return jsonify({
+            'discount_status': False
+        })
+
 @ticketing.route('/<order_identifier>/', methods=('GET',))
 def view_order(order_identifier):
     order = TicketingManager.get_and_set_expiry(order_identifier)


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

Issue:
Admin sales section: Navbar absent on fees, fees status, discount code, create discount code section
![selection_063](https://cloud.githubusercontent.com/assets/13910561/21829119/58fd4198-d7ba-11e6-9eed-0f7092fa08a3.png)



Discussion:

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
@@ -91,7 +91,8 @@ def fees_by_events_view():
                            from_date=from_date,
                            to_date=to_date,
                            tickets_total=tickets_total,
-                           fee_total=fee_total)
+                           fee_total=fee_total,
+                           navigation_bar=list_navbar())
 
 
 @sadmin_sales.route('/fees/status/')
@@ -118,7 +119,8 @@ def fees_status_view():
                            current_date=datetime.now(),
                            overdue_date=datetime.now() + timedelta(days=15),
                            invoices=invoices,
-                           to_date=to_date)
+                           to_date=to_date,
+                           navigation_bar=list_navbar())
 
 
 @sadmin_sales.route('/marketer/')
@@ -374,7 +376,7 @@ def sales_by_events_view(path):
 @sadmin_sales.route('/discounts/', methods=('GET',))
 def discount_codes_view():
     discount_codes = InvoicingManager.get_discount_codes()
-    return render_template('gentelella/admin/super_admin/sales/discount_codes.html', discount_codes=discount_codes)
+    return render_template('gentelella/admin/super_admin/sales/discount_codes.html', discount_codes=discount_codes, navigation_bar=list_navbar())
 
 
 @sadmin_sales.route('/discounts/create/', methods=('GET', 'POST'))
@@ -394,7 +396,7 @@ def discount_codes_create(discount_code_id=None):
     marketers = User.query.filter(User.id.in_(active_users_ids)).all()
 
     return render_template('gentelella/admin/super_admin/sales/discount_codes_create.html',
-                           discount_code=discount_code, marketers=marketers)
+                           discount_code=discount_code, marketers=marketers, navigation_bar=list_navbar())
 
 
 @sadmin_sales.route('/discounts/check/duplicate/', methods=('GET',))


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

Issue:
No Flash message showing on clicking save button
When admin clicks on the save button after making changes in admin `modules` and **social links** section in admin `content`, flash message doesn't display showing `Changes Saved Successfully` or something like that.


Discussion:
I'd like to work on this if it's ok.
@PARAG00991 sure ... Go on 
Can I work on this if the work has not been initiated ?

@RajuKoushik I'm working on it.
Sure :) 

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
@@ -10,6 +10,7 @@
 from flask import current_app as app
 from flask import redirect, request, url_for, jsonify, render_template
 from flask import send_from_directory
+from flask import flash
 
 from app.helpers.data import DataManager, delete_from_db, save_to_db
 from app.helpers.data_getter import DataGetter
@@ -47,6 +48,7 @@ def index_view():
         for key, value in dic.items():
             settings[key] = value[0]
             set_settings(**settings)
+        flash("Changes have been saved.")
     return render_template(
         'gentelella/admin/super_admin/content/content.html', pages=pages, settings=settings,
         placeholder_images=placeholder_images, subtopics=subtopics, custom_placeholder=custom_placeholder,
diff --git a/app/views/super_admin/modules.py b/app/views/super_admin/modules.py
--- a/app/views/super_admin/modules.py
+++ b/app/views/super_admin/modules.py
@@ -1,6 +1,7 @@
 from flask import Blueprint
 from flask import render_template
 from flask import request
+from flask import flash
 
 from app.helpers.data import save_to_db
 from app.helpers.data_getter import DataGetter
@@ -22,11 +23,13 @@ def index_view():
         if not module:
             module = Module()
             save_to_db(module)
+            flash("Changes have been saved.")
     elif request.method == 'POST':
         form = request.form
         module.ticket_include = True if form.get('ticketing') == 'on' else False
         module.payment_include = True if form.get('payments') == 'on' else False
         module.donation_include = True if form.get('donations') == 'on' else False
         save_to_db(module)
+        flash("Changes have been saved.")
 
     return render_template('gentelella/admin/super_admin/modules/modules.html', module=module,navigation_bar=list_navbar())


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

Issue:
Remove discount code related sections from admin/sales, also rename fees status to Invoices.
Follow up from #2919. The relevant code should commented out


Discussion:

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
@@ -220,10 +220,10 @@ def sales_by_marketer_view(by_discount_code=False):
                            navigation_bar=list_navbar())
 
 
-@sadmin_sales.route('/discount_code/')
+'''@sadmin_sales.route('/discount_code/')
 def sales_by_discount_code_view():
     return sales_by_marketer_view(True)
-
+'''
 
 @sadmin_sales.route('/<path>/')
 def sales_by_events_view(path):
@@ -372,7 +372,7 @@ def sales_by_events_view(path):
     else:
         abort(404)
 
-
+'''
 @sadmin_sales.route('/discounts/', methods=('GET',))
 def discount_codes_view():
     discount_codes = InvoicingManager.get_discount_codes()
@@ -447,3 +447,4 @@ def discount_codes_delete(discount_code_id=None):
     delete_from_db(discount_code, "Discount code deleted")
     flash("The discount code has been deleted.", "warning")
     return redirect(url_for('.discount_codes_view'))
+'''


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

Issue:
Adding user image to profile and saving it results in error page
After user uploads an image to the profile page and updates/saves the profile an error page shows up.

![screenshot from 2016-12-31 15-36-41](https://cloud.githubusercontent.com/assets/1583873/21577975/160aba80-cf6f-11e6-999a-d42a21e9561b.png)



Discussion:
@mariobehling @SaptakS I amn't facing any issue on my computer , but this problem persists on http://open-event-dev.herokuapp.com and eventyay
@SaptakS Any updates?

This issue doesn't come up in local system. However occurs in deployments. I did check in heroku which gave a R14 memory error. Will check for kubernetes. Problem is since I cant recreate in local system its a little difficult. I will try to solve this issue by tomorrow.
@mariobehling figured out the issue why it works properly in local system but not in deployments. The problem is in local system, the absolute path of the image returned is correct however in deployment we use AWS which now due to some reason returns a wrong path. I will get this fixed by today. :)

Resolving patch:
diff --git a/app/views/users/profile.py b/app/views/users/profile.py
--- a/app/views/users/profile.py
+++ b/app/views/users/profile.py
@@ -11,7 +11,7 @@
 from app.helpers.data_getter import DataGetter
 from app.helpers.helpers import uploaded_file
 from app.helpers.oauth import FbOAuth, InstagramOAuth, OAuth
-from app.helpers.storage import upload, UPLOAD_PATHS
+from app.helpers.storage import upload, UPLOAD_PATHS, upload_local
 
 profile = Blueprint('profile', __name__, url_prefix='/profile')
 
@@ -89,7 +89,7 @@ def create_event_bgimage_upload():
         background_image = request.form['bgimage']
         if background_image:
             background_file = uploaded_file(file_content=background_image)
-            background_url = upload(
+            background_url = upload_local(
                 background_file,
                 UPLOAD_PATHS['temp']['event'].format(uuid=uuid4())
             )


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

Issue:
Discount shown in Event Guest Page is wrong.
The total and the discount seem to be exchanged in the event guest page. 


Discussion:
I'll 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
@@ -46,6 +46,7 @@ def apply_promo():
             'discount_amount': discount.value,
             'discount_status': True,
             'access_status': True,
+            'access_code_ticket': access_code.tickets,
         })
     elif discount:
         return jsonify({
@@ -58,6 +59,7 @@ def apply_promo():
         return jsonify({
             'access_status': True,
             'discount_status': False,
+            'access_code_ticket': access_code.tickets,
         })
     else:
         return jsonify({


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

Issue:
Email Update option no longer available
The options to subscribe/unsubscribe to email updates from events are no longer available.

Please make a list of updates and enable them again.

These were solved here https://github.com/fossasia/open-event-orga-server/issues/1179 and here https://github.com/fossasia/open-event-orga-server/issues/1236

![screenshot from 2016-12-31 16-17-32](https://cloud.githubusercontent.com/assets/1583873/21578114/cce33764-cf74-11e6-8d97-70f978e1fc3f.png)



Discussion:
I'll try working on this @mariobehling @niranjan94 @SaptakS 
@mariobehling @niranjan94 @SaptakS I dont find this bug on my pc.
![screenshot from 2017-01-05 21-43-38](https://cloud.githubusercontent.com/assets/15216503/21687620/0ad604b0-d390-11e6-8837-d640f5baf0a4.png)

@nikhilrayaprolu try these. Let's see if the bug comes up in any of this.
1. Import an event and check
2. Create two users A & B. Create an event from user A. Add user B as a speaker in that event. Now check the email settings in User B.
@nikhilrayaprolu were you able to reproduce this with what I have said above ?
Bug is still vaild on eventyay. Please see below. There are no options to switch on or off anything.

![screenshot from 2017-01-12 21-01-00](https://cloud.githubusercontent.com/assets/1583873/21906136/5630d03c-d90a-11e6-8280-8a547f2c9e48.png)


Resolving patch:
diff --git a/populate_db.py b/populate_db.py
--- a/populate_db.py
+++ b/populate_db.py
@@ -2,6 +2,10 @@
 from app.models import db
 from app.helpers.data import get_or_create  # , save_to_db
 
+#Admin message settings
+from app.helpers.system_mails import MAILS
+from app.models.message_settings import MessageSettings
+
 # Event Role-Service Permissions
 from app.models.role import Role
 from app.models.service import Service
@@ -127,6 +131,26 @@ def create_user_permissions():
     db.session.add(user_perm)
 
 
+def create_admin_message_settings():
+    default_mails = ["Next Event",
+                     "Session Schedule Change",
+                     "User email",
+                     "Invitation For Papers",
+                     "After Event",
+                     "Ticket(s) Purchased",
+                     "Session Accept or Reject",
+                     "Event Published",
+                     "Event Export Failed",
+                     "Event Exported",
+                     "Event Role Invitation",
+                     "New Session Proposal"]
+    for mail in MAILS:
+        if mail in default_mails:
+            get_or_create(MessageSettings, action=mail, mail_status=1, notif_status=1, user_control_status=1)
+        else:
+            get_or_create(MessageSettings, action=mail, mail_status=0, notif_status=0, user_control_status=0)
+
+
 def populate():
     """
     Create defined Roles, Services and Permissions.
@@ -144,6 +168,8 @@ def populate():
     create_panel_permissions()
     print 'Creating user permissions...'
     create_user_permissions()
+    print 'Creating admin message settings...'
+    create_admin_message_settings()
 
     db.session.commit()
 


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

Issue:
Reset a lost password function doesn't work
Hi, I tried to reset my password for the registered account. Nothing happened. I did not receive any email, also not in my spam folder. I got this screen after submitted my email in the form 

![screenshot from 2017-01-18 18 31 45](https://cloud.githubusercontent.com/assets/1658742/22082766/5eeba616-ddc9-11e6-95c5-f24c1add9c57.png)



Discussion:

Resolving patch:
diff --git a/app/__init__.py b/app/__init__.py
--- a/app/__init__.py
+++ b/app/__init__.py
@@ -415,7 +415,7 @@ def as_timezone(dt, tzname):
     """Accepts a Time aware Datetime object and a Timezone name.
         Returns Converted Timezone aware Datetime Object.
         """
-    if tzname:
+    if timezone(tzname):
         return dt.astimezone(timezone(tzname))
     return dt
 
diff --git a/app/views/home.py b/app/views/home.py
--- a/app/views/home.py
+++ b/app/views/home.py
@@ -177,7 +177,6 @@ def password_reset_view():
         user = DataGetter.get_user_by_email(email)
         if user:
             link = request.host + url_for(".change_password_view", hash=user.reset_password)
-            return link
             send_email_with_reset_password_hash(email, link)
             flash('Please go to the link sent to your email to reset your password')
         return redirect(url_for('.login_view'))


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

Issue:
No access to sales tab
Cannot access sales tab as an admin.

![screenshot from 2017-01-18 21-57-35](https://cloud.githubusercontent.com/assets/1583873/22082724/326f5f42-ddc9-11e6-9e30-c85a46fb12c5.png)



Discussion:

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
@@ -1,3 +1,5 @@
+# encoding=utf8
+
 import copy
 from datetime import datetime, timedelta
 
@@ -326,7 +328,7 @@ def sales_by_events_view(path):
                 += order_ticket.quantity
             tickets_summary_organizer_wise[str(order.event.creator_id)][str(order.status)]['tickets_count'] \
                 += order_ticket.quantity
-            tickets_summary_location_wise[str(order
+            tickets_summary_location_wise[unicode(order
                                               .event.searchable_location_name)][str(order
                                                                                     .status)]['tickets_count'] \
                 += order_ticket.quantity


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

Issue:
Discount in the public event page gets applied to all tickets.
Discount in the public event page gets applied to all tickets instead of getting applied to only those tickets which are applicable for the discount.


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
@@ -47,6 +47,7 @@ def apply_promo():
             'discount_status': True,
             'access_status': True,
             'access_code_ticket': access_code.tickets,
+            'discount_code_ticket': discount.tickets,
         })
     elif discount:
         return jsonify({
@@ -54,6 +55,7 @@ def apply_promo():
             'discount_amount': discount.value,
             'discount_status': True,
             'access_status': False,
+            'discount_code_ticket': discount.tickets,
         })
     elif access_code:
         return jsonify({


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

Issue:
Cannot save changes in profile
Trying to save any changes in the profile result in an error page.

![screenshot from 2017-01-10 06-25-43](https://cloud.githubusercontent.com/assets/1583873/21794781/ba2e31ba-d6fd-11e6-866c-38778ff3b878.png)



Discussion:
I will have a look at it. 
This issue is not entirely solved. The fix still has issues:
When the user uploads a photo and saves it, any text that is in the "description" is deleted. On the other hand if the user goes to another page and returns to the profile and then changes anything in the "description" field the images disappears after the change is "Updated".

Expected: Image and test should be saved.
@mariobehling checking

Resolving patch:
diff --git a/app/helpers/data.py b/app/helpers/data.py
--- a/app/helpers/data.py
+++ b/app/helpers/data.py
@@ -728,11 +728,11 @@ def update_user(form, user_id, contacts_only_update=False):
 
             user_detail.details = form['details']
             avatar_img = form.get('avatar-img', None)
-            user_detail.avatar_uploaded = ""
-            user_detail.thumbnail = ""
-            user_detail.small = ""
-            user_detail.icon = ""
-            if string_not_empty(avatar_img) and avatar_img:
+            if string_not_empty(avatar_img) and avatar_img:                
+                user_detail.avatar_uploaded = ""
+                user_detail.thumbnail = ""
+                user_detail.small = ""
+                user_detail.icon = ""
                 filename = '{}.png'.format(time.time())
                 filepath = '{}/static/{}'.format(path.realpath('.'),
                                                  avatar_img[len('/serve_static/'):])


Test patch: