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

Issue:
How do you plan to handle room assignments
The question for the rooms is essential for building the schedule. If a track is in a room, there should be an option in the UI "tick here if all tracks run in a dedicated room" or something similar.

If tracks could run across different rooms the schedule should be build according to rooms.

There also should be a wizard point "rooms" or it should appear together with "tracks". Please tell us how shdlr.com and other handle this.



Discussion:
@mariobehling shdlr.com does the scheduling only based on rooms. So, we should decide now whether we'll be going with tracks or rooms. 

Rooms seem to be the practical choice. If that's the case, switching the UI to rooms is an easy task and I'll do it.

Yes, we need to go with rooms for practical reason, but should have an option "Track = Rooms". We also need to distinguish sessions with some color.


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,7 +12,7 @@
 from ...helpers.helpers import send_email_after_account_create, send_email_with_reset_password_hash
 from open_event.models.user import User
 from open_event.helpers.oauth import OAuth, FbOAuth
-
+from flask import current_app
 
 def intended_url():
     return request.args.get('next') or url_for('.index')
@@ -47,7 +47,14 @@ def login_view(self):
                 return redirect(url_for('admin.login_view'))
             login.login_user(user)
             logging.info('logged successfully')
-            return redirect(intended_url())
+            redirect_to_intended = redirect(intended_url())
+            response = current_app.make_response(redirect_to_intended)
+
+            # TODO Remove these cookie setters once a proper token-based auth is available in the API. -@niranjan94
+            response.set_cookie('username', value=email)
+            response.set_cookie('password', value=request.form['password'])
+
+            return response
 
     @expose('/register/', methods=('GET', 'POST'))
     def register_view(self):


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

Issue:
Session POST API fails when speaker doesn't exist



Discussion:

Resolving patch:
diff --git a/open_event/api/sessions.py b/open_event/api/sessions.py
--- a/open_event/api/sessions.py
+++ b/open_event/api/sessions.py
@@ -102,6 +102,7 @@ def create(self, event_id, data):
         session = SessionModel(**data)
         session.speakers = InstrumentedList(
             SpeakerModel.query.get(_) for _ in speakers
+            if SpeakerModel.query.get(_) is not None
         )
         new_session = save_db_model(session, SessionModel.__name__, event_id)
         return self.get(event_id, new_session.id)


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

Issue:
Show login info in swagger UI
Since POST, PUT and DELETE requests work from the swagger ui using current login'd user as authorizer, it will be better if the show some info of active user in the UI. 
If no user is login'd, we can show links to register and login, and use next param in url to come back to swagger UI after either of the processes.  



Discussion:

Resolving patch:
diff --git a/open_event/api/__init__.py b/open_event/api/__init__.py
--- a/open_event/api/__init__.py
+++ b/open_event/api/__init__.py
@@ -1,5 +1,6 @@
-from flask import Blueprint
+from flask import Blueprint, render_template
 from flask.ext.restplus import Api
+from flask_login import current_user
 
 from .events import api as event_api
 from .sessions import api as session_api
@@ -15,8 +16,7 @@
 api_v2 = Blueprint('api', __name__, url_prefix='/api/v2')
 
 api = Api(api_v2, version='2.0', title='Organizer Server APIs',
-    description='Open Event Organizer APIs'
-)
+          description='Open Event Organizer APIs')
 
 api.add_namespace(event_api)
 api.add_namespace(session_api)
@@ -28,3 +28,12 @@
 api.add_namespace(format_api)
 api.add_namespace(language_api)
 api.add_namespace(login_api)
+
+
+@api.documentation
+def custom_ui():
+    return render_template(
+        'swagger/swagger-ui.html',
+        title=api.title,
+        specs_url=api.specs_url,
+        user=current_user)


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

Issue:
requires_auth function should abort if a means of authentication fails
Suppose a user tried to send a JWT based authentication and his credentials where wrong, then the `requires_auth` function should abort and don't check active session.
This was my intention all along but there was a logic issue and somehow the tests weren't able to catch it. 



Discussion:

Resolving patch:
diff --git a/open_event/api/helpers.py b/open_event/api/helpers.py
--- a/open_event/api/helpers.py
+++ b/open_event/api/helpers.py
@@ -211,14 +211,14 @@ def decorated(*args, **kwargs):
         except JWTError as e:
             if e.headers is not None and 'WWW-Authenticate' not in e.headers:
                 # JWT header was set but something wrong happened
-                message = e.error + ': ' + e.description
+                _error_abort(401, e.error + ': ' + e.description)
 
         # Basic Auth
         if not success:
             results = auth_basic()
             if not results[0]:
-                if results[1]:
-                    message = results[1]
+                if results[1]:  # basic auth was set but..
+                    _error_abort(401, results[1])
             else:
                 success = True
 


Test patch:
diff --git a/tests/api/test_post_api_auth.py b/tests/api/test_post_api_auth.py
--- a/tests/api/test_post_api_auth.py
+++ b/tests/api/test_post_api_auth.py
@@ -9,6 +9,7 @@
 from tests.auth_helper import register
 from open_event import current_app as app
 
+
 class TestPostApiBasicAuth(OpenEventTestCase):
     """
     Tests the Basic Authorization in Post API
Repository: fossasia/open-event-server

Issue:
Page for Scheduler
A separate page at `/events/ID/schedule/edit` as per #622 for the Scheduling tool.



Discussion:

Resolving patch:
diff --git a/open_event/views/admin/admin.py b/open_event/views/admin/admin.py
--- a/open_event/views/admin/admin.py
+++ b/open_event/views/admin/admin.py
@@ -14,6 +14,7 @@
 from open_event.views.admin.models_views.events import EventsView
 from open_event.views.admin.models_views.roles import RoleView
 from open_event.views.admin.models_views.profile import ProfileView
+from open_event.views.admin.models_views.scheduler import SchedulerView
 from open_event.views.admin.models_views.tracks import TracksView
 from open_event.views.admin.models_views.invite import InviteView
 from open_event.views.admin.models_views.session import SessionView
@@ -33,16 +34,14 @@ def init(self, app):
         self._add_views()
 
     def _add_views(self):
-        events = EventsView(Event, db.session, name='Events', url='events')
-        self.admin.add_view(events)
+        self.admin.add_view(EventsView(Event, db.session, name='Events', url='events'))
         self.admin.add_view(EventsSpeakersView(Speaker, db.session, name='Speaker', url='events/<event_id>/speakers'))
         self.admin.add_view(EventsSponsorsView(Sponsor, db.session, name='Sponsor', url='events/<event_id>/sponsors'))
         self.admin.add_view(SessionView(Session, db.session, name='Sessions', url='events/<event_id>/sessions'))
+        self.admin.add_view(SchedulerView(name='Scheduler', url='events/<event_id>/scheduler'))
         self.admin.add_view(RoleView(Role, db.session, name='Role', url='events/<event_id>/roles'))
-        profile = ProfileView(User, db.session, name='Profile', url='profile')
-        self.admin.add_view(profile)
-        track = TracksView(Track, db.session, name='Track', url='events/<event_id>/tracks')
-        self.admin.add_view(track)
+        self.admin.add_view(ProfileView(User, db.session, name='Profile', url='profile'))
+        self.admin.add_view(TracksView(Track, db.session, name='Track', url='events/<event_id>/tracks'))
         self.admin.add_view(InviteView(Invite, db.session, name='Invite', url='events/<event_id>/invite'))
 
 
diff --git a/open_event/views/admin/models_views/scheduler.py b/open_event/views/admin/models_views/scheduler.py
new file mode 100644
--- /dev/null
+++ b/open_event/views/admin/models_views/scheduler.py
@@ -0,0 +1,9 @@
+from flask_admin import BaseView, expose
+from ....helpers.data_getter import DataGetter
+
+class SchedulerView(BaseView):
+    @expose('/')
+    def display_view(self, event_id):
+        sessions = DataGetter.get_sessions_by_event_id(event_id)
+        event = DataGetter.get_event(event_id)
+        return self.render('/gentelella/admin/scheduler/scheduler.html', sessions=sessions, event=event)


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

Issue:
UI crashed when no user is logged in and root url is opened for the first time
This looks because in data_getter , the events list is fetched for the user without checking if he is logged in. 

``` python
# line 237
    @staticmethod
    def get_published_events():
        events = Event.query.join(Event.roles, aliased=True).filter_by(user_id=login.current_user.id) \
            .filter(Event.state == 'Call for papers')
        return events

    @staticmethod
    def get_current_events():
        events = Event.query.join(Event.roles, aliased=True).filter_by(user_id=login.current_user.id)\
            .filter(Event.state != 'Completed')
        return events
```

@rafalkowalski @SaptakS please look

![crash](https://cloud.githubusercontent.com/assets/4047597/15983010/a57cec4a-2fb7-11e6-8e38-e35a2c3b3059.png)



Discussion:
get_completed_events and get_user_events also use a similar code. I don't know which ones to change . @rafalkowalski @SaptakS someone take this issue. 

@aviaryan I'll take this up


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
@@ -225,7 +225,7 @@ def get_completed_events():
         return events
 
     @staticmethod
-    def get_published_events():
+    def get_all_published_events():
         events = Event.query.filter(Event.state == 'Published')
         return events
 
diff --git a/open_event/views/views.py b/open_event/views/views.py
--- a/open_event/views/views.py
+++ b/open_event/views/views.py
@@ -35,7 +35,7 @@
 def get_main_page():
     """Redirect to admin page"""
     call_for_papers_evs = DataGetter.get_call_for_speakers_events()
-    published_events= DataGetter.get_published_events()
+    published_events = DataGetter.get_all_published_events()
     return render_template('gentelella/index.html',
                            call_for_papers_evs=call_for_papers_evs,
                            published_events=published_events)


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

Issue:
Change color for :hover on Tabs
![screenshot from 2016-06-14 01 36 36](https://cloud.githubusercontent.com/assets/9530293/16021470/915dbb34-31d0-11e6-8b4f-e0bc43bc7045.png)

As you can see, on hovering a tab the text color becomes white.



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
@@ -20,8 +20,10 @@ def index_view(self):
         live_events = DataGetter.get_live_events()
         draft_events = DataGetter.get_draft_events()
         past_events = DataGetter.get_past_events()
+        all_events = DataGetter.get_all_events()
         return self.render('/gentelella/admin/event/index.html',
-                           live_events=live_events, draft_events=draft_events, past_events=past_events)
+                           live_events=live_events, draft_events=draft_events, past_events=past_events,
+                           all_events=all_events)
 
     @expose('/create/', methods=('GET', 'POST'))
     def create_view(self):


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

Issue:
Delete created data if importing event crashes midway
Suppose you are importing an event and there is problem in the sessions.json file. 
Then as the event is created before creating its sessions, the error causes method to immediately abort.  Due to this the created event + other created services (speakers, tracks etc) still remain which should not happen. As the import was unsuccessful, every bit of data created by it should be deleted. 



Discussion:

Resolving patch:
diff --git a/open_event/api/helpers/import_helpers.py b/open_event/api/helpers/import_helpers.py
--- a/open_event/api/helpers/import_helpers.py
+++ b/open_event/api/helpers/import_helpers.py
@@ -17,6 +17,8 @@
 from ..sponsors import DAO as SponsorDAO
 from ..tracks import DAO as TrackDAO
 
+from errors import BaseError, ServerError
+
 
 IMPORT_SERIES = [
     ('formats', FormatDAO),
@@ -131,7 +133,6 @@ def create_service_from_json(data, srv, event_id, service_ids={}):
     # sort by id
     data.sort(key=lambda k: k['id'])
     ids = {}
-    print srv[0]
     # start creating
     for obj in data:
         # trim id field
@@ -164,13 +165,19 @@ def import_event_json(zip_path):
     new_event = EventDAO.create(data, 'dont')[0]
 
     # create other services
-    service_ids = {}
-    for item in IMPORT_SERIES:
-        data = open(path + '/%s.json' % item[0], 'r').read()
-        dic = json.loads(data)
-        changed_ids = create_service_from_json(
-            dic, item, new_event.id, service_ids)
-        service_ids[item[0]] = changed_ids.copy()
-
-    # TODO: If something fails, delete event+everything
+    try:
+        service_ids = {}
+        for item in IMPORT_SERIES:
+            data = open(path + '/%s.json' % item[0], 'r').read()
+            dic = json.loads(data)
+            changed_ids = create_service_from_json(
+                dic, item, new_event.id, service_ids)
+            service_ids[item[0]] = changed_ids.copy()
+    except BaseError as e:
+        EventDAO.delete(new_event.id)
+        raise e
+    except Exception:
+        EventDAO.delete(new_event.id)
+        raise ServerError()
+
     return new_event


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

Issue:
Add Nested validation to API
``` json
{
    "id": 1,
    "email": "email@gmail.com",
    "user_detail": {
        "fullname": "John Doe",
        "details": "bio",
        "avatar": "http://link/to/avatar",
        "contact": "+91823234433",
        "facebook": "http://fb.com/link",
        "twitter": "http://twitter.com/link"
    }
}
```

Currently everything under user_detail is not being validated.
Note - This type of API does not exist now but I think it will be needed for the Profile POST/PUT API. There is no harm in adding this feature. 



Discussion:

Resolving patch:
diff --git a/open_event/api/helpers/helpers.py b/open_event/api/helpers/helpers.py
--- a/open_event/api/helpers/helpers.py
+++ b/open_event/api/helpers/helpers.py
@@ -144,6 +144,8 @@ def validate_payload(payload, api_model):
         if isinstance(field, fields.List):
             field = field.container
             data = payload[key]
+        elif isinstance(field, fields.Nested):
+            validate_payload(payload[key], field.model)
         else:
             data = [payload[key]]
         if isinstance(field, CustomField) and hasattr(field, 'validate'):


Test patch:
diff --git a/tests/api/test_post_api_validation.py b/tests/api/test_post_api_validation.py
--- a/tests/api/test_post_api_validation.py
+++ b/tests/api/test_post_api_validation.py
@@ -19,7 +19,8 @@ def test_event_api(self):
         return self._test_model(
             'event',
             POST_EVENT_DATA,
-            ['color', 'email', 'logo', 'event_url', 'background_url']
+            ['color', 'email', 'logo', 'event_url', 'background_url',
+                'type', 'topic']
         )
 
     def test_speaker_api(self):
Repository: fossasia/open-event-server

Issue:
Session Form: Make Title and Name always required
In session forms in step 5 of the wizard make "Title" and "Name" always required. Maybe we should make those in another color, so it becomes clear that they cannot be edited or change the UI somehow?

![screenshot from 2016-06-15 08 17 55](https://cloud.githubusercontent.com/assets/1583873/16069896/257ff8d4-32d2-11e6-840d-53ea58adb955.png)



Discussion:
Okay ... will do. 

![screencapture-localhost-5000-events-create-1465974801755](https://cloud.githubusercontent.com/assets/2404372/16071049/c55ba0fa-32f6-11e6-87e9-fead851830f2.png)

how about like this ? 
The name and title fields will also be disabled, so that the user can't change it. 

I also feel the email field for the speaker should be compulsory. As that's the way we are able to relate speakers with their Open Event accounts, 

Yes, was also thinking about the email, but there is a common use case, where an organizer will fill out the speaker info for VIPs and maybe does not fill in the info. I am unsure, what is the best decision. 

Well, maybe make it compulsory for now and we need to get feedback of other organizers at some point.


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
@@ -29,6 +29,9 @@ def index_view(self):
     def create_view(self):
         session_columns = DataGetter.get_session_columns()
         speaker_columns = DataGetter.get_speaker_columns()
+        speaker_columns = list(speaker_columns)
+        speaker_columns.insert(2, speaker_columns.pop(4))  # Moving email to the top
+
         if request.method == 'POST':
             event = DataManager.create_event(request.form)
             if event:
@@ -57,6 +60,7 @@ def edit_view(self, event_id):
         sponsors = DataGetter.get_sponsors(event_id)
         session_columns = DataGetter.get_session_columns()
         speaker_columns = DataGetter.get_speaker_columns()
+
         if request.method == 'GET':
             return self.render('/gentelella/admin/event/edit/edit.html', event=event, session_types=session_types,
                                tracks=tracks, social_links=social_links, microlocations=microlocations,


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

Issue:
Internal Server Error on Event Edit
There seemed to be an Internal Server error when editing events. 



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
@@ -616,7 +616,7 @@ def create_event(form, imd):
                                                  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(call_for_speakers, "Call for speakers saved")
 
             uer = UsersEventsRoles(event_id=event.id, user_id=login.current_user.id, role_id=role.id)
             if save_to_db(uer, "Event saved"):
@@ -667,9 +667,9 @@ def edit_event(request, event_id, event, session_types, tracks, social_links, mi
 
         for sponsor in sponsors:
             delete_from_db(sponsor, 'Sponsor deleted')
+
         if call_for_papers:
-            for call_for_paper in call_for_papers:
-                delete_from_db(call_for_paper, 'Call for paper deleted')
+            delete_from_db(call_for_papers, 'Call for paper deleted')
 
         session_type_names = form.getlist('session_type[name]')
         session_type_length = form.getlist('session_type[length]')
@@ -682,7 +682,7 @@ def edit_event(request, event_id, event, session_types, tracks, social_links, mi
 
         room_name = form.getlist('rooms[name]')
         room_color = form.getlist('rooms[color]')
-        print form
+
         sponsor_name = form.getlist('sponsors[name]')
         sponsor_logo = request.files.getlist('sponsors[logo]')
         sponsor_url = form.getlist('sponsors[url]')
@@ -717,7 +717,7 @@ def edit_event(request, event_id, event, session_types, tracks, social_links, mi
                                              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)
-            db.session.add(call_for_speakers)
+            save_to_db(call_for_speakers)
         save_to_db(event, "Event saved")
         return event
 
@@ -786,7 +786,7 @@ def update_user_event_role(form, uer):
         save_to_db(uer, "Event saved")
 
 
-def save_to_db(item, msg):
+def save_to_db(item, msg="Saved to db"):
     """Convenience function to wrap a proper DB save
     :param item: will be saved to database
     :param msg: Message to log


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

Issue:
Show return model of sponsor types list in Swagger spec
Currently no return model (or schema) is shown for the GET API to get sponsor types used in a Event

![sponsor_type_old](https://cloud.githubusercontent.com/assets/4047597/16110108/be118070-33c9-11e6-8532-ce104c5a57d3.png)



Discussion:

Resolving patch:
diff --git a/open_event/api/sponsors.py b/open_event/api/sponsors.py
--- a/open_event/api/sponsors.py
+++ b/open_event/api/sponsors.py
@@ -88,7 +88,7 @@ def post(self, event_id):
 
 @api.route('/events/<int:event_id>/sponsors/types')
 class SponsorTypesList(Resource):
-    @api.doc('list_sponsor_types')
+    @api.doc('list_sponsor_types', model=[fields.String()])
     def get(self, event_id):
         """List all sponsor types"""
         return DAO.list_types(event_id)


Test patch: