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

Issue:
Port OTS json to Open Event for samples, import/export
Parent issue #799 and #896 

https://github.com/OpenTechSummit/2016.opentechsummit.net/tree/gh-pages/programm/json



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
@@ -74,7 +74,8 @@ def _delete_fields(srv, data):
     """
     if srv[0] in DELETE_FIELDS:
         for i in DELETE_FIELDS[srv[0]]:
-            del data[i]
+            if i in data:
+                del data[i]
     return data
 
 
diff --git a/open_event/api/helpers/special_fields.py b/open_event/api/helpers/special_fields.py
--- a/open_event/api/helpers/special_fields.py
+++ b/open_event/api/helpers/special_fields.py
@@ -28,3 +28,12 @@ def __init__(self, **kwargs):
         super(SessionLanguageField, self).__init__(
             choice_list=DataGetter.get_language_list(),
             **kwargs)
+
+
+class SessionStateField(fields.ChoiceString):
+    __schema_example__ = 'pending'
+
+    def __init__(self, **kwargs):
+        super(SessionStateField, self).__init__(
+            choice_list=['pending', 'accepted', 'rejected'],
+            **kwargs)
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
@@ -11,7 +11,7 @@
 from .helpers.utils import PAGINATED_MODEL, PaginatedResourceBase, ServiceDAO, \
     PAGE_PARAMS, POST_RESPONSES, PUT_RESPONSES
 from .helpers import custom_fields as fields
-from .helpers.special_fields import SessionLanguageField
+from .helpers.special_fields import SessionLanguageField, SessionStateField
 
 api = Namespace('sessions', description='Sessions', path='/')
 
@@ -24,6 +24,7 @@
 SESSION_SPEAKER = api.model('SessionSpeaker', {
     'id': fields.Integer(required=True),
     'name': fields.String(),
+    'organisation': fields.String()
 })
 
 SESSION_MICROLOCATION = api.model('SessionMicrolocation', {
@@ -47,7 +48,8 @@
     'slides': fields.String(),
     'video': fields.String(),
     'audio': fields.String(),
-    'signup_url': fields.Uri()
+    'signup_url': fields.Uri(),
+    'state': SessionStateField()
 })
 
 SESSION_PAGINATED = api.clone('SessionPaginated', PAGINATED_MODEL, {


Test patch:
diff --git a/tests/api/utils_post_data.py b/tests/api/utils_post_data.py
--- a/tests/api/utils_post_data.py
+++ b/tests/api/utils_post_data.py
@@ -18,7 +18,7 @@
     "closing_datetime": "2016-05-22 12:12:43",
     "organizer_name": "FOSSASIA",
     "organizer_description": "Promoting Open Source culture around the world",
-    "state": "TestEvent",
+    "state": "pending",
     "type": "Conference",
     "topic": "Science & Technology",
     "privacy": "public",
Repository: fossasia/open-event-server

Issue:
If nested fields are null, show null instead of their structure
Take for example Sessions API. If `track` is None (not set), it shows 

``` json
  "title": "string",
  "track": {
    "id": null,
    "name": null
  },
  "video": "string"
```

It would be better if it shows 

``` json
  "title": "string",
  "track": null,
  "video": "string"
```

@shivamMg @mariobehling What do you think ?



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
@@ -41,10 +41,10 @@
     'comments': fields.String(),
     'start_time': fields.DateTime(required=True),
     'end_time': fields.DateTime(required=True),
-    'track': fields.Nested(SESSION_TRACK),
+    'track': fields.Nested(SESSION_TRACK, allow_null=True),
     'speakers': fields.List(fields.Nested(SESSION_SPEAKER)),
     'language': SessionLanguageField(),
-    'microlocation': fields.Nested(SESSION_MICROLOCATION),
+    'microlocation': fields.Nested(SESSION_MICROLOCATION, allow_null=True),
     'slides': fields.String(),
     'video': fields.String(),
     'audio': fields.String(),


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

Issue:
Scheduler: Cannot drag and drop items
I tried out event: https://open-event.herokuapp.com/events/59/scheduler/



Discussion:
- [x] Please only show "accepted "sessions" for the scheduler

Getting an error message on live system.

![screenshot from 2016-06-18 11 41 38](https://cloud.githubusercontent.com/assets/1583873/16170170/ff21c3dc-3549-11e6-822f-2b0f27d856ab.png)

@mariobehling which event ? 

(seems to work fine for me here http://open-event.herokuapp.com/events/61/scheduler/ ) 

http://open-event.herokuapp.com/events/50/scheduler/

Maybe related to https://github.com/fossasia/open-event-orga-server/issues/976

@mariobehling No. it's unrelated to that. It's an issue with the API Validation. API wants Long abstract. But that session doesn't have it. 

@aviaryan @shivamMg the validation for the session and speaker API must be dynamic based on the fields selected by the user.

@niranjan94 So `long_abstract` field is not compulsary. I thought since in database, `long_abstract` is not nullable, it will be compulsary. 
Never mind, can you give an insight into how custom form is being stored in the database. And how can  we retrieve data from it. 

@aviaryan ... @SaptakS implemented that part. I think he'll be able to assist you better. 

@aviaryan except for the Title of the session, none of the fields are necessarily compulsory.. It is upon organizer to decide whether he wants to make that field required. I believe we will need to make modifications in the database table for these other fields.

@SaptakS How are you storing custom forms (in session_form and speaker_form fields) in the CustomForm model ? I will need it to validate a speaker or session post/put request according to the event . 


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
@@ -37,10 +37,10 @@
     'title': fields.String(required=True),
     'subtitle': fields.String(),
     'short_abstract': fields.String(),
-    'long_abstract': fields.String(required=True),
+    'long_abstract': fields.String(),
     'comments': fields.String(),
-    'start_time': fields.DateTime(required=True),
-    'end_time': fields.DateTime(required=True),
+    'start_time': fields.DateTime(),
+    'end_time': fields.DateTime(),
     'track': fields.Nested(SESSION_TRACK, allow_null=True),
     'speakers': fields.List(fields.Nested(SESSION_SPEAKER)),
     'language': SessionLanguageField(),


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

Issue:
Add event name in "Create sessions" form
Currently there is not event name in the create sessions form at `events/ID/sessions/create/`.
![screenshot from 2016-06-18 21 53 10](https://cloud.githubusercontent.com/assets/1583873/16173362/8736f77e-359f-11e6-8564-0f7cc3e35807.png)

Please add the event name here.



Discussion:

Resolving patch:
diff --git a/open_event/views/admin/models_views/sessions.py b/open_event/views/admin/models_views/sessions.py
--- a/open_event/views/admin/models_views/sessions.py
+++ b/open_event/views/admin/models_views/sessions.py
@@ -47,20 +47,22 @@ def create_view(self, event_id):
             return redirect(url_for('.index_view', event_id=event_id))
         speaker_form = json.loads(form_elems.speaker_form)
         session_form = json.loads(form_elems.session_form)
+        event = DataGetter.get_event(event_id)
         if request.method == 'POST':
             DataManager.add_session_to_event(request.form, event_id)
             return redirect(url_for('.index_view', event_id=event_id))
         return self.render('/gentelella/admin/event/sessions/new.html',
-                           speaker_form=speaker_form, session_form=session_form)
+                           speaker_form=speaker_form, session_form=session_form, event=event)
 
     @expose('/new/<user_id>/<hash>/', methods=('GET', 'POST'))
     def new_view(self, event_id, user_id, hash):
         invite = DataGetter.get_invite_by_user_id(user_id)
+        event = DataGetter.get_event(event_id)
         if invite and invite.hash == hash:
             if request.method == 'POST':
                 DataManager.add_session_to_event(request.form, event_id)
                 return redirect(url_for('.index_view', event_id=event_id))
-            return self.render('/gentelella/admin/sessions/new.html')
+            return self.render('/gentelella/admin/sessions/new.html', event=event)
 
     @expose('/<int:session_id>/invited/', methods=('GET', 'POST'))
     def invited_view(self, event_id, session_id):


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

Issue:
Only show "upcoming events" in Upcoming Events section on start page
There seem to be finished events showing up on the start page. Ensure that no drafts or old events show up.

![screenshot from 2016-06-19 03 36 49](https://cloud.githubusercontent.com/assets/1583873/16174718/4d8d4b6a-35cf-11e6-8478-801b5a3ef0d1.png)
u



Discussion:

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
@@ -268,6 +268,7 @@ def get_all_published_events(include_private=False):
             events = Event.query.filter(Event.state == 'Published')
         else:
             events = Event.query.filter(Event.state == 'Published').filter(Event.privacy != 'private')
+        events = events.filter(Event.start_time >= datetime.datetime.now()).filter(Event.end_time >= datetime.datetime.now())
         return events
 
     @staticmethod


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

Issue:
Reduce dependency on outside services to a minimum
There are a number of services that we access for no obvious reason. Especially we get placeholder images from other sites. Why?

Please reduce dependency on other services and keep system images in a static image folder.

Please list in the documentation which outside services we still need nevertheless.



Discussion:

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
@@ -1,5 +1,7 @@
 """Copyright 2015 Rafal Kowalski"""
 import os
+from urllib2 import urlopen
+
 from flask import jsonify, url_for, redirect, request, send_from_directory
 from flask.ext.cors import cross_origin
 from flask.ext import login
@@ -23,6 +25,7 @@
 from open_event.helpers.oauth import OAuth, FbOAuth
 from requests.exceptions import HTTPError
 from ..helpers.data import get_google_auth, create_user_oauth, get_facebook_auth, user_logged_in
+import geoip2.database
 
 auto = Autodoc()
 
@@ -454,6 +457,26 @@ def serve_static(filename):
 def documentation():
     return auto.html()
 
+@app.route('/api/location/', methods=('GET', 'POST'))
+def location():
+    reader = geoip2.database.Reader(os.path.realpath('.') + '/static/data/GeoLite2-Country.mmdb')
+    ip = request.remote_addr
+    if ip == '127.0.0.1' or ip == '0.0.0.0':
+        ip = urlopen('http://ip.42.pl/raw').read()
+    try:
+        response = reader.country(ip)
+        return jsonify({
+            'status': 'ok',
+            'name': response.country.name,
+            'code': response.country.iso_code
+        })
+    except:
+        return jsonify({
+            'status': 'ok',
+            'name': 'United States',
+            'code': 'US'
+        })
+
 @app.route('/migrate/', methods=('GET', 'POST'))
 def run_migrations():
     try:


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

Issue:
Show social links in Event GET API



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
@@ -21,6 +21,12 @@
     'email': fields.Email()
 })
 
+EVENT_SOCIAL = api.model('EventSocial', {
+    'id': fields.Integer(),
+    'name': fields.String(),
+    'link': fields.String()
+})
+
 EVENT = api.model('Event', {
     'id': fields.Integer(required=True),
     'name': fields.String(required=True),
@@ -44,7 +50,8 @@
     'privacy': fields.String(),
     'ticket_url': fields.Uri(),
     'creator': fields.Nested(EVENT_CREATOR, allow_null=True),
-    'schedule_published_on': fields.DateTime()
+    'schedule_published_on': fields.DateTime(),
+    'social_links': fields.List(fields.Nested(EVENT_SOCIAL), attribute='social_link')
 })
 
 EVENT_PAGINATED = api.clone('EventPaginated', PAGINATED_MODEL, {
@@ -54,6 +61,7 @@
 EVENT_POST = api.clone('EventPost', EVENT)
 del EVENT_POST['id']
 del EVENT_POST['creator']
+del EVENT_POST['social_links']
 
 
 class EventDAO(BaseDAO):
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
@@ -27,7 +27,7 @@
 ]
 
 DELETE_FIELDS = {
-    'event': ['creator'],
+    'event': ['creator', 'social_links'],
     'tracks': ['sessions'],
     'speakers': ['sessions']
 }


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

Issue:
Rebuild Event wizard UI for a better UX
To resolve the issues outlined here #1157. 



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
@@ -38,8 +38,12 @@ def index_view(self):
                            past_events=past_events,
                            all_events=all_events)
 
+    @expose('/create/<step>', methods=('GET', 'POST'))
+    def create_view_stepped(self, step):
+        return redirect(url_for('.create_view'))
+
     @expose('/create/', methods=('GET', 'POST'))
-    def create_view(self):
+    def create_view(self,):
         if request.method == 'POST':
             img_files = []
             imd = ImmutableMultiDict(request.files)
@@ -142,6 +146,11 @@ def details_view(self, event_id):
     @expose('/<event_id>/edit/', methods=('GET', 'POST'))
     @can_access
     def edit_view(self, event_id):
+        return self.edit_view_stepped(event_id=event_id, step='')
+
+    @expose('/<event_id>/edit/<step>', methods=('GET', 'POST'))
+    @can_access
+    def edit_view_stepped(self, event_id, step):
         event = DataGetter.get_event(event_id)
         session_types = DataGetter.get_session_types_by_event_id(event_id).all(
         )
@@ -153,7 +162,7 @@ def edit_view(self, event_id):
         custom_forms = DataGetter.get_custom_form_elements(event_id).first()
         speaker_form = json.loads(custom_forms.speaker_form)
         session_form = json.loads(custom_forms.session_form)
-        
+
         preselect = []
         required = []
         for session_field in session_form:
@@ -181,6 +190,7 @@ def edit_view(self, event_id):
                                event_topics=DataGetter.get_event_topics(),
                                preselect=preselect,
                                timezones=DataGetter.get_all_timezones(),
+                               step=step,
                                required=required)
         if request.method == "POST":
             event = DataManager.edit_event(
@@ -188,12 +198,11 @@ def edit_view(self, event_id):
                 microlocations, call_for_speakers, sponsors, custom_forms)
             if request.form.get('state',
                                 u'Draft') == u'Published' and string_empty(
-                event.location_name):
+                                event.location_name):
                 flash(
                     "Your event was saved. To publish your event please review the highlighted fields below.",
                     "warning")
-                return redirect(url_for(
-                    '.edit_view', event_id=event.id) + "#step=location_name")
+                return redirect(url_for('.edit_view', event_id=event.id) + "#highlight=location_name")
 
             return redirect(url_for('.details_view', event_id=event_id))
 


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

Issue:
Internal server error http://open-event.herokuapp.com/admin/logs/



Discussion:
Any logs ? I can't access that link from my account . 


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
@@ -478,10 +478,10 @@ def get_all_timezones():
     def get_sponsor(sponsor_id):
         return Sponsor.query.get(sponsor_id)
 
+    @staticmethod
     def get_all_activities(count=300):
         """
         Get all activities by recent first
         """
         activities = Activity.query.order_by(desc(Activity.time)).all()
         return activities[:count]
-


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

Issue:
The IP Address shown in the login logs are incorrect



Discussion:

Resolving patch:
diff --git a/open_event/helpers/helpers.py b/open_event/helpers/helpers.py
--- a/open_event/helpers/helpers.py
+++ b/open_event/helpers/helpers.py
@@ -177,9 +177,11 @@ def get_request_stats():
     """
     Get IP, Browser, Platform, Version etc
     http://werkzeug.pocoo.org/docs/0.11/utils/#module-werkzeug.useragents
+
+    Note: request.remote_addr gives the server's address if the server is behind a reverse proxy. -@niranjan94
     """
     return {
-        'ip': request.remote_addr,
+        'ip': request.environ['REMOTE_ADDR'],
         'platform': request.user_agent.platform,
         'browser': request.user_agent.browser,
         'version': request.user_agent.version,
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
@@ -459,8 +459,12 @@ def documentation():
 
 @app.route('/api/location/', methods=('GET', 'POST'))
 def location():
+    """
+    Note: request.remote_addr gives the server's address if the server is behind a reverse proxy. -@niranjan94
+    :return:
+    """
     reader = geoip2.database.Reader(os.path.realpath('.') + '/static/data/GeoLite2-Country.mmdb')
-    ip = request.remote_addr
+    ip = request.environ['REMOTE_ADDR']
     if ip == '127.0.0.1' or ip == '0.0.0.0':
         ip = urlopen('http://ip.42.pl/raw').read()
     try:


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

Issue:
Cannot Import Event
![import_error](https://cloud.githubusercontent.com/assets/15054664/16357989/ef1781f4-3b23-11e6-8a19-52a3898acd65.png)
Description field is required to be filled for event to be imported



Discussion:
My guess is that it is the track description field that is giving that error here. Earlier description in track was set to not nullable so I made required=True for that field. I will fix it. 


Resolving patch:
diff --git a/open_event/api/tracks.py b/open_event/api/tracks.py
--- a/open_event/api/tracks.py
+++ b/open_event/api/tracks.py
@@ -17,7 +17,7 @@
 TRACK = api.model('Track', {
     'id': fields.Integer(required=True),
     'name': fields.String(required=True),
-    'description': fields.String(required=True),
+    'description': fields.String(),
     'color': fields.Color(required=True),
     'track_image_url': fields.ImageUri(),
     'location': fields.String(),


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

Issue:
Make privacy field in Event API accept only public/private as values
Currently privacy field in Event API accepts any string . It should be limited to "public" and "private" and should have "public" as default value. 



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
@@ -12,7 +12,8 @@
 from .helpers.utils import PAGINATED_MODEL, PaginatedResourceBase, \
     PAGE_PARAMS, POST_RESPONSES, PUT_RESPONSES, BaseDAO, ServiceDAO
 from .helpers import custom_fields as fields
-from helpers.special_fields import EventTypeField, EventTopicField
+from helpers.special_fields import EventTypeField, EventTopicField, \
+    EventPrivacyField
 
 
 api = Namespace('events', description='Events')
@@ -49,7 +50,7 @@
     'closing_datetime': fields.DateTime(),
     'type': EventTypeField(),
     'topic': EventTopicField(),
-    'privacy': fields.String(),
+    'privacy': EventPrivacyField(),
     'ticket_url': fields.Uri(),
     'creator': fields.Nested(EVENT_CREATOR, allow_null=True),
     'schedule_published_on': fields.DateTime(),
diff --git a/open_event/api/helpers/special_fields.py b/open_event/api/helpers/special_fields.py
--- a/open_event/api/helpers/special_fields.py
+++ b/open_event/api/helpers/special_fields.py
@@ -21,6 +21,16 @@ def __init__(self, **kwargs):
             **kwargs)
 
 
+class EventPrivacyField(fields.ChoiceString):
+    __schema_example__ = 'public'
+
+    def __init__(self, **kwargs):
+        super(EventPrivacyField, self).__init__(
+            choice_list=['public', 'private'],
+            **kwargs
+        )
+
+
 class SessionLanguageField(fields.ChoiceString):
     __schema_example__ = DataGetter.get_language_list()[51]
 


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,7 @@ def test_event_api(self):
             'event',
             POST_EVENT_DATA,
             ['color', 'email', 'logo', 'event_url', 'background_url',
-                'type', 'topic']
+                'type', 'topic', 'privacy']
         )
 
     def test_speaker_api(self):
Repository: fossasia/open-event-server

Issue:
Internal server error
http://open-event.herokuapp.com/Wroc%C5%82aw/events/s



Discussion:

Resolving patch:
diff --git a/open_event/views/public/browse.py b/open_event/views/public/browse.py
--- a/open_event/views/public/browse.py
+++ b/open_event/views/public/browse.py
@@ -53,7 +53,6 @@ def browse(self, location):
 
     @expose('/s', methods=('GET', 'POST'))
     def browses(self, location):
-        print location
         current_page = request.args.get('page')
         if not current_page:
             current_page = 1
@@ -61,10 +60,12 @@ def browses(self, location):
             current_page = int(current_page)
 
         filtering = {'privacy': 'public', 'state': 'Published'}
+        start, end = None, None
         word = request.form.get('word', '')
         event_type = request.args.get('event_type', '')
         day_filter = request.args.get('day', '')
-        start, end = get_date_range(day_filter)
+        if day_filter:
+            start, end = get_date_range(day_filter)
         if location:
             filtering['__event_location'] = location
         if word:


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

Issue:
timezone didn't selected in copy event view
![screen shot 2016-06-27 at 18 04 09](https://cloud.githubusercontent.com/assets/2479753/16386659/bff44398-3c91-11e6-9940-3747b0ea8d1d.png)



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
@@ -283,7 +283,8 @@ def copy_event(self, event_id):
             is_copy=True,
             start_date=datetime.datetime.now() + datetime.timedelta(days=10),
             event_types=DataGetter.get_event_types(),
-            event_topics=DataGetter.get_event_topics())
+            event_topics=DataGetter.get_event_topics(),
+            timezones=DataGetter.get_all_timezones())
 
     @expose('/<int:event_id>/role-invite/<hash>', methods=('GET', 'POST'))
     def user_role_invite(self, event_id, hash):


Test patch: