Repository: fossasia/open-event-server

Issue:
Event Dashboard: Implement "Add" button for speakers/session
Currently there is not "Add button" on the specific event dashboard speakers page e.g. http://open-event.herokuapp.com/events/3/speakers/.
- [x] Implement "Add" button next "Rejected"
- [x] **Show "Session/Speaker" form**
- [x] Let "Organizer" change email address of speaker (currently email is added automatically from profile. This is correct, if the user submits own proposals to events, but if the user is the organizer and wants to submit a speaker (himself e.g. a VIP), he should be able to enter an email.)
- [x] Afterwards sent user back to speakers table page



Discussion:
The logic for "Add Speaker" is that a speaker can only be added together with a session. If there is no session then the speaker is not a speaker.

Let us really keep it simple now and just add the full "register as a speaker" form here.

It should not be possible currently in our logic to have a speaker, but no session.

Add speaker = speaker + session (normal form).


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
@@ -52,6 +52,10 @@ def session_display_view(self, event_id, session_id):
     def create_view(self, event_id):
         if request.method == 'POST':
             DataManager.add_session_to_event(request, event_id)
+            flash("The session and speaker have been saved")
+            get_from = request.args.get("from")
+            if get_from and get_from == 'speaker':
+                return redirect(url_for('event_speakers.index_view', event_id=event_id))
             return redirect(url_for('.index_view', event_id=event_id))
 
         form_elems = DataGetter.get_custom_form_elements(event_id).first()
@@ -100,18 +104,6 @@ def invited_view(self, event_id, session_id):
         return self.render('/gentelella/admin/event/sessions/invited.html',
                            session=session, event_id=event_id)
 
-    @expose('/<int:session_id>/speaker/', methods=('GET', 'POST'))
-    def speaker_view(self, event_id, session_id):
-        session = get_session_or_throw(session_id)
-        event = DataGetter.get_event(event_id)
-        form_elems = DataGetter.get_custom_form_elements(event_id).first()
-        speaker_form = json.loads(form_elems.speaker_form)
-        if request.method == 'POST':
-            DataManager.add_speaker_to_session(request, event_id, session_id)
-            return redirect(url_for('.index_view', event_id=event_id))
-        return self.render('/gentelella/admin/event/sessions/speaker.html',
-                           session=session, speaker_form=speaker_form, event=event)
-
     @expose('/<int:session_id>/accept', methods=('GET',))
     @can_accept_and_reject
     def accept_session(self, event_id, session_id):
diff --git a/open_event/views/admin/models_views/speakers.py b/open_event/views/admin/models_views/speakers.py
--- a/open_event/views/admin/models_views/speakers.py
+++ b/open_event/views/admin/models_views/speakers.py
@@ -30,24 +30,6 @@ def index_view(self, event_id):
         return self.render('/gentelella/admin/event/speakers/base_speaker_table.html',
                            speakers=speakers, event_id=event_id, event=event)
 
-    @expose('/create/', methods=('GET', 'POST'))
-    def create_view(self, event_id):
-        event = DataGetter.get_event(event_id)
-
-        if request.method == 'POST':
-            DataManager.add_speaker_to_event(request, event_id, None)
-            flash("User has been added", "success")
-            return redirect(url_for('.index_view', event_id=event_id))
-
-        form_elems = DataGetter.get_custom_form_elements(event_id).first()
-        if not form_elems:
-            flash("Speaker and Session forms have been incorrectly configured for this event."
-                  " Session creation has been disabled", "danger")
-            return redirect(url_for('.index_view', event_id=event_id))
-        speaker_form = json.loads(form_elems.speaker_form)
-        return self.render('/gentelella/admin/event/speakers/edit.html',
-                           event_id=event_id, event=event, speaker_form=speaker_form)
-
     @expose('/<int:speaker_id>/edit/', methods=('GET', 'POST'))
     def edit_view(self, event_id, speaker_id):
         speaker = get_speaker_or_throw(speaker_id)


Test patch: