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.

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,13 +150,14 @@ 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']
     session_overview_link = session.event.organizer_site_link + "/sessions/pending"
     action = MailType.NEW_SESSION
     mail = MAILS[action]
+
     send_email(
         to=email,
         action=action,
@@ -164,6 +165,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
@@ -76,7 +76,12 @@ def after_create_object(self, session, data, view_kwargs):
         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
+            speakers = Speaker.query.filter_by(
+                event_id=session.event_id, deleted_at=None
+            ).all()
+
+            # TODO: Send to all organizers
+            send_email_new_session(owner_email, session, speakers)
             notify_new_session(session)
 
         for speaker in session.speakers:
@@ -345,7 +350,7 @@ def before_update_object(self, session, data, view_kwargs):
             )
 
     def after_update_object(self, session, data, view_kwargs):
-        """ Send email if session accepted or rejected """
+        """Send email if session accepted or rejected"""
 
         if data.get('send_email', None) and g.get('send_email'):
             notify_for_session(session)
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: