Repository: fossasia/open-event-server

Issue:
New session email to organizers uses CfS link and needs text improvements
The "new session" email to organizers uses the CfS link of the session which is used for speakers. When changing this email, please also enhance the email. So expected is: It should use the organizer session link.

1. Current email and link:
Hi office@fossasia.org,
The event FOSSASIA Summit 2021 has received a new session proposal.
Visit this link to view the session: https://eventyay.com/e/fa96ae2c/cfs/session/6760

2. Correct link would be: https://eventyay.com/events/fa96ae2c/session/6760
3. Change email text as follows:

Subject: New session proposal for the {event_name} titled "{session_title}".

Hello,

This is an automatic email from {app name} for organizers of the "{event_name}" [add link to public event page].

Your Call for Speakers [add link to CfS page] has received a new session proposal with the following details:

Speaker: {speaker_name}
Email: {speaker_email}
Bio: {speaker_bio}
Session: {session_title}
Abstract: {session_abstract}

You can view all speaker details on the speaker profile [add link to profile for organizers to "speaker profile"] page and the session proposal on the session page [add link to "session page"]. 

To change the status of sessions please go to the sessions overview page [add link to sessions overview page] and click on the status badge of the session.

Thank you.
{app name frontpage}

4. Ensure everything is translatable.


Discussion:
looking into this.
This issue has not been solved entirely. 

1) The following info is missing from the session email:

- Speaker: {speaker_name}
- Email: {speaker_email}
- Bio: {speaker_bio}

2) The link to the "Call for Speakers" in the email goes to the session page. Expected: It should go to the call for speakers page of that event.
I think you confused this a bit. Now the email comes with the bio and details of all speakers of the entire event. Expected: It should be all speakers of a session only. @progmatic-99 

Resolving patch:
diff --git a/app/api/helpers/mail.py b/app/api/helpers/mail.py
--- a/app/api/helpers/mail.py
+++ b/app/api/helpers/mail.py
@@ -150,7 +150,7 @@ def send_email_confirmation(email, link):
     )
 
 
-def send_email_new_session(email, session):
+def send_email_new_session(email, session, speakers):
     """email for new session"""
     app_name = get_settings()['app_name']
     front_page = get_settings()['frontend_url']
@@ -164,6 +164,7 @@ def send_email_new_session(email, session):
         html=render_template(
             mail['template'],
             session=session,
+            speakers=speakers,
             session_overview_link=session_overview_link,
             app_name=app_name,
             front_page=front_page,
diff --git a/app/api/sessions.py b/app/api/sessions.py
--- a/app/api/sessions.py
+++ b/app/api/sessions.py
@@ -73,11 +73,6 @@ def after_create_object(self, session, data, view_kwargs):
         :param view_kwargs:
         :return:
         """
-        if session.event.get_owner():
-            owner = session.event.get_owner()
-            owner_email = owner.email
-            send_email_new_session(owner_email, session)  # TODO: Send to all organizers
-            notify_new_session(session)
 
         for speaker in session.speakers:
             session_speaker_link = SessionsSpeakersLink(
@@ -86,6 +81,13 @@ def after_create_object(self, session, data, view_kwargs):
                 speaker_id=speaker.id,
             )
             save_to_db(session_speaker_link, "Session Speaker Link Saved")
+        
+        if session.event.get_owner():
+            owner = session.event.get_owner()
+            owner_email = owner.email
+            if session.speakers:
+                send_email_new_session(owner_email, session, session.speakers)  # TODO: Send to all organizers
+            notify_new_session(session)
 
     decorators = (api.has_permission('create_event'),)
     schema = SessionSchema
@@ -366,6 +368,10 @@ def after_update_object(self, session, data, view_kwargs):
                         speaker_id=speaker.id,
                     )
                     save_to_db(session_speaker_link, "Session Speaker Link Saved")
+                if current_session.event.get_owner() and current_session.speakers:
+                    owner = session.event.get_owner()
+                    owner_email = owner.email
+                    send_email_new_session(owner_email, session, current_session.speakers)  # TODO: Send to all organizers
 
     decorators = (api.has_permission('is_speaker_for_session', methods="PATCH,DELETE"),)
     schema = SessionSchema
diff --git a/app/models/session.py b/app/models/session.py
--- a/app/models/session.py
+++ b/app/models/session.py
@@ -129,7 +129,7 @@ def site_link(self):
 
     @property
     def site_cfs_link(self):
-        return self.event.site_link + f"/cfs/session/{self.id}"
+        return self.event.site_link + "/cfs"
 
     def __repr__(self):
         return '<Session %r>' % self.title


Test patch: