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

Issue:
Fix tab names in My Session
![screenshot from 2016-06-28 00 06 02](https://cloud.githubusercontent.com/assets/9530293/16391338/4b28e266-3cc4-11e6-95d3-aa258fbc11ec.png)

Tabs are wrongly named as `Upcoming Events` instead of `Upcoming Sessions`. Also, both tabs have same name.



Discussion:

Resolving patch:
diff --git a/open_event/views/admin/models_views/my_sessions.py b/open_event/views/admin/models_views/my_sessions.py
--- a/open_event/views/admin/models_views/my_sessions.py
+++ b/open_event/views/admin/models_views/my_sessions.py
@@ -15,8 +15,8 @@ class MySessionView(BaseView):
     def display_my_sessions_view(self):
         upcoming_events_sessions = DataGetter.get_sessions_of_user(upcoming_events=True)
         past_events_sessions = DataGetter.get_sessions_of_user(upcoming_events=False)
-        page_content = {"tab_upcoming_events": "Upcoming Events",
-                        "tab_past_events": "Upcoming Events",
+        page_content = {"tab_upcoming_events": "Upcoming Sessions",
+                        "tab_past_events": "Past Sessions",
                         "title": "My Session Proposals"}
         return self.render('/gentelella/admin/mysessions/mysessions_list.html',
                            upcoming_events_sessions=upcoming_events_sessions, past_events_sessions=past_events_sessions,


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

Issue:
Create and adapt robots.txt according to site and user policy
A robots.txt has to be served at `/robots.txt` to control search-engine crawler behaviour. (As said here #849)

_(For example) unlisted/private events should not come up on search listings_



Discussion:
I was looking on the [robots.txt spec](http://www.robotstxt.org/robotstxt.html) today and realize that a better way to prevent crawling of private events will be to add permissions check to events display page which will not allow other users entry (401 UNAUTHORIZED) if event is private. Ofcourse it will work for bots too. 

If we want to use robots.txt to prevent unlisted events from being crawled, we will have to update robots.txt file with every event create and edit. I think this is not a good solution and probably enterprises don't do this. Not to mention, the robots.txt file will become gigantic. 

We can use robots.txt to mask other things like `/static/media/` folder (uploads storage directory) to prevent direct links of files from showing up in search. 

@niranjan94 @mariobehling views ?

I think the option "Private page: do not list this event publicly" just means it is accessible to anyone who has the link but not listed on search engines and our internal search.

The question about the robots.txt is also, if there can be a number of robots.txt to keep the size down. Actually if an event is not listed in the sitemap.xml and is not linked on any public search from us, it should not be possible that a search engine finds it.

So, apart from the robots.txt, please also think about the implementation of a sitemap.xml and possibly open an issue for it.


Resolving patch:
diff --git a/open_event/views/api_v1_views.py b/open_event/views/api_v1_views.py
--- a/open_event/views/api_v1_views.py
+++ b/open_event/views/api_v1_views.py
@@ -2,7 +2,8 @@
 import os
 from urllib2 import urlopen
 
-from flask import jsonify, url_for, redirect, request, send_from_directory
+from flask import jsonify, url_for, redirect, request, send_from_directory, \
+    render_template, make_response
 from flask.ext.cors import cross_origin
 from flask.ext import login
 from flask.ext.migrate import upgrade
@@ -495,3 +496,10 @@ def run_migrations():
 
 def intended_url():
     return request.args.get('next') or url_for('admin.index')
+
+
+@app.route('/robots.txt', methods=('GET', 'POST'))
+def robots_txt():
+    resp = make_response(render_template('robots.txt'))
+    resp.headers['Content-type'] = 'text/plain'
+    return resp


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

Issue:
Fix tab names in My Session
![screenshot from 2016-06-28 00 06 02](https://cloud.githubusercontent.com/assets/9530293/16391338/4b28e266-3cc4-11e6-95d3-aa258fbc11ec.png)

Tabs are wrongly named as `Upcoming Events` instead of `Upcoming Sessions`. Also, both tabs have same name.



Discussion:
Well, it is not just a different name. The pages should show what they say "upcoming sessions" and "past sessions". The functions does not work simply by renaming the menu tab item. Please look more into details of things and test with more thoughts.

@mariobehling will check that out.


Resolving patch:
diff --git a/open_event/helpers/data_getter.py b/open_event/helpers/data_getter.py
--- a/open_event/helpers/data_getter.py
+++ b/open_event/helpers/data_getter.py
@@ -178,10 +178,10 @@ def get_sessions_of_user(upcoming_events=True):
         """
         if upcoming_events:
             return Session.query.filter(Session.speakers.any(Speaker.user_id == login.current_user.id)).filter(
-                Event.state != 'Completed')
+                Session.start_time >= datetime.datetime.now())
         else:
             return Session.query.filter(Session.speakers.any(Speaker.user_id == login.current_user.id)).filter(
-                Event.state == 'Completed')
+                Session.start_time < datetime.datetime.now())
 
     @staticmethod
     def get_all_sessions_of_user(upcoming_events=True):


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

Issue:
Wizard Create Event Step 1: Implement Upload form for Event Logo
Please implement an upload form for a logo on the event wizard step 1. Do we need the logo to be in a specific shape? If yes, please implement a crop option.



Discussion:

Resolving patch:
diff --git a/open_event/helpers/data.py b/open_event/helpers/data.py
--- a/open_event/helpers/data.py
+++ b/open_event/helpers/data.py
@@ -773,7 +773,6 @@ def create_event(form, img_files):
         event = Event(name=form['name'],
                       email=form.get('email', u'test@example.com'),
                       color=form.get('color', u'black'),
-                      logo=form['logo'],
                       start_time=datetime.strptime(form['start_date'] + ' ' + form['start_time'], '%m/%d/%Y %H:%M'),
                       end_time=datetime.strptime(form['end_date'] + ' ' + form['end_time'], '%m/%d/%Y %H:%M'),
                       timezone=form['timezone'],
@@ -837,6 +836,17 @@ def create_event(form, img_files):
                 background_url = upload(background_file, 'events/%d/background_image' % (int(event.id)))
                 event.background_url = background_url
 
+            logo = form['logo']
+            if string_not_empty(logo):
+                filename = str(time.time()) + '.png'
+                file_path = os.path.realpath('.') + '/static/temp/' + filename
+                fh = open(file_path, "wb")
+                fh.write(logo.split(",")[1].decode('base64'))
+                fh.close()
+                logo_file = UploadedFile(file_path, filename)
+                logo = upload(logo_file, 'events/%d/logo' % (int(event.id)))
+                event.logo = logo
+
             for index, name in enumerate(session_type_names):
                 if not string_empty(name):
                     session_type = SessionType(name=name, length=session_type_length[index], event_id=event.id)
@@ -937,6 +947,17 @@ def edit_event(request, event_id, event, session_types, tracks, social_links, mi
             background_url = upload(background_file, 'events/%d/background_image' % (int(event.id)))
             event.background_url = background_url
 
+        logo = form['logo']
+        if string_not_empty(logo):
+            filename = str(time.time()) + '.png'
+            file_path = os.path.realpath('.') + '/static/temp/' + filename
+            fh = open(file_path, "wb")
+            fh.write(background_image.split(",")[1].decode('base64'))
+            fh.close()
+            logo_file = UploadedFile(file_path, filename)
+            logo = upload(logo_file, 'events/%d/logo' % (int(event.id)))
+            event.logo = logo
+
         state = form.get('state', None)
         if state and ((state == u'Published' and not string_empty(
             event.location_name)) or state != u'Published') and login.current_user.is_verified:


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

Issue:
Use secret key config (from Admin->Settings) in the application
Currently `app secret key` is being saved and loaded to the database but it is not affecting the running app "secret key" config i.e. technically it is not being used at all. 



Discussion:

Resolving patch:
diff --git a/open_event/__init__.py b/open_event/__init__.py
--- a/open_event/__init__.py
+++ b/open_event/__init__.py
@@ -35,6 +35,7 @@
 from open_event.helpers.data_getter import DataGetter
 from open_event.views.api_v1_views import app as api_v1_routes
 from open_event.views.sitemap import app as sitemap_routes
+from open_event.settings import get_settings
 import requests
 
 
@@ -208,15 +209,20 @@ def side_by_side_diff(changeset_entry):
                 side_by_side_diff=side_by_side_diff,
                 get_user_name=get_user_name)
 
+
 # http://stackoverflow.com/questions/26724623/
 @app.before_request
 def track_user():
     if current_user.is_authenticated:
         current_user.update_lat()
 
-
 current_app, manager, database, jwt = create_app()
 
 
+@app.before_first_request
+def set_secret():
+    current_app.secret_key = get_settings()['secret']
+
+
 if __name__ == '__main__':
     current_app.run()
diff --git a/open_event/settings/__init__.py b/open_event/settings/__init__.py
--- a/open_event/settings/__init__.py
+++ b/open_event/settings/__init__.py
@@ -24,6 +24,7 @@ def set_settings(**kwargs):
     setting = Setting(**kwargs)
     from open_event.helpers.data import save_to_db
     save_to_db(setting, 'Setting saved')
+    current_app.secret_key = setting.secret
     current_app.config['custom_settings'] = make_dict(setting)
 
 


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

Issue:
Category/type hashtags are not clickable 
Make the category/top hashtags under each event element in home page and search page clickable.



Discussion:

Resolving patch:
diff --git a/open_event/views/admin/home.py b/open_event/views/admin/home.py
--- a/open_event/views/admin/home.py
+++ b/open_event/views/admin/home.py
@@ -1,6 +1,7 @@
 """Copyright 2015 Rafal Kowalski"""
 import logging
 import os
+import urllib
 from urllib2 import urlopen
 
 from flask import url_for, redirect, request, session, send_from_directory
@@ -187,8 +188,5 @@ def browse_view(self):
             country = response.country.name
         except:
             country = "United States"
-        return redirect(url_for('explore.explore_view', location=slugify(country)))
-
-
-
-
+        return redirect(url_for('explore.explore_view', location=slugify(country)) + '?' +
+                        urllib.urlencode(request.args))


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

Issue:
Basic filtering and search in the Home page
_Like eventbrite_
![capture](https://cloud.githubusercontent.com/assets/2404372/16550614/42ff1e6a-41ca-11e6-81bd-38067071d497.PNG)



Discussion:

Resolving patch:
diff --git a/open_event/views/admin/home.py b/open_event/views/admin/home.py
--- a/open_event/views/admin/home.py
+++ b/open_event/views/admin/home.py
@@ -12,6 +12,7 @@
 from wtforms import ValidationError
 
 from open_event.helpers.flask_helpers import get_real_ip, slugify
+from open_event.views.public.explore import erase_from_dict
 from ...helpers.data import DataManager, save_to_db, get_google_auth, get_facebook_auth, create_user_password, \
     user_logged_in, record_activity
 from ...helpers.data_getter import DataGetter
@@ -179,14 +180,21 @@ def forbidden_view(self):
 
     @expose('/browse/', methods=('GET',))
     def browse_view(self):
-        try:
-            reader = geoip2.database.Reader(os.path.realpath('.') + '/static/data/GeoLite2-Country.mmdb')
-            ip = get_real_ip()
-            if ip == '127.0.0.1' or ip == '0.0.0.0':
-                ip = urlopen('http://ip.42.pl/raw').read()  # On local test environments
-            response = reader.country(ip)
-            country = response.country.name
-        except:
-            country = "United States"
+        if not request.args.get("location"):
+            try:
+                reader = geoip2.database.Reader(os.path.realpath('.') + '/static/data/GeoLite2-Country.mmdb')
+                ip = get_real_ip()
+                if ip == '127.0.0.1' or ip == '0.0.0.0':
+                    ip = urlopen('http://ip.42.pl/raw').read()  # On local test environments
+                response = reader.country(ip)
+                country = response.country.name
+            except:
+                country = "United States"
+        else:
+            country = request.args.get("location")
+
+        params = request.args.items()
+        erase_from_dict(params, 'location')
+        params = dict((k, v) for k, v in params if v)
         return redirect(url_for('explore.explore_view', location=slugify(country)) + '?' +
-                        urllib.urlencode(request.args))
+                        urllib.urlencode(params))


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

Issue:
Check if datetime fields exists in Event API payload before using them
Currently when string datetime's are converted to python datetime in Event API, then the keys are not being checked for existence. So if an "optional" field is missing from payload, it results in `KeyError`. 

Fixing this issue should also fix https://github.com/loklak/loklak_server/issues/642



Discussion:

Resolving patch:
diff --git a/open_event/api/events.py b/open_event/api/events.py
--- a/open_event/api/events.py
+++ b/open_event/api/events.py
@@ -70,7 +70,6 @@
 del EVENT_POST['social_links']
 
 
-
 # ###################
 # Data Access Objects
 # ###################
@@ -93,12 +92,12 @@ def fix_payload(self, data):
         Fixes the payload data.
         Here converts string time from datetime obj
         """
-        data['start_time'] = EVENT_POST['start_time'].from_str(data['start_time'])
-        data['end_time'] = EVENT_POST['end_time'].from_str(data['end_time'])
-        data['closing_datetime'] = EVENT_POST['closing_datetime'].from_str(
-            data['closing_datetime'])
-        data['schedule_published_on'] = EVENT_POST['schedule_published_on'].from_str(
-            data['schedule_published_on'])
+        datetime_fields = [
+            'start_time', 'end_time', 'closing_datetime',
+            'schedule_published_on'
+        ]
+        for i in datetime_fields:
+            data[i] = EVENT_POST[i].from_str(data.get(i))
         return data
 
     def create(self, data, url):
@@ -133,35 +132,20 @@ def update(self, event_id, data):
 # DEFINE PARAMS
 
 EVENT_PARAMS = {
-    'location': {
-        'type': str
-    },
+    'location': {},
     'contains': {
-        'description': 'Contains the string in name and description',
-        'type': str
-    },
-    'state': {
-        'type': str
-    },
-    'privacy': {
-        'type': str
-    },
-    'type': {
-        'type': str
-    },
-    'topic': {
-        'type': str
-    },
-    'sub_topic': {
-        'type': str
+        'description': 'Contains the string in name and description'
     },
+    'state': {},
+    'privacy': {},
+    'type': {},
+    'topic': {},
+    'sub_topic': {},
     'start_time_gt': {},
     'start_time_lt': {},
     'end_time_gt': {},
     'end_time_lt': {},
-    'time_period': {
-        'type': str
-    }
+    'time_period': {}
 }
 
 


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

Issue:
changing date in call for speakers is not possible 



Discussion:

Resolving patch:
diff --git a/open_event/helpers/data.py b/open_event/helpers/data.py
--- a/open_event/helpers/data.py
+++ b/open_event/helpers/data.py
@@ -1062,16 +1062,24 @@ def edit_event(request, event_id, event, session_types, tracks, social_links, mi
         update_or_create(
             CustomForms, event_id=event.id,
             session_form=session_form, speaker_form=speaker_form)
-
         if form.get('call_for_speakers_state', u'off') == u'on':
-            call_for_speakers, c = get_or_create(CallForPaper,
-                                                 announcement=form['announcement'],
-                                                 start_date=datetime.strptime(
-                                                     form['cfs_start_date'], '%m/%d/%Y'),
-                                                 end_date=datetime.strptime(
-                                                     form['cfs_end_date'], '%m/%d/%Y'),
-                                                 event_id=event.id)
-            save_to_db(call_for_speakers)
+            if call_for_papers:
+                call_for_papers.announcement = form['announcement']
+                call_for_papers.start_date = datetime.strptime(
+                                                     form['cfs_start_date'], '%m/%d/%Y')
+                call_for_papers.end_date = datetime.strptime(
+                                                     form['cfs_end_date'], '%m/%d/%Y')
+                call_for_papers.event_id = event.id
+                save_to_db(call_for_papers)
+            else:
+                call_for_speakers, c = get_or_create(CallForPaper,
+                                                     announcement=form['announcement'],
+                                                     start_date=datetime.strptime(
+                                                        form['cfs_start_date'], '%m/%d/%Y'),
+                                                     end_date=datetime.strptime(
+                                                        form['cfs_end_date'], '%m/%d/%Y'),
+                                                     event_id=event.id)
+                save_to_db(call_for_speakers)
 
         save_to_db(event, "Event saved")
         record_activity('update_event', event_id=event.id)


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

Issue:
Allow user to change his password in settings - /settings



Discussion:

Resolving patch:
diff --git a/open_event/views/admin/models_views/settings.py b/open_event/views/admin/models_views/settings.py
--- a/open_event/views/admin/models_views/settings.py
+++ b/open_event/views/admin/models_views/settings.py
@@ -1,6 +1,7 @@
 import unicodedata
-from flask import request, url_for, redirect, jsonify
+from flask import request, url_for, redirect, jsonify, flash
 from flask.ext.admin import BaseView
+from flask.ext.scrypt import generate_password_hash, generate_random_salt
 from flask_admin import expose
 from flask.ext import login
 
@@ -8,7 +9,6 @@
 from open_event.models.email_notifications import EmailNotification
 from ....helpers.data_getter import DataGetter
 
-
 def get_or_create_notification_settings(event_id):
     email_notification = DataGetter \
         .get_email_notification_settings_by_event_id(login.current_user.id, event_id)
@@ -37,14 +37,32 @@ def index_view(self):
         # TODO Settings landing page
         return redirect(url_for('.email_preferences_view'))
 
-    @expose('/email-preferences')
+    @expose('/password/', methods=('POST', 'GET'))
+    def password_view(self):
+        if request.method == 'POST':
+            user = login.current_user
+            if user.password == generate_password_hash(request.form['current_password'], user.salt):
+                if request.form['new_password'] == request.form['repeat_password']:
+                    salt = generate_random_salt()
+                    user.password = generate_password_hash(request.form['new_password'], salt)
+                    user.salt = salt
+                    save_to_db(user, "password changed")
+                    flash('Password changed successfully.', 'success')
+                else:
+                    flash('The new password and the repeat don\'t match.', 'danger')
+            else:
+                flash('The current password is incorrect.', 'danger')
+
+        return self.render('/gentelella/admin/settings/pages/password.html')
+
+    @expose('/email-preferences/')
     def email_preferences_view(self):
         events = DataGetter.get_all_events()
         settings = DataGetter.get_email_notification_settings(login.current_user.id)
         return self.render('/gentelella/admin/settings/pages/email_preferences.html',
                            settings=settings, events=events)
 
-    @expose('/email/toggle', methods=('POST',))
+    @expose('/email/toggle/', methods=('POST',))
     def email_toggle_view(self):
         if request.method == 'POST':
             name = request.form.get('name')


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

Issue:
Error while saving Email preferences
When toggling the bulk-email-update switch at `/settings/email-preferences`, an error occurs and settings are not saved.



Discussion:

Resolving patch:
diff --git a/open_event/helpers/data.py b/open_event/helpers/data.py
--- a/open_event/helpers/data.py
+++ b/open_event/helpers/data.py
@@ -161,7 +161,7 @@ def toggle_email_notification_settings(user_id, value):
                                                                        user_id=user_id,
                                                                        event_id=event.id)
                     save_to_db(new_email_notification_setting, "EmailSetting Toggled")
-                    new_email_notification_setting.append(email_notification.id)
+                    notification_ids.append(new_email_notification_setting.id)
         return notification_ids
 
     @staticmethod


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

Issue:
Copy of Event doesn't work
Saving or publishing a copy of event gives internal error.



Discussion:

Resolving patch:
diff --git a/open_event/views/admin/models_views/events.py b/open_event/views/admin/models_views/events.py
--- a/open_event/views/admin/models_views/events.py
+++ b/open_event/views/admin/models_views/events.py
@@ -321,6 +321,7 @@ def copy_event(self, event_id):
         sponsors = DataGetter.get_sponsors(event_id)
         return self.render('/gentelella/admin/event/copy/copy.html',
                            event=event,
+                           is_copy=1,
                            session_types=session_types,
                            tracks=tracks,
                            social_links=social_links,


Test patch: