Repository: fossasia/open-event-server

Issue:
Sesssions/Profile of speaker of one event shows up in another event submission form
When I try to submit my proposal to another event there are suddenly all the talks of an event where I previously proposed/participated in.

E.g. I participate in the FOSSASIA Summit and propose a session for the OpenTechSummit at https://eventyay.com/e/5642d9a1/cfs/

I see sessions and infos from the FOSSASIA Summit. 

Expected: Each event should be independent and have their independent set of data.

![screenshot from 2017-03-13 01-19-58](https://cloud.githubusercontent.com/assets/1583873/23834099/97cbd4c4-078b-11e7-88a3-d1886ea396e3.png)



Discussion:
I'd like to work on this.
@cepradeep This is a follow up issue to https://github.com/fossasia/open-event-orga-server/issues/3069. Actually if the speaker has never submitted a talk for the specific event, no talk should show up. Right now sessions of another event show up. Imagine you have two blogs on wordpress and blog post of one blog suddenly show up on your second blog. This is what is happening here. 

Events should be totally separated and if no data has been entered for the specific event, it should look like in the following screenshot.

![screenshot from 2017-02-13 06-42-37](https://cloud.githubusercontent.com/assets/20799954/22868103/047f7c22-f1b8-11e6-976a-2ab9d080ed76.png)

@magdalenesuo: Could you help as well, please as you have implemented the original function. Cheers.
@mariobehling I was able to get the issue fixed.

Before registering as a speaker, or proposing a session:

![screenshot from 2017-03-13 14-39-55](https://cloud.githubusercontent.com/assets/6213734/23847753/e8f02a94-07f9-11e7-81b6-4b20f43ab627.png)

After proposing a session:

![screenshot from 2017-03-13 14-43-19](https://cloud.githubusercontent.com/assets/6213734/23847773/ff63c6fa-07f9-11e7-8217-ffbda43572ed.png)

---

But before that, if you clicked the 'Register as a Speaker' button and submitted the form, then subsequent clicks of 'Submit Proposal' show you this:

![screenshot from 2017-03-13 14-39-38](https://cloud.githubusercontent.com/assets/6213734/23847842/496b8ec2-07fa-11e7-82eb-9b2176225604.png)

This doesn't seem right. What is it that we want to display in the dialog when the user has registered as a speaker? Would love @magdalenesuo's inputs as well!
@cepradeep Hey there, been busy lately. Sorry for the delay. After new registration (i.e. no session), it is supposed to show a message saying 'No session. Submit a session proposal? ' or something like that. I was suppose to fix that but got hung up on things. You can work on this too while solving this issue.
@cepradeep And I think I wrote the code to display all the speaker's sessions , I didn't give a check on which event. 

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
@@ -192,6 +192,16 @@ def display_event_cfs(identifier, via_hash=False):
     if login.current_user.is_authenticated:
         email = login.current_user.email
         user_speaker = DataGetter.get_speaker_by_email(email)
+
+        existing_sessions = []
+        for speaker in user_speaker:
+            current_session = []
+            for session in speaker.sessions:
+                if session.event_id == event.id and not session.in_trash:
+                    if session.title:
+                        current_session.append(session)
+            if current_session:
+                existing_sessions.append(current_session)
     if event.sub_topic:
         custom_placeholder = DataGetter.get_custom_placeholder_by_name(event.sub_topic)
     elif event.topic:
@@ -234,7 +244,8 @@ def display_event_cfs(identifier, via_hash=False):
                            accepted_sessions_count=accepted_sessions_count,
                            session_form=session_form, call_for_speakers=call_for_speakers,
                            placeholder_images=placeholder_images, state=state, speakers=speakers,
-                           via_hash=via_hash, custom_placeholder=custom_placeholder, user_speaker=user_speaker)
+                           via_hash=via_hash, custom_placeholder=custom_placeholder,
+                           existing_sessions=existing_sessions)
 
 
 @event_detail.route('/cfs/<hash>/', methods=('GET', 'POST'))


Test patch: