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

Issue:
Add to super admin settings field with email
Email field is neccessary to define, because we don't won't to hardcode email in code



Discussion:
I would like to take a stab at the issue.

@souravsingh awesome. Go ahead.

@souravsingh are you working on the project as a part of [code heat](http://codeheat.org) ? 

@niranjan94 I  am not doing the project as part of code heat. I just want to contribute to FOSSASIA.

@souravsingh are you still working on this issue ? If not, let me know so that I can assign this to someone else 


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
@@ -56,6 +56,15 @@
 
 
 class DataGetter(object):
+
+    @staticmethod
+    def get_super_admin_user():
+        return User.query\
+            .filter_by(is_super_admin=True)\
+            .filter_by(is_admin=True)\
+            .filter_by(is_verified=True)\
+            .order_by(asc(User.id)).first()
+
     @staticmethod
     def get_all_user_notifications(user):
         return Notification.query.filter_by(user=user).all()
diff --git a/app/helpers/helpers.py b/app/helpers/helpers.py
--- a/app/helpers/helpers.py
+++ b/app/helpers/helpers.py
@@ -684,9 +684,9 @@ def update_state(task_handle, state, result=None):
         )
 
 
-def uploaded_file(extention='.png', file_content=None):
-    filename = str(time.time()) + extention
-    file_path = os.path.realpath('.') + '/static/temp/' + filename
+def uploaded_file(extension='.png', file_content=None):
+    filename = str(time.time()) + extension
+    file_path = current_app.config.get('BASE_DIR') + '/static/temp/' + filename
     file = open(file_path, "wb")
     file.write(file_content.split(",")[1].decode('base64'))
     file.close()
diff --git a/app/views/admin/super_admin/dep_settings.py b/app/views/admin/super_admin/dep_settings.py
--- a/app/views/admin/super_admin/dep_settings.py
+++ b/app/views/admin/super_admin/dep_settings.py
@@ -16,6 +16,10 @@ class SuperAdminSettingsView(SuperAdminBaseView):
     @expose('/', methods=('GET', 'POST'))
     def index_view(self):
         if request.method == 'POST':
+            if 'super_admin_email' in request.form:
+                super_admin = DataGetter.get_super_admin_user()
+                super_admin.email = request.form['super_admin_email']
+                save_to_db(super_admin)
             if 'event-thumbnail_width' in request.form:
                 im_size_profile = DataGetter.get_image_sizes_by_type(type='profile')
                 im_size_event = DataGetter.get_image_sizes_by_type(type='event')
@@ -114,6 +118,7 @@ def index_view(self):
             payment_currencies=DataGetter.get_payment_currencies(),
             included_settings=event_view.get_module_settings(),
             image_config=image_config,
+            super_admin_email=DataGetter.get_super_admin_user().email,
             event_image_sizes=event_image_sizes,
             profile_image_sizes=profile_image_sizes
         )


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

Issue:
Only the first confirmation email can verify user
Version: 84a0a7d

The link in the resend confirmation email isn't same as the first confirmation email.

Test case,
1. Create a new user, without verifying this account.
2. As this unverified new user, go to `Manage Events` page, and resend the confirmation.
3. Check email again. Now try verify the account with the latest confirmation email.

As a result, I get a 404 page.



Discussion:
After looking into the code, I find out there is a bigger security problem. 

First confirmation email can 'always' verify user, because it uses the plain password.
The resend confirmation email may fail, if the encrypted contain '/'.


Resolving patch:
diff --git a/app/views/admin/home.py b/app/views/admin/home.py
--- a/app/views/admin/home.py
+++ b/app/views/admin/home.py
@@ -2,6 +2,8 @@
 import logging
 import os
 import urllib
+import string
+import random
 from urllib2 import urlopen
 
 from flask import url_for, redirect, request, session, flash
@@ -36,6 +38,8 @@ def record_user_login_logout(template, user):
         **req_stats
     )
 
+def str_generator(size=6, chars=string.ascii_uppercase + string.digits):
+    return ''.join(random.choice(chars) for _ in range(size))
 
 class MyHomeView(AdminIndexView):
     @expose('/')
@@ -98,7 +102,7 @@ def register_view(self):
             s = get_serializer()
             data = [request.form['email'], request.form['password']]
             user = DataManager.create_user(data)
-            form_hash = s.dumps(data)
+            form_hash = s.dumps([request.form['email'], str_generator()])
             link = url_for('.create_account_after_confirmation_view', hash=form_hash, _external=True)
             send_email_confirmation(request.form, link)
             login.login_user(user)
@@ -238,7 +242,7 @@ def check_duplicate_email(self):
     def resend_email_confirmation(self):
         user = DataGetter.get_user(login.current_user.id)
         s = get_serializer()
-        data = [user.email, user.password]
+        data = [user.email, str_generator()]
         form_hash = s.dumps(data)
         link = url_for('.create_account_after_confirmation_view', hash=form_hash, _external=True)
         form = {"email": user.email, "password": user.password}


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

Issue:
Call For Speaker Events in Home Page are wrong.
In home page, only the starting date of call for speakers is checked irrespective of the end date. So even if call for speakers is closed, it is shown.

http://open-event-dev.herokuapp.com/e/0e5d7295/cfs/



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
@@ -464,14 +464,18 @@ def get_call_for_speakers_events(include_private=False):
         if include_private:
             events = DataGetter.get_all_published_events(include_private)
             for e in events:
-                call_for_speakers = DataGetter.get_call_for_papers(e.id).first()
+                call_for_speakers = CallForPaper.query.filter_by(event_id=e.id)\
+                                    .filter(CallForPaper.start_date <= datetime.datetime.now())\
+                                    .filter(CallForPaper.end_date >= datetime.datetime.now()).first()
                 if call_for_speakers and not e.in_trash:
                     results.append(e)
 
         else:
             events = DataGetter.get_all_published_events()
             for e in events:
-                call_for_speakers = DataGetter.get_call_for_papers(e.id).first()
+                call_for_speakers = CallForPaper.query.filter_by(event_id=e.id)\
+                                    .filter(CallForPaper.start_date <= datetime.datetime.now())\
+                                    .filter(CallForPaper.end_date >= datetime.datetime.now()).first()
                 if call_for_speakers and not e.in_trash:
                     results.append(e)
         return results[:12]


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

Issue:
Bug: Kubernetes Deployment Info shown on heroku
Do not try to show Kubernetes deployment info when not hosted on Kubernetes


Discussion:

Resolving patch:
diff --git a/app/views/admin/super_admin/super_admin.py b/app/views/admin/super_admin/super_admin.py
--- a/app/views/admin/super_admin/super_admin.py
+++ b/app/views/admin/super_admin/super_admin.py
@@ -53,7 +53,7 @@ def index_view(self):
                            events=events,
                            version=version,
                            commit_info=commit_info,
-                           on_kubernetes=True,
+                           on_kubernetes=on_kubernetes,
                            pods_info=pods_info,
                            number_live_events=number_live_events,
                            number_draft_events=number_draft_events,


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

Issue:
Account data changed when user buys several tickets
Description:

I added information to get tickets for an event. Both tickets had another name and email (not the account email). I got the tickets, but at the end my account name changed to the second's ticket name.

Expected:

There should not be any change in the account data.

![screenshot from 2016-11-12 13 57 06](https://cloud.githubusercontent.com/assets/1583873/20236024/2606ec70-a8e0-11e6-84b2-738ae91647aa.png)


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
@@ -184,10 +184,8 @@ def get_or_create_user_by_email(email, data=None):
                 'email': email,
                 'password': password
             })
-        if user.user_detail:
-            user.user_detail.firstname = data['firstname']
-            user.user_detail.lastname = data['lastname']
-        else:
+
+        if not user.user_detail:
             user_detail = UserDetail(firstname=data['firstname'], lastname=data['lastname'])
             user.user_detail = user_detail
 


