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

Issue:
Show image and square crop option (like in wizard) for speakers and ensure it shows up after import
![screenshot from 2016-08-24 11 30 08](https://cloud.githubusercontent.com/assets/1583873/17925701/48dd03be-69ee-11e6-84e4-c353001ddde1.png)

As the above screenshot shows, the image of the speaker does not show up as expected. In the wizard step 1 it is already implemented in that way.

Compare: http://open-event-dev.herokuapp.com/events/132/speakers/882/edit/



Discussion:

Resolving patch:
diff --git a/app/views/admin/models_views/speakers.py b/app/views/admin/models_views/speakers.py
--- a/app/views/admin/models_views/speakers.py
+++ b/app/views/admin/models_views/speakers.py
@@ -4,10 +4,11 @@
 from flask.ext.restplus import abort
 from flask_admin import expose
 from flask.ext import login
-from flask import request, url_for, redirect, flash
+from flask import request, url_for, redirect, flash, jsonify
 from ....helpers.data import delete_from_db, save_to_db
 from ....helpers.data_getter import DataGetter
 from ....helpers.storage import upload, UPLOAD_PATHS
+from app.helpers.helpers import uploaded_file
 
 
 def get_speaker_or_throw(speaker_id):
@@ -85,3 +86,23 @@ def delete(self, event_id, speaker_id):
         delete_from_db(speaker, 'Speaker Rejected')
         flash("The speaker has been deleted", "danger")
         return redirect(url_for('.index_view', event_id=event_id))
+
+    @expose('/<int:speaker_id>/photo_upload', methods=('POST',))
+    def photo_upload(self, event_id, speaker_id):
+        speaker = get_speaker_or_throw(speaker_id)
+        event = DataGetter.get_event(event_id)
+        photo = request.form['photo']
+        if photo:
+            photo_file = uploaded_file(file_content=photo)
+            photo = upload(
+                photo_file,
+                UPLOAD_PATHS['speakers']['photo'].format(
+                        event_id=int(event_id), id=int(speaker.id)
+                ))
+            speaker.photo = photo
+            save_to_db(speaker)
+            return jsonify({'status': 'ok', 'photo': photo})
+        else:
+            speaker.photo = None
+            save_to_db(speaker)
+            return jsonify({'status': 'Removed'})


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

Issue:
Invitation link returns 404 response in event details page
![test1 open event](https://cloud.githubusercontent.com/assets/2479753/17668627/81f1eeb6-630a-11e6-8894-3521bfbf9e51.png)



Discussion:

Resolving patch:
diff --git a/app/models/role_invite.py b/app/models/role_invite.py
--- a/app/models/role_invite.py
+++ b/app/models/role_invite.py
@@ -41,6 +41,6 @@ def __str__(self):
         return unicode(self).encode('utf-8')
 
     def __unicode__(self):
-        return 'Invite for %r' % (self.email,
-                                  self.event,
-                                  self.role, )
+        return 'Invite for %r:%r:%r' % (self.email,
+                                        self.event,
+                                        self.role)
diff --git a/app/views/admin/models_views/roles.py b/app/views/admin/models_views/roles.py
--- a/app/views/admin/models_views/roles.py
+++ b/app/views/admin/models_views/roles.py
@@ -25,7 +25,6 @@ def create_view(self, event_id):
 
             user = DataGetter.get_user_by_email(email, no_flash=True)
 
-
             accept_link, decline_link = DataManager.add_event_role_invite(email, role_name, event_id)
 
             if not user:
@@ -37,8 +36,6 @@ def create_view(self, event_id):
                                                         role.title_name,
                                                         event.name,
                                                         signup_invite_link)
-                print signup_invite_link
-
                 flash('An email invitation has been sent to user')
             else:
                 if user.has_role(event.id):


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

Issue:
Internal Server Error in CFS via hash
For example: https://open-event-dev.herokuapp.com/e/cfs/1d04a8a181f9c5f58e5aefe58ea99221ec7b3216



Discussion:

Resolving patch:
diff --git a/app/views/public/event_detail.py b/app/views/public/event_detail.py
--- a/app/views/public/event_detail.py
+++ b/app/views/public/event_detail.py
@@ -127,7 +127,33 @@ def display_event_cfs_via_hash(self, hash):
         call_for_speakers = CallForPaper.query.filter_by(hash=hash).first()
         if not call_for_speakers:
             abort(404)
-        return self.display_event_cfs(call_for_speakers.event_id, True)
+        event = DataGetter.get_event(call_for_speakers.event_id)
+        placeholder_images = DataGetter.get_event_default_images()
+        custom_placeholder = DataGetter.get_custom_placeholders()
+        if not event.has_session_speakers:
+            abort(404)
+
+        accepted_sessions = DataGetter.get_sessions(event.id)
+
+        if not call_for_speakers:
+            abort(404)
+
+        form_elems = DataGetter.get_custom_form_elements(event.id)
+        speaker_form = json.loads(form_elems.speaker_form)
+        session_form = json.loads(form_elems.session_form)
+
+        now = datetime.now()
+        state = "now"
+        if call_for_speakers.end_date < now:
+            state = "past"
+        elif call_for_speakers.start_date > now:
+            state = "future"
+        speakers = DataGetter.get_speakers(event.id).all()
+        return self.render('/gentelella/guest/event/cfs.html', event=event, accepted_sessions=accepted_sessions,
+                           speaker_form=speaker_form,
+                           session_form=session_form, call_for_speakers=call_for_speakers,
+                           placeholder_images=placeholder_images, state=state, speakers=speakers,
+                           via_hash=True, custom_placeholder=custom_placeholder)
 
     @expose('/<identifier>/cfs/', methods=('POST',))
     def process_event_cfs(self, identifier):


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

Issue:
Generate an html page from the sitemap.xml as a tab in admin/reports
Sitemap.xml was implemented here #1288

Please implement a html version for admins in a tab on `admin/reports` to make it easier to keep an overview of the development of the site.



Discussion:
@mariobehling
Can you point towards a sample sitemap on how ours should look like . 
I researched and like this ( https://www.xml-sitemaps.com/sitemap.html ), a simple list of urls (with page title) and pagination.
Since this feature is meant to be for admins, I guess we don't need to make a menu-based sitemap like [Eventbrite](https://www.eventbrite.com/sitemap/). 

I am thinking of a simple page with Event names and urls to their respective pages (sessions page, schedule page, main page etc). It will have pagination to keep it from getting huge. 

https://www.xml-sitemaps.com/sitemap.html is not so human friendly and does not provide us with value I think.

Actually, you are right, there are two sitemaps
a) a sitemap like eventbrite for users at `/sitemap` (just follow this example)
b) a sitemap with all pages including admin pages at `/admin/reports` as a tab (you could have a simple in the first version list like in the [below example](http://cdn3.wpbeginner.com/wp-content/uploads/2015/08/html-sitemap-pagesonly.jpg)). I think we should exclude user pages (events, sessions etc) here as it would make the sitemap huge.

![html-sitemap-pagesonly](https://cloud.githubusercontent.com/assets/1583873/16570013/f5e6426a-423d-11e6-9fb7-2156fcc86e7d.jpg)

@aviaryan Do you still have this issue from June 29 on your to do list?

@mariobehling If it is needed, I can start working on it.  Should I start working on this ?

@aviaryan Currently we are linking to an xml on the bottom of the page. So, yes we need something better.

![screenshot from 2016-08-20 10 03 12](https://cloud.githubusercontent.com/assets/1583873/17829899/66a32db2-66bd-11e6-9278-089bbfe26681.png)

> @aviaryan Currently we are linking to an xml on the bottom of the page. So, yes we need something better.

Since the sitemap will be linked from footer, I guess what I need to make here is the "USER (public) sitemap" . I think the eventbrite's public sitemap is a nice example to follow. 

![eventbrite_sitemap](https://cloud.githubusercontent.com/assets/4047597/17996730/46f0ae70-6b88-11e6-9269-b85183860ce0.png)

@mariobehling What do you think ?

Looks very nice. Thank you.


Resolving patch:
diff --git a/app/views/public/pages.py b/app/views/public/pages.py
--- a/app/views/public/pages.py
+++ b/app/views/public/pages.py
@@ -1,6 +1,7 @@
 from flask_admin import BaseView, expose
 from ...helpers.data_getter import DataGetter
 
+
 class BasicPagesView(BaseView):
     @expose('/', methods=('GET', 'POST'))
     def index(self):
@@ -11,3 +12,6 @@ def url_view(self, url):
         page = DataGetter.get_page_by_url('/' + url)
         return self.render('/gentelella/guest/page.html', page=page)
 
+    @expose('/sitemap', methods=('GET', 'POST'))
+    def sitemap_view(self):
+        return self.render('/gentelella/guest/sitemap.html')


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

Issue:
Nested fields in export json are ordered randomly
Nested fields after exporting an event have the tendency to be ordered randomly.

Eg > version field in event json

``` json
{
    "version": {
        "tracks_ver": 4,
        "event_ver": 1, 
        "sessions_ver": 3, 
        "microlocations_ver": 2, 
        "speakers_ver": 2, 
        "sponsors_ver": 3
    }
}
```

This is because eariler we used json dumps sorting when saving the export file but now as we are exporting json in a custom order, we are not using it. So nested fields in the json have a tendency to be exported in a random order. 



Discussion:

Resolving patch:
diff --git a/app/api/helpers/export_helpers.py b/app/api/helpers/export_helpers.py
--- a/app/api/helpers/export_helpers.py
+++ b/app/api/helpers/export_helpers.py
@@ -92,6 +92,20 @@
 
 # FUNCTIONS
 
+def sorted_dict(data):
+    """
+    sorts a json (dict/list->dict) and returns OrderedDict
+    """
+    if type(data) == OrderedDict:
+        data = dict(data)
+    if type(data) == dict:
+        data = OrderedDict(sorted(data.items(), key=lambda t: t[0]))
+    elif type(data) == list:
+        for count in range(len(data)):
+            data[count] = OrderedDict(sorted(data[count].items(), key=lambda t: t[0]))
+    return data
+
+
 def _order_json(data, srv):
     """
     sorts the data a/c FIELD_ORDER and returns.
@@ -99,13 +113,13 @@ def _order_json(data, srv):
     """
     new_data = OrderedDict()
     for field in FIELD_ORDER[srv[0]]:
-        new_data[field] = data[field]
+        new_data[field] = sorted_dict(data[field])
         data.pop(field, None)
     # remaining fields, sort and add
     # https://docs.python.org/2/library/collections.html#collections.OrderedDict
     data = OrderedDict(sorted(data.items(), key=lambda t: t[0]))
     for key in data:
-        new_data[key] = data[key]
+        new_data[key] = sorted_dict(data[key])
     return new_data
 
 


Test patch:
diff --git a/tests/unittests/api/test_export_import.py b/tests/unittests/api/test_export_import.py
--- a/tests/unittests/api/test_export_import.py
+++ b/tests/unittests/api/test_export_import.py
@@ -165,6 +165,8 @@ def test_export_order(self):
         data = open(dr + '/event', 'r').read()
         self.assertTrue(data.find('id') < data.find('background_image'))
         self.assertTrue(data.find('location_name') < data.find('copyright'))
+        # test nested order, they should be sorted alphabetically as they are nested
+        self.assertTrue(data.find('event_ver') < data.find('tracks_ver'))
         # sessions (a service)
         data = open(dr + '/sessions', 'r').read()
         self.assertTrue(data.find('id') < data.find('audio'))
Repository: fossasia/open-event-server

Issue:
Custom forms not taken into account when importing
This happens because custom forms is being imported after speaker/sessions are imported. So the custom form setting for an event is not being taken into account. 
Also there are bugs in the way in which custom form based validation is being handled. 



Discussion:

Resolving patch:
diff --git a/app/api/helpers/helpers.py b/app/api/helpers/helpers.py
--- a/app/api/helpers/helpers.py
+++ b/app/api/helpers/helpers.py
@@ -405,8 +405,11 @@ def model_custom_form(cf_data, model):
     tmp = model.clone('TempModel')
     cf = json.loads(cf_data)
     for key in tmp:
-        if key in cf and cf[key]['require'] == 1:
-            tmp[key].required = True
+        if key in cf:
+            if cf[key]['require'] == 1:
+                tmp[key].required = True
+            elif cf[key]['require'] == 0:
+                tmp[key].required = False
     return tmp
 
 
diff --git a/app/api/helpers/import_helpers.py b/app/api/helpers/import_helpers.py
--- a/app/api/helpers/import_helpers.py
+++ b/app/api/helpers/import_helpers.py
@@ -29,13 +29,13 @@
 
 IMPORT_SERIES = [
     ('social_links', SocialLinkDAO),
+    ('forms', CustomFormDAO),
     ('microlocations', MicrolocationDAO),
     ('sponsors', SponsorDAO),
     ('speakers', SpeakerDAO),
     ('tracks', TrackDAO),
     ('session_types', SessionTypeDAO),
-    ('sessions', SessionDAO),
-    ('forms', CustomFormDAO)
+    ('sessions', SessionDAO)
 ]
 
 DELETE_FIELDS = {
diff --git a/app/api/helpers/tasks.py b/app/api/helpers/tasks.py
--- a/app/api/helpers/tasks.py
+++ b/app/api/helpers/tasks.py
@@ -29,7 +29,7 @@ def import_event_task(self, file):
         print traceback.format_exc()
         update_import_job(task_id, e.message, e.status)
         result = {'__error': True, 'result': e.to_dict()}
-    except Exception:
+    except Exception as e:
         print traceback.format_exc()
         update_import_job(task_id, e.message, e.status)
         result = {'__error': True, 'result': ServerError().to_dict()}


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

Issue:
Timezone not being saved on event edit
I see this error in the terminal.  @niranjan94 Do you have any idea ?

```
ERROR:root:DB Exception! Class '__builtin__.NoneType' is not mapped
```



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
@@ -1779,6 +1779,7 @@ def edit_event(request, event_id, event, session_types, tracks, social_links, mi
 
         # Remove all the tickets that are not in form
         # except those that already have placed orders
+        save_to_db(event, 'Event saved')
         for ticket in event.tickets:
             if ticket.name not in ticket_names and not ticket.has_order_tickets():
                 delete_from_db(ticket, 'Delete ticket')


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

Issue:
Add filter "Checked In" and "Not checked in" to attendees
In order to easily sort "checked in" and "not checked-in" it would be good to have the relevant options in the filters next to "completed, pending, expired".

![screenshot from 2016-08-23 08 33 47](https://cloud.githubusercontent.com/assets/1583873/17882481/fa7ee8d6-690c-11e6-8a08-5177c6e070f1.png)



Discussion:

Resolving patch:
diff --git a/app/helpers/static.py b/app/helpers/static.py
--- a/app/helpers/static.py
+++ b/app/helpers/static.py
@@ -210,7 +210,7 @@
     ('SGD', True, True),
     ('THB', True, True),
     ('TWD', True, True),
-
+    ('USD', True, True),
 }
 
 # Event Images with Event Topics and Subtopics


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

Issue:
Profile Image resized not uploaded using Amazon S3 service.
On uploading a profile image, the resized images are not uploaded. Gives a 500 internal server error.



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
@@ -1016,14 +1016,15 @@ def update_user(form, user_id, avatar_img, contacts_only_update=False):
 
             user_detail.details = form['details']
             logo = form.get('logo', None)
-            print logo
+            #print logo
             if string_not_empty(logo) and logo:
                 filename = '{}.png'.format(time.time())
                 filepath = '{}/static/{}'.format(path.realpath('.'),
                            logo[len('/serve_static/'):])
+                #print "File path 1", filepath
                 logo_file = UploadedFile(filepath, filename)
-                logo = upload(logo_file, 'users/%d/avatar' % int(user_id))
-                user_detail.avatar_uploaded = logo
+                logo_temp = upload(logo_file, 'users/%d/avatar' % int(user_id))
+                user_detail.avatar_uploaded = logo_temp
                 image_sizes = DataGetter.get_image_sizes_by_type(type='profile')
                 if not image_sizes:
                     image_sizes = ImageSizes(full_width=150,
@@ -1037,6 +1038,7 @@ def update_user(form, user_id, avatar_img, contacts_only_update=False):
                 filename = '{}.jpg'.format(time.time())
                 filepath = '{}/static/{}'.format(path.realpath('.'),
                            logo[len('/serve_static/'):])
+                #print "File path 1", filepath
                 logo_file = UploadedFile(filepath, filename)
 
                 temp_img_file = upload_local(logo_file,


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

Issue:
Content type of images stored in AmazonS3 bucket is `application/octet-stream`
e.g.
https://opevbucketname.s3.amazonaws.com/events/179/speakers/1263/photo/MFhNSk9yRU/HansBakker_111.jpg has the content type `application/octet-stream` instead of `image/jpeg`.

Following is the response header for the specified file:

```
Accept-Ranges →bytes
Content-Disposition →attachment; filename=HansBakker_111.jpg
Content-Length →56060
Content-Type →application/octet-stream
Date →Fri, 09 Sep 2016 10:51:06 GMT
ETag →"964b1d839a9261fb0b159e960ceb4cf9"
Last-Modified →Tue, 06 Sep 2016 05:06:23 GMT
Server →AmazonS3
x-amz-id-2 →1GnO0Ta1e+qUE96Qgjm5ZyfyuhMetjc7vfX8UWEsE4fkZRBAuGx9gQwozidTroDVO/SU3BusCZs=
x-amz-request-id →ACF274542E950116
```



Discussion:
@shubham-padia Are you aware of a reliable way to extract the content type information from a file in Python ? To fix this issue, we will have to set Content-Type header when uploading the file to S3 using boto. This [answer on SO](http://stackoverflow.com/a/33445129/2295672) makes it clear. 
The only question that remains is how to get the Content-Type. 

Uploaded files can be of many types like `pptx, pdf, jpg, png, mp4, mkv, mpg, ogg, mp3, m4a` etc.. 

@aviaryan  Maybe this : https://github.com/ahupp/python-magic can do the required task.


Resolving patch:
diff --git a/app/helpers/storage.py b/app/helpers/storage.py
--- a/app/helpers/storage.py
+++ b/app/helpers/storage.py
@@ -5,6 +5,7 @@
 from boto.s3.connection import S3Connection
 from boto.s3.key import Key
 from werkzeug.utils import secure_filename
+import magic
 
 from app.settings import get_settings
 
@@ -102,6 +103,7 @@ def upload(file, key, **kwargs):
     aws_key = get_settings()['aws_key']
     aws_secret = get_settings()['aws_secret']
     storage_place = get_settings()['storage_place']
+
     # upload
     if bucket_name and aws_key and aws_secret and storage_place == 's3':
         return upload_to_aws(bucket_name, aws_key, aws_secret, file, key, **kwargs)
@@ -144,12 +146,15 @@ def upload_to_aws(bucket_name, aws_key, aws_secret, file, key, acl='public-read'
     for item in bucket.list(prefix='/' + key_dir):
         item.delete()
     # set object settings
+
     file_data = file.read()
+    file_mime = magic.from_buffer(file_data, mime=True)
     size = len(file_data)
     sent = k.set_contents_from_string(
         file_data,
         headers={
-            'Content-Disposition': 'attachment; filename=%s' % filename
+            'Content-Disposition': 'attachment; filename=%s' % filename,
+            'Content-Type': '%s' % file_mime
         }
     )
     k.set_acl(acl)


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

Issue:
Propose attendees/ticketing API
With the orga app and the implementation of API endpoints in this PR https://github.com/fossasia/open-event-orga-server/pull/2379 we have the first steps to an attendee API. In how far would that overlap with a ticketing API?

What is the best way to implement this and keep it generic? Do we need two APIs - Attendees and Ticketing or would that be handled in one API?

Also related to https://github.com/fossasia/open-event-orga-server/issues/904



Discussion:
#### Ticketing API
- [x] Retrieving the list of available tickets
- [ ] Placing an order
- [x] Retrieving information about an Order/Payment
- [x] Retrieving information about a ticket

#### Attendee API
- [x] Retrieving the list of attendees
- [x] Retrieving information about a particular Attendee
- [x] Check in/Check out of an attendee

@mariobehling So, I don't think we have any overlap. 


Resolving patch:
diff --git a/app/api/tickets.py b/app/api/tickets.py
--- a/app/api/tickets.py
+++ b/app/api/tickets.py
@@ -52,5 +52,13 @@ def get(self, event_id, ticket_id):
         """Get information about a ticket"""
         return TicketingManager.get_ticket(ticket_id=ticket_id)
 
+@api.route('/events/<int:event_id>/orders/<string:identifier>')
+class Order(Resource):
+    @requires_auth
+    @api.doc('order', responses=POST_RESPONSES)
+    @api.marshal_with(ORDER)
+    def get(self, event_id, identifier):
+        """Get information about a ticket"""
+        return TicketingManager.get_order_by_identifier(identifier=identifier)
 
 


Test patch: