From cea04b624e8d3c05d5aa1860b2ffa6ff541378a8 Mon Sep 17 00:00:00 2001 From: Adil Mohak Date: Sat, 5 Oct 2024 22:44:46 +0300 Subject: [PATCH] Fix: template does not exist --- accounts/forms.py | 9 +++++++++ accounts/models.py | 4 ++-- accounts/urls.py | 2 +- course/forms.py | 1 - templates/accounts/add_staff.html | 1 + templates/accounts/edit_lecturer.html | 3 +++ templates/accounts/profile.html | 2 +- templates/accounts/profile_single.html | 2 +- templates/core/semester_list.html | 14 +------------- templates/core/semester_update.html | 14 +------------- templates/core/session_list.html | 14 +------------- templates/core/session_update.html | 14 +------------- 12 files changed, 22 insertions(+), 58 deletions(-) diff --git a/accounts/forms.py b/accounts/forms.py index 63a5ff9..3958ee0 100644 --- a/accounts/forms.py +++ b/accounts/forms.py @@ -44,6 +44,15 @@ class StaffAddForm(UserCreationForm): label="Last Name", ) + gender = forms.CharField( + widget=forms.Select( + choices=GENDERS, + attrs={ + "class": "browser-default custom-select form-control", + }, + ), + ) + address = forms.CharField( max_length=30, widget=forms.TextInput( diff --git a/accounts/models.py b/accounts/models.py index b95e802..7aa8899 100644 --- a/accounts/models.py +++ b/accounts/models.py @@ -118,7 +118,7 @@ class User(AbstractUser): return no_picture def get_absolute_url(self): - return reverse("profile_single", kwargs={"id": self.id}) + return reverse("profile_single", kwargs={"user_id": self.id}) def save(self, *args, **kwargs): super().save(*args, **kwargs) @@ -170,7 +170,7 @@ class Student(models.Model): return {"M": males_count, "F": females_count} def get_absolute_url(self): - return reverse("profile_single", kwargs={"id": self.id}) + return reverse("profile_single", kwargs={"user_id": self.id}) def delete(self, *args, **kwargs): self.student.delete() diff --git a/accounts/urls.py b/accounts/urls.py index 3042276..b83c77b 100644 --- a/accounts/urls.py +++ b/accounts/urls.py @@ -37,7 +37,7 @@ urlpatterns = [ path("", include("django.contrib.auth.urls")), path("admin_panel/", admin_panel, name="admin_panel"), path("profile/", profile, name="profile"), - path("profile//detail/", profile_single, name="profile_single"), + path("profile//detail/", profile_single, name="profile_single"), path("setting/", profile_update, name="edit_profile"), path("change_password/", change_password, name="change_password"), path("lecturers/", LecturerFilterView.as_view(), name="lecturer_list"), diff --git a/course/forms.py b/course/forms.py index ce568d3..18b1d9e 100644 --- a/course/forms.py +++ b/course/forms.py @@ -51,7 +51,6 @@ class CourseAllocationForm(forms.ModelForm): fields = ["lecturer", "courses"] def __init__(self, *args, **kwargs): - user = kwargs.pop("user") super(CourseAllocationForm, self).__init__(*args, **kwargs) self.fields["lecturer"].queryset = User.objects.filter(is_lecturer=True) diff --git a/templates/accounts/add_staff.html b/templates/accounts/add_staff.html index 14c7818..57861c2 100644 --- a/templates/accounts/add_staff.html +++ b/templates/accounts/add_staff.html @@ -30,6 +30,7 @@ {{ form.email|as_crispy_field }} {{ form.address|as_crispy_field }} {{ form.phone|as_crispy_field }} + {{ form.gender|as_crispy_field }} diff --git a/templates/accounts/edit_lecturer.html b/templates/accounts/edit_lecturer.html index 7516b78..5781cee 100644 --- a/templates/accounts/edit_lecturer.html +++ b/templates/accounts/edit_lecturer.html @@ -20,6 +20,8 @@ {% include 'snippets/messages.html' %} +{{ form.errors }} +
{% csrf_token %}
@@ -29,6 +31,7 @@ {{ form.email|as_crispy_field }} {{ form.first_name|as_crispy_field }} {{ form.last_name|as_crispy_field }} + {{ form.gender|as_crispy_field }} {{ form.phone|as_crispy_field }} {{ form.address|as_crispy_field }}
diff --git a/templates/accounts/profile.html b/templates/accounts/profile.html index 7a8df87..472a47d 100644 --- a/templates/accounts/profile.html +++ b/templates/accounts/profile.html @@ -63,7 +63,7 @@ {% if courses %} {% else %} diff --git a/templates/accounts/profile_single.html b/templates/accounts/profile_single.html index c60762b..89f8e93 100644 --- a/templates/accounts/profile_single.html +++ b/templates/accounts/profile_single.html @@ -76,7 +76,7 @@ {% if courses %} {% else %} diff --git a/templates/core/semester_list.html b/templates/core/semester_list.html index 9675f92..cd30e70 100644 --- a/templates/core/semester_list.html +++ b/templates/core/semester_list.html @@ -19,19 +19,7 @@
{% trans 'Semester List' %}
-{% if messages %} -{% for message in messages %} -{% if message.tags == 'error' %} -
- {{ message }} -
-{% else %} -
- {{ message }} -
-{% endif %} -{% endfor %} -{% endif %} +{% include 'snippets/messages.html' %}
diff --git a/templates/core/semester_update.html b/templates/core/semester_update.html index 8b6a383..b16e182 100644 --- a/templates/core/semester_update.html +++ b/templates/core/semester_update.html @@ -14,19 +14,7 @@ -{% if messages %} - {% for message in messages %} - {% if message.tags == 'error' %} -
- {{ message }} -
- {% else %} -
- {{ message }} -
- {% endif %} - {% endfor %} -{% endif %} +{% include 'snippets/messages.html' %}
diff --git a/templates/core/session_list.html b/templates/core/session_list.html index 98d6e3c..cd5221a 100644 --- a/templates/core/session_list.html +++ b/templates/core/session_list.html @@ -19,19 +19,7 @@
{% trans 'Session List' %}
-{% if messages %} - {% for message in messages %} - {% if message.tags == 'error' %} -
- {{ message }} -
- {% else %} -
- {{ message }} -
- {% endif %} - {% endfor %} -{% endif %} +{% include 'snippets/messages.html' %}
diff --git a/templates/core/session_update.html b/templates/core/session_update.html index b92f576..6b7d500 100644 --- a/templates/core/session_update.html +++ b/templates/core/session_update.html @@ -14,19 +14,7 @@ -{% if messages %} - {% for message in messages %} - {% if message.tags == 'error' %} -
- {{ message }} -
- {% else %} -
- {{ message }} -
- {% endif %} - {% endfor %} -{% endif %} +{% include 'snippets/messages.html' %}