Test patch:
diff --git a/tests/unittests/views/guest/test_ticketing.py b/tests/unittests/views/guest/test_ticketing.py
--- a/tests/unittests/views/guest/test_ticketing.py
+++ b/tests/unittests/views/guest/test_ticketing.py
@@ -119,7 +119,7 @@ def test_order_payment_stripe(self):
             save_to_db(order)
             response = self.app.get(url_for('ticketing.view_order_after_payment', order_identifier=identifier),
                                     follow_redirects=True)
-            self.assertTrue("John" in response.data, msg=response.data)
+            self.assertTrue("Your Order" in response.data, msg=response.data)
             self.assertTrue("ACME Lane" in response.data, msg=response.data)
             self.assertTrue("1234" in response.data, msg=response.data)
             self.assertTrue(str(event.name) in response.data, msg=response.data)
@@ -161,7 +161,6 @@ def test_order_payment_paypal(self):
             save_to_db(order)
             response = self.app.get(url_for('ticketing.view_order_after_payment', order_identifier=identifier),
                                     follow_redirects=True)
-            self.assertTrue("John" in response.data, msg=response.data)
             self.assertTrue("ACME Lane" in response.data, msg=response.data)
             self.assertTrue("87906533255" in response.data, msg=response.data)
             self.assertTrue(str(event.name) in response.data, msg=response.data)
Repository: fossasia/open-event-server

Issue:
Organizer Profile: Improve design of Social Links
Currently the social links on the organizer profile are simply added as text in the form (e.g. http://open-event-dev.herokuapp.com/profile/).

The domain should not be a part of the form though. Please see example below.

![screenshot from 2016-11-20 05-26-04](https://cloud.githubusercontent.com/assets/1583873/20460420/0e4d3276-aee2-11e6-883e-6350a0bc8969.png)



Discussion:

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


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

Issue:
Import not working on Kubernetes deployment
The file upload for import is not working on Kubernetes deployment. (but works locally and on heroku)




Discussion:
**Reason:**
Celery and gunicorn are running in two separate containers. The file upload is stored on a temporarily folder inside gunicorn's container. That folder is obviously not accessible from the celery container.

**Solution:**
Setup a persistent store that can be simultaneously accessed by multiple pods. Hence, we need to use an NFS persistent store.
Will this solution still enable us to scale up and down containers and resources required.. depending on the number of users etc?
@mariobehling yes. The persistent store will also be scalable. 

Resolving patch:
diff --git a/app/helpers/storage.py b/app/helpers/storage.py
--- a/app/helpers/storage.py
+++ b/app/helpers/storage.py
@@ -199,7 +199,7 @@ def upload_to_gs(bucket_name, client_id, client_secret, file, key, acl='public-r
     k.set_acl(acl)
     gs_url = 'https://storage.googleapis.com/%s/' % bucket_name
     if sent == size:
-        return gs_url + key
+        return gs_url + k.key
     return False
 
 # ########


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

Issue:
Login page still shows login page when logged in
![http://i.imgur.com/94Ys2CK.png](http://i.imgur.com/94Ys2CK.png)

When logged in, you can still access the [login page](http://open-event-dev.herokuapp.com/login/) which feels odd.

It's probably better to redirect people to [/profile](http://open-event-dev.herokuapp.com/profile/) or a different page when they are logged in.

Steps to Reproduce
* Logged in with Google
* Visit http://open-event-dev.herokuapp.com/login


Discussion:

Resolving patch:
diff --git a/app/views/admin/home.py b/app/views/admin/home.py
--- a/app/views/admin/home.py
+++ b/app/views/admin/home.py
@@ -23,7 +23,6 @@
 from app.models.user import User
 import geoip2.database
 from flask import abort
-from werkzeug.datastructures import ImmutableMultiDict
 
 
 def intended_url():
@@ -38,9 +37,11 @@ def record_user_login_logout(template, user):
         **req_stats
     )
 
+
 def str_generator(size=6, chars=string.ascii_uppercase + string.digits):
     return ''.join(random.choice(chars) for _ in range(size))
 
+
 class MyHomeView(AdminIndexView):
     @expose('/')
     def index(self):
@@ -62,6 +63,10 @@ def index(self):
 
     @expose('/login/', methods=('GET', 'POST'))
     def login_view(self):
+
+        if login.current_user.is_authenticated:
+            return redirect(url_for('.index'))
+
         if request.method == 'GET':
             google = get_google_auth()
             auth_url, state = google.authorization_url(OAuth.get_auth_uri(), access_type='offline')
@@ -94,6 +99,10 @@ def login_view(self):
 
     @expose('/register/', methods=('GET', 'POST'))
     def register_view(self):
+
+        if login.current_user.is_authenticated:
+            return redirect(url_for('.index'))
+
         """Register view page"""
         if request.method == 'GET':
             return self.render('/gentelella/admin/login/register.html')


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

Issue:
Create Sessions from event dashboard gives error if user is not admin
If the logged in user is not an admin or staff of the server, there are certain checks in the permission decorators which gives 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
@@ -110,7 +110,7 @@ def decorated_function(*args, **kwargs):
         url = request.url
         if user.is_staff:
             return f(*args, **kwargs)
-        if 'events/' + event_id + '/' in url:
+        if 'events/' + str(event_id) + '/' in url:
             if user.has_role(event_id):
                 return f(*args, **kwargs)
             abort(403)
@@ -134,7 +134,7 @@ def decorated_function(*args, **kwargs):
                     return f(*args, **kwargs)
             abort(403)
         if '/edit/' in url:
-            if 'events/' + event_id + '/edit/' in url:
+            if 'events/' + str(event_id) + '/edit/' in url:
                 if user.is_organizer(event_id) or user.is_coorganizer(
                         event_id):
                     return f(*args, **kwargs)
@@ -155,11 +155,11 @@ def decorated_function(*args, **kwargs):
                     return f(*args, **kwargs)
             abort(403)
         if '/delete/' in url or '/trash/' in url:
-            if 'events/' + event_id + '/delete/' in url:
+            if 'events/' + str(event_id) + '/delete/' in url:
                 if user.is_organizer(event_id) or user.is_coorganizer(
                         event_id):
                     return f(*args, **kwargs)
-            if 'events/' + event_id + '/trash/' in url:
+            if 'events/' + str(event_id) + '/trash/' in url:
                 if user.is_organizer(event_id) or user.is_coorganizer(
                         event_id):
                     return f(*args, **kwargs)


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

Issue:
Language Box on Footer behaves improperly
The language box on the Footer doesn't shows any language selected by default and this is something not suitable in my eyes as far as UX is concerned. 
When I click on the dropdown/dropup box on my device (case iPad) I Can find English, while English is already default on site (but not default on the box).
![img_1432](https://cloud.githubusercontent.com/assets/16618931/20753945/b9708c58-b72e-11e6-9275-c29edde376f2.JPG)
![img_1433](https://cloud.githubusercontent.com/assets/16618931/20753946/b9f53c28-b72e-11e6-9266-57658f44f562.JPG)

Also when I select other language (German) only few parts on the navigation section is translated to German, while many parts remain non-translated.

![img_1434](https://cloud.githubusercontent.com/assets/16618931/20754086/45d4c8ee-b72f-11e6-940d-da523c2443ac.JPG)

Is this default language issue for the box at Footer only on small devices? I guess no, it could also be for PCs. #GCI16

Thanks.



Discussion:

Resolving patch:
diff --git a/config.py b/config.py
--- a/config.py
+++ b/config.py
@@ -6,7 +6,9 @@
 # available languages
 LANGUAGES = {
     'en': 'English',
-    'de': 'German'
+    'de': 'German',
+    'id': 'Indonesian',
+    'pl': 'Polish',
 }
 
 


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

Issue:
In event dashboard sponsor images are not scaled properly
Please show sponsor logos in correct ratio.

![screenshot from 2016-12-06 15-48-39](https://cloud.githubusercontent.com/assets/1583873/20918844/8ec9b51e-bbcb-11e6-92f6-48fb94286a13.png)



Discussion:

Resolving patch:
diff --git a/app/views/__init__.py b/app/views/__init__.py
--- a/app/views/__init__.py
+++ b/app/views/__init__.py
@@ -35,6 +35,7 @@
 from app.views.users.sessions import event_sessions
 from app.views.users.speakers import event_speakers
 from app.views.users.ticket_sales import event_ticket_sales
+from app.views.users.sponsors import event_sponsors
 from app.views.utils_routes import utils_routes
 
 
@@ -70,6 +71,7 @@ def register(app):
         app.register_blueprint(event_roles)
         app.register_blueprint(event_invites)
         app.register_blueprint(event_ticket_sales)
+        app.register_blueprint(event_sponsors)
 
         app.register_blueprint(my_tickets)
         app.register_blueprint(my_sessions)
@@ -97,6 +99,7 @@ def register(app):
 @event_export.before_request
 @events.before_request
 @event_roles.before_request
+@event_sponsors.before_request
 @event_invites.before_request
 @event_ticket_sales.before_request
 @my_tickets.before_request
diff --git a/app/views/users/events.py b/app/views/users/events.py
--- a/app/views/users/events.py
+++ b/app/views/users/events.py
@@ -10,7 +10,6 @@
 from flask.ext.login import current_user
 from flask.ext.restplus import abort
 from geoip import geolite2
-from werkzeug.datastructures import ImmutableMultiDict
 
 from app import db
 from app.helpers.auth import AuthManager
diff --git a/app/views/users/sponsors.py b/app/views/users/sponsors.py
new file mode 100644
--- /dev/null
+++ b/app/views/users/sponsors.py
@@ -0,0 +1,16 @@
+from flask import Blueprint
+from flask import url_for, redirect
+
+from app.helpers.data import delete_from_db
+from app.helpers.data_getter import DataGetter
+from app.helpers.permission_decorators import *
+
+event_sponsors = Blueprint('event_sponsors', __name__, url_prefix='/events/<int:event_id>/sponsors')
+
+
+@event_sponsors.route('/<sponsor_id>/delete/', methods=('GET',))
+@can_access
+def delete_view(event_id, sponsor_id):
+    sponsor = DataGetter.get_sponsor(sponsor_id)
+    delete_from_db(sponsor, "Sponsor deleted")
+    return redirect(url_for('events.details_view', event_id=event_id))


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

Issue:
Public Event Page: Speakers not showing up after import
I imported the 2016 FOSSASIA event to eventyay. After the import the speaker images do not show up and the heading of the speakers section has layout issues. Test site at https://eventyay.com/e/18252ab6/

Expected behavior: Import speaker images and show heading on a separate line.

![screenshot from 2016-12-06 15-17-28](https://cloud.githubusercontent.com/assets/1583873/20918019/89d451b2-bbc7-11e6-9445-719be4830e6d.png)



Discussion:

Resolving patch:
diff --git a/app/__init__.py b/app/__init__.py
--- a/app/__init__.py
+++ b/app/__init__.py
@@ -2,6 +2,7 @@
 import warnings
 
 from flask.exthook import ExtDeprecationWarning
+
 warnings.simplefilter('ignore', ExtDeprecationWarning)
 # Keep it before flask extensions are imported
 
@@ -71,6 +72,25 @@
 app = Flask(__name__)
 
 
+class ReverseProxied(object):
+    """
+    ReverseProxied flask wsgi app wrapper from http://stackoverflow.com/a/37842465/1562480 by aldel
+    """
+    def __init__(self, app):
+        self.app = app
+
+    def __call__(self, environ, start_response):
+        scheme = environ.get('HTTP_X_FORWARDED_PROTO')
+        if scheme:
+            environ['wsgi.url_scheme'] = scheme
+        if os.getenv('FORCE_SSL', 'no') == 'yes':
+            environ['wsgi.url_scheme'] = 'https'
+        return self.app(environ, start_response)
+
+
+app.wsgi_app = ReverseProxied(app.wsgi_app)
+
+
 def create_app():
     babel.init_app(app)
     BlueprintsManager.register(app)


Test patch: