Repository: CiviWiki/OpenCiviWiki

Issue:
Consolidate Backbone templates for comprehension
We are beginning the process of porting Backbone templates to the Django template syntax. However, the Backbone templates are often spread across multiple "partial" files, where a single Backbone model is applied against several combined template fragments.

In order to make it easier to port our Backbone templates, we can combine the templates into single files, where possible.

## Task

- [x] combine Backbone template partials into monolithic template files for easier comprehension


Discussion:

Resolving patch:
diff --git a/project/accounts/views.py b/project/accounts/views.py
--- a/project/accounts/views.py
+++ b/project/accounts/views.py
@@ -82,7 +82,7 @@ class SettingsView(LoginRequiredMixin, UpdateView):
     login_url = "accounts_login"
     form_class = ProfileEditForm
     success_url = reverse_lazy("accounts_settings")
-    template_name = "accounts/utils/update_settings.html"
+    template_name = "accounts/update_settings.html"
 
     def get_object(self, queryset=None):
         return Profile.objects.get(user=self.request.user)
@@ -126,7 +126,6 @@ def get(self, request, uidb64, token):
                     "content": "You have already verified your email",
                     "link": redirect_link,
                 }
-                return TemplateResponse(request, "general-message.html", template_var)
             else:
                 profile.is_verified = True
                 profile.save()
@@ -137,7 +136,6 @@ def get(self, request, uidb64, token):
                     "content": "Thank you for verifying your email with CiviWiki",
                     "link": redirect_link,
                 }
-                return TemplateResponse(request, "general-message.html", template_var)
         else:
             # invalid link
             redirect_link = {"href": "/", "label": "Back to Main"}
@@ -146,7 +144,8 @@ def get(self, request, uidb64, token):
                 "content": "Email could not be verified",
                 "link": redirect_link,
             }
-            return TemplateResponse(request, "general-message.html", template_var)
+
+        return TemplateResponse(request, "general_message.html", template_var)
 
 
 class ProfileSetupView(LoginRequiredMixin, View):


Test patch:
diff --git a/project/accounts/tests/test_views.py b/project/accounts/tests/test_views.py
--- a/project/accounts/tests/test_views.py
+++ b/project/accounts/tests/test_views.py
@@ -29,7 +29,6 @@ def test_login_template(self):
 
         self.assertEqual(self.response.status_code, 200)
         self.assertTemplateUsed(self.response, "accounts/register/login.html")
-        self.assertTemplateNotUsed(self.response, "accounts/login.html")
         self.assertContains(self.response, "Log In")
         self.assertNotContains(self.response, "Wrong Content!")
 
@@ -129,7 +128,7 @@ def setUp(self) -> None:
     def test_template_name(self):
         """Whether the correct template is used"""
 
-        self.assertTemplateUsed(self.response, "accounts/utils/update_settings.html")
+        self.assertTemplateUsed(self.response, "accounts/update_settings.html")
 
     def test_contains_existing_data(self):
         """Whether the existing data is available"""
@@ -178,7 +177,7 @@ def test_activation_link(self):
         response = self.client.get(self.activation_link)
         self.profile.refresh_from_db()
         self.assertTrue(self.profile.is_verified)
-        self.assertTemplateUsed(response, "general-message.html")
+        self.assertTemplateUsed(response, "general_message.html")
         self.assertContains(response, "Email Verification Successful")
 
     def test_activation_link_with_a_verified_user(self):
@@ -186,7 +185,7 @@ def test_activation_link_with_a_verified_user(self):
 
         self.client.get(self.activation_link)
         response = self.client.get(self.activation_link)
-        self.assertTemplateUsed(response, "general-message.html")
+        self.assertTemplateUsed(response, "general_message.html")
         self.assertContains(response, "Email Already Verified")
 
     def test_invalid_action_link(self):
@@ -195,5 +194,5 @@ def test_invalid_action_link(self):
         invalid_link = self.activation_link[:-10] + "12345/"
         response = self.client.get(invalid_link)
         self.assertFalse(self.profile.is_verified)
-        self.assertTemplateUsed(response, "general-message.html")
+        self.assertTemplateUsed(response, "general_message.html")
         self.assertContains(response, "Email Verification Error")