Repository: e-valuation/EvaP

Issue:
Wrong user importer message format
When importing users and a message about changes in a user object is shown, this message does not have correct line breaks, although defined in the code (see `staff/importers.py ExcelImport.check_user_data_sanity`).

current format:
![wrong linebreak](https://cloud.githubusercontent.com/assets/1781719/18945337/5f6b0754-862a-11e6-8637-8711cc305c46.PNG)
(expected are linebreaks before the dashes)



Discussion:

Resolving patch:
diff --git a/evap/staff/importers.py b/evap/staff/importers.py
--- a/evap/staff/importers.py
+++ b/evap/staff/importers.py
@@ -5,6 +5,7 @@
 from django.contrib import messages
 from django.db import transaction
 from django.utils.translation import ugettext as _
+from django.utils.safestring import mark_safe
 from django.core.exceptions import ValidationError
 
 from evap.evaluation.models import Course, UserProfile, Degree, Contribution, CourseType
@@ -180,11 +181,11 @@ def check_user_data_sanity(self):
                         or (user.title is not None and user.title != user_data.title)
                         or user.first_name != user_data.first_name
                         or user.last_name != user_data.last_name):
-                    self.warnings.append(_("The existing user would be overwritten with the following data:") +
-                        "\n - {} ({} {} {}, {})".format(user.username, user.title or "", user.first_name, user.last_name, user.email) +
+                    self.warnings.append(mark_safe(_("The existing user would be overwritten with the following data:") +
+                        "<br> - {} ({} {} {}, {})".format(user.username, user.title or "", user.first_name, user.last_name, user.email) +
                         _(" (existing)") +
-                        "\n - {} ({} {} {}, {})".format(user_data.username, user_data.title or "", user_data.first_name, user_data.last_name, user_data.email) +
-                        _(" (new)"))
+                        "<br> - {} ({} {} {}, {})".format(user_data.username, user_data.title or "", user_data.first_name, user_data.last_name, user_data.email) +
+                        _(" (new)")))
             except UserProfile.DoesNotExist:
                 pass
 
@@ -192,11 +193,11 @@ def check_user_data_sanity(self):
             if len(users_same_name) > 0:
                 warningstring = _("An existing user has the same first and last name as a new user:")
                 for user in users_same_name:
-                    warningstring += "\n - {} ({} {} {}, {})".format(user.username, user.title or "", user.first_name, user.last_name, user.email)
+                    warningstring += "<br> - {} ({} {} {}, {})".format(user.username, user.title or "", user.first_name, user.last_name, user.email)
                     warningstring += _(" (existing)")
-                warningstring += "\n - {} ({} {} {}, {})".format(user_data.username, user_data.title or "", user_data.first_name, user_data.last_name, user_data.email)
+                warningstring += "<br> - {} ({} {} {}, {})".format(user_data.username, user_data.title or "", user_data.first_name, user_data.last_name, user_data.email)
                 warningstring += _(" (new)")
-                self.warnings.append(warningstring)
+                self.warnings.append(mark_safe(warningstring))
 
     def show_errors_and_warnings(self):
         for error in self.errors:


Test patch: