@@ -415,6 +415,15 @@ def homework_submission_recipient_list_payload(
415415 "learning_in_public_score" : submission .learning_in_public_score ,
416416 "faq_score" : submission .faq_score ,
417417 "total_score" : submission .total_score ,
418+ "homework_url" : public_url (
419+ reverse (
420+ "homework" ,
421+ kwargs = {
422+ "course_slug" : course .slug ,
423+ "homework_slug" : homework .slug ,
424+ },
425+ )
426+ ),
418427 }
419428 payload = recipient_list_member_payload (
420429 list_type = "homework_submitters" ,
@@ -457,6 +466,18 @@ def project_submission_recipient_list_payload(
457466 submission .peer_review_learning_in_public_score
458467 ),
459468 "total_score" : submission .total_score ,
469+ "github_link" : submission .github_link ,
470+ "commit_id" : submission .commit_id ,
471+ "faq_contribution_url" : submission .faq_contribution_url or "" ,
472+ "project_url" : public_url (
473+ reverse (
474+ "project" ,
475+ kwargs = {
476+ "course_slug" : course .slug ,
477+ "project_slug" : project .slug ,
478+ },
479+ )
480+ ),
460481 "reviewed_enough_peers" : submission .reviewed_enough_peers ,
461482 "passed" : submission .passed ,
462483 }
@@ -621,6 +642,8 @@ def homework_score_notification_members(
621642 ).order_by ("student_id" , "-submitted_at" , "-id" )
622643 seen_students = set ()
623644 for submission in submissions :
645+ if not getattr (submission .student , "email_submission_confirmations" , True ):
646+ continue
624647 if submission .student_id in seen_students :
625648 continue
626649 item = homework_submission_recipient_list_payload (submission )
@@ -653,6 +676,8 @@ def project_score_notification_members(
653676 "student" , "project__course"
654677 ).order_by ("id" )
655678 for submission in submissions :
679+ if not getattr (submission .student , "email_submission_confirmations" , True ):
680+ continue
656681 item = project_submission_recipient_list_payload (submission )
657682 if item is None :
658683 continue
@@ -680,6 +705,19 @@ def homework_score_notification_payload(
680705 course_url = public_url (
681706 reverse ("course" , kwargs = {"course_slug" : course .slug })
682707 )
708+ homework_url = public_url (
709+ reverse (
710+ "homework" ,
711+ kwargs = {
712+ "course_slug" : course .slug ,
713+ "homework_slug" : homework .slug ,
714+ },
715+ )
716+ )
717+ leaderboard_url = public_url (
718+ reverse ("leaderboard" , kwargs = {"course_slug" : course .slug })
719+ )
720+ profile_url = public_url (reverse ("account_settings" ))
683721
684722 payload = {
685723 "audience" : config .audience ,
@@ -692,7 +730,20 @@ def homework_score_notification_payload(
692730 "homework_slug" : homework .slug ,
693731 "homework_title" : homework .title ,
694732 "course_url" : course_url ,
695- "scores_url" : course_url ,
733+ "homework_url" : homework_url ,
734+ "scores_url" : homework_url ,
735+ "leaderboard_url" : leaderboard_url ,
736+ "profile_url" : profile_url ,
737+ "notification_footer" : (
738+ f"You are receiving this because you submitted { homework .title } "
739+ f"for { course .title } and homework/project submission emails "
740+ "are enabled in your profile."
741+ ),
742+ "notification_footer_text" : (
743+ "If you don't want to receive homework/project submission "
744+ "and score emails, turn off homework and project submission "
745+ f"emails in your profile: { profile_url } "
746+ ),
696747 },
697748 "list" : list_data ,
698749 "members" : members ,
@@ -704,6 +755,8 @@ def homework_score_notification_payload(
704755 "course_slug" : course .slug ,
705756 "homework_slug" : homework .slug ,
706757 "homework_id" : homework .pk ,
758+ "preference_key" : "email_submission_confirmations" ,
759+ "cmp_preference_key" : "email_submission_confirmations" ,
707760 },
708761 }
709762 if config .from_email :
@@ -731,6 +784,22 @@ def project_score_notification_payload(
731784 },
732785 )
733786 )
787+ project_results_url = public_url (
788+ reverse (
789+ "project_results" ,
790+ kwargs = {
791+ "course_slug" : course .slug ,
792+ "project_slug" : project .slug ,
793+ },
794+ )
795+ )
796+ course_url = public_url (
797+ reverse ("course" , kwargs = {"course_slug" : course .slug })
798+ )
799+ leaderboard_url = public_url (
800+ reverse ("leaderboard" , kwargs = {"course_slug" : course .slug })
801+ )
802+ profile_url = public_url (reverse ("account_settings" ))
734803
735804 payload = {
736805 "audience" : config .audience ,
@@ -742,8 +811,22 @@ def project_score_notification_payload(
742811 "course_title" : course .title ,
743812 "project_slug" : project .slug ,
744813 "project_title" : project .title ,
814+ "course_url" : course_url ,
745815 "project_url" : project_url ,
746- "scores_url" : project_url ,
816+ "project_results_url" : project_results_url ,
817+ "scores_url" : project_results_url ,
818+ "leaderboard_url" : leaderboard_url ,
819+ "profile_url" : profile_url ,
820+ "notification_footer" : (
821+ f"You are receiving this because you submitted { project .title } "
822+ f"for { course .title } and homework/project submission emails "
823+ "are enabled in your profile."
824+ ),
825+ "notification_footer_text" : (
826+ "If you don't want to receive homework/project submission "
827+ "and score emails, turn off homework and project submission "
828+ f"emails in your profile: { profile_url } "
829+ ),
747830 },
748831 "list" : list_data ,
749832 "members" : members ,
@@ -755,6 +838,8 @@ def project_score_notification_payload(
755838 "course_slug" : course .slug ,
756839 "project_slug" : project .slug ,
757840 "project_id" : project .pk ,
841+ "preference_key" : "email_submission_confirmations" ,
842+ "cmp_preference_key" : "email_submission_confirmations" ,
758843 },
759844 }
760845 if config .from_email :
0 commit comments