Repository: fossasia/open-event-server

Issue:
Proposal Stage changing from pending to accepted after editing content
Editing session proposals as an organizer results in sessions showing up in the "Accepted Filter" on the speakers dashboard, but at the same time they are not promoted to the public event page.

Expected: Editing speakers proposals should not change their state.

![screenshot from 2017-01-30 22-30-23](https://cloud.githubusercontent.com/assets/1583873/22442579/298aaefa-e73c-11e6-8863-170ee2b4e3a8.png)

Session Overview with scrollbars, long text, draft issue
The session overview has a few issues:
* [ ] shows scroll bars after saving sessions - Expected: No scrollbars
* [x] After user adds more information to an accepted session, the session shows up again in draft mode - Expected: Session should stay in same mode as before
* [ ] The abstract text in overview is very long - Expected: Only show the first 200 characters of the abstract

![screenshot from 2017-01-29 04-36-14](https://cloud.githubusercontent.com/assets/1583873/22401666/db285d58-e5dc-11e6-9c46-1b5e3bf711c3.png)



Discussion:
At the same time in the speakers dashboard tab the speakers show up in draft. Expected: They should show up in "Pending" here as well.

![screenshot from 2017-01-30 22-36-38](https://cloud.githubusercontent.com/assets/1583873/22442762/b44f59b4-e73c-11e6-88e5-ba99f8f4f8ad.png)



Resolving patch:
diff --git a/app/helpers/data.py b/app/helpers/data.py
--- a/app/helpers/data.py
+++ b/app/helpers/data.py
@@ -351,29 +351,29 @@ def edit_session(request, session, speaker=None):
             video_file = ''
             audio_file = ''
 
-            if slide_temp_url and slide_temp_url!=session.slides:
+            if slide_temp_url and slide_temp_url != session.slides:
                 slide_file = UploadedFile(get_path_of_temp_url(slide_temp_url), slide_temp_url.rsplit('/', 1)[1])
 
-            if video_temp_url and video_temp_url!=session.video:
+            if video_temp_url and video_temp_url != session.video:
                 video_file = UploadedFile(get_path_of_temp_url(video_temp_url), video_temp_url.rsplit('/', 1)[1])
 
-            if audio_temp_url and audio_temp_url!=session.audio:
+            if audio_temp_url and audio_temp_url != session.audio:
                 audio_file = UploadedFile(get_path_of_temp_url(audio_temp_url), audio_temp_url.rsplit('/', 1)[1])
 
             form_state = form.get('state', 'draft')
 
-            if slide_temp_url != "" and slide_temp_url!=session.slides and slide_file:
+            if slide_temp_url != "" and slide_temp_url != session.slides and slide_file:
                 slide_temp_url = upload(slide_file,
-                    UPLOAD_PATHS['sessions']['slides'].format(
-                        event_id=int(event_id), id=int(session.id)
-                    ))
-            if audio_temp_url != "" and audio_temp_url!=session.audio and audio_file:
+                                        UPLOAD_PATHS['sessions']['slides'].format(
+                                            event_id=int(event_id), id=int(session.id)
+                                        ))
+            if audio_temp_url != "" and audio_temp_url != session.audio and audio_file:
                 audio_temp_url = upload(
                     audio_file,
                     UPLOAD_PATHS['sessions']['audio'].format(
                         event_id=int(event_id), id=int(session.id)
                     ))
-            if video_temp_url != "" and video_temp_url!=session.video and video_file:
+            if video_temp_url != "" and video_temp_url != session.video and video_file:
                 video_temp_url = upload(
                     video_file,
                     UPLOAD_PATHS['sessions']['video'].format(
@@ -386,6 +386,7 @@ def edit_session(request, session, speaker=None):
 
             if form_state == 'pending' and session.state != 'pending' and \
                     session.state != 'accepted' and session.state != 'rejected':
+                session.state = 'pending'
                 trigger_new_session_notifications(session.id, event_id=event_id)
 
             session.title = form.get('title', '')
@@ -393,7 +394,6 @@ def edit_session(request, session, speaker=None):
             session.long_abstract = form.get('long_abstract', '')
             session.short_abstract = form.get('short_abstract', '')
             session.level = form.get('level', '')
-            session.state = form_state
             session.track_id = form.get('track', None) if form.get('track', None) != "" else  None
             session.session_type_id = form.get('session_type', None) if form.get('session_type', None) != "" else None
 
@@ -413,8 +413,8 @@ def edit_session(request, session, speaker=None):
                 current_speaker_ids.append(str(current_speaker.id))
 
             for current_speaker_id in current_speaker_ids:
-                if current_speaker_id not in existing_speaker_ids and current_speaker_id \
-                    not in existing_speaker_ids_by_email:
+                if current_speaker_id \
+                     not in existing_speaker_ids and current_speaker_id not in existing_speaker_ids_by_email:
                     current_speaker = DataGetter.get_speaker(current_speaker_id)
                     session.speakers.remove(current_speaker)
                     db.session.commit()
diff --git a/app/views/users/my_sessions.py b/app/views/users/my_sessions.py
--- a/app/views/users/my_sessions.py
+++ b/app/views/users/my_sessions.py
@@ -75,8 +75,8 @@ def process_session_view(session_id):
         speaker = DataGetter.get_speakers(session.event_id).filter_by(user_id=login.current_user.id).first()
         return render_template(
             'gentelella/users/mysessions/mysession_detail_edit.html', session=session,
-                               photo_delete_url=url_for('.avatar_delete', event_id=event.id, speaker_id=speaker.id),
-                               speaker_form=speaker_form, session_form=session_form, event=event, speaker=speaker)
+            photo_delete_url=url_for('.avatar_delete', event_id=event.id, speaker_id=speaker.id),
+            speaker_form=speaker_form, session_form=session_form, event=event, speaker=speaker)
 
     if request.method == 'POST':
         session = DataGetter.get_sessions_of_user_by_id(session_id)


Test patch: