Repository: dotkom/onlineweb4

Issue:
[Feedback] - Mail text is borked
The feedback notification mail is broken.
Probably after the python upgrade.



Discussion:
Should probably check all other mails too.

On Thu, Mar 10, 2016, 11:35 Torrib notifications@github.com wrote:

> The feedback notification mail is broken.
> Probably after the python upgrade.
> 
> —
> Reply to this email directly or view it on GitHub
> https://github.com/dotKom/onlineweb4/issues/1476.

Though I think maybe @myth is looking into email templates? If not, this is
a golden time to do it. :)

On Thu, Mar 10, 2016, 12:33 Håkon Solbjørg hlsolbjorg@gmail.com wrote:

> Should probably check all other mails too.
> 
> On Thu, Mar 10, 2016, 11:35 Torrib notifications@github.com wrote:
> 
> > The feedback notification mail is broken.
> > Probably after the python upgrade.
> > 
> > —
> > Reply to this email directly or view it on GitHub
> > https://github.com/dotKom/onlineweb4/issues/1476.

No I am not looking into E-mail templates. Too much had to be re-done to continue on that branch. Better to start from scratch. I'm currently focusing on #1474 

Actually, you have WIP PR #1331 on the subject yourself, @sklirg :smile: 

😊

On Mon, Mar 14, 2016, 08:56 Nils Herde notifications@github.com wrote:

> Actually, you have WIP PR #1331
> https://github.com/dotKom/onlineweb4/pull/1331 on the subject yourself,
> @sklirg https://github.com/sklirg [image: :smile:]
> 
> —
> Reply to this email directly or view it on GitHub
> https://github.com/dotKom/onlineweb4/issues/1476#issuecomment-196085535.


Resolving patch:
diff --git a/apps/feedback/mommy.py b/apps/feedback/mommy.py
--- a/apps/feedback/mommy.py
+++ b/apps/feedback/mommy.py
@@ -76,10 +76,10 @@ def generate_message(feedback, logger):
         message.attended_mails = FeedbackMail.get_user_mails(not_responded)
 
         message.committee_mail = FeedbackMail.get_committee_email(feedback)
-        deadline = feedback.deadline.strftime("%d. %B").encode("utf-8")
+        deadline = feedback.deadline.strftime("%d. %B")
         title = FeedbackMail.get_title(feedback)
-        message.link = str("\n\n" + FeedbackMail.get_link(feedback)).encode()
-        results_link = str(FeedbackMail.get_link(feedback) + "results").encode()
+        message.link = str("\n\n" + FeedbackMail.get_link(feedback))
+        results_link = str(FeedbackMail.get_link(feedback) + "results")
 
         deadline_diff = (feedback.deadline - today).days
 
@@ -109,10 +109,8 @@ def generate_message(feedback, logger):
         elif deadline_diff < 1:  # Last warning
             message.deadline = "\n\nI dag innen 23:59 er siste frist til å svare på skjemaet."
 
-            message.results_message = """
-            Hei, siste purremail på feedback skjema har blitt sendt til alle
-            gjenværende deltagere på \"{}\".\nDere kan se feedback-resultatene på:\n{}\n
-            """.format(title, results_link)
+            message.results_message = "Hei, siste purremail på feedback skjema har blitt sendt til alle gjenværende " \
+                "deltagere på \"{}\".\nDere kan se feedback-resultatene på:\n{}\n".format(title, results_link)
             message.send = True
             message.status = "Last warning"
         elif deadline_diff < 3 and feedback.gives_mark:  # 3 days from the deadline
@@ -121,13 +119,11 @@ def generate_message(feedback, logger):
             message.status = "Warning message"
         elif not feedback.first_mail_sent:
             message.deadline = "\n\nFristen for å svare på skjema er %s innen kl 23:59." % deadline
-
-            message.results_message = """
-            Hei, nå har feedbackmail blitt sendt til alle
-            deltagere på \"{}\".\nDere kan se feedback-resultatene på:\n{}\n
-            """.format(title, results_link)
+            message.results_message = "Hei, nå har feedbackmail blitt sendt til alle deltagere på \"{}\"." \
+                "\nDere kan se resultatene på:\n{}\n".format(title, results_link)
             message.send = True
             message.status = "First message"
+
             feedback.first_mail_sent = True
             feedback.save()
             logger.info("first_mail_sent set")
@@ -149,7 +145,7 @@ def date_message(date):
         # If the object(event) doesnt have start date it will send
         # The first notification the day after the feedbackrelation is made
         if date:
-            date_string = date.strftime("%d. %B").encode("utf-8")
+            date_string = date.strftime("%d. %B")
             message_date = "som du var med på den %s:" % date_string
         else:
             message_date = ""
@@ -179,10 +175,8 @@ def get_committee_email(feedback):
     @staticmethod
     def mark_message(feedback):
         if feedback.gives_mark:
-            return """
-            \nVær oppmerksom på at du får prikk dersom du ikke svarer
-            på disse spørsmålene innen fristen.
-            """
+            return "\nVær oppmerksom på at du får prikk dersom du ikke svarer " \
+                "på disse spørsmålene innen fristen."
         else:
             return ""
 


Test patch: