diff --git a/app/accounts/forms.py b/app/accounts/forms.py index 7c84f221..2a4a966e 100644 --- a/app/accounts/forms.py +++ b/app/accounts/forms.py @@ -69,14 +69,16 @@ def clean_email(self): The "clean_email" method is overridden to ensure that only active staff members can reset their passwords. This is done to prevent unauthorized users from resetting their passwords and gaining access to the system. and prevent users getting an email to reset their password if they are not active or staff members. """ + User = get_user_model() email = self.cleaned_data["email"] - users = User.objects.filter(email=email) - if not users.exists(): - raise forms.ValidationError("There is a error please contact the administrator.") - for user in users: - if not user.is_active or not user.is_staff: - raise forms.ValidationError("There is a error please contact the administrator.") + try: + user = User.objects.get(email=email) + except User.DoesNotExist: + raise forms.ValidationError("There is an error please contact the administrator.") + + if not user.is_active or not user.is_staff: + raise forms.ValidationError("There is an error please contact the administrator.") return email diff --git a/app/templates/accounts/email/activation_email.html b/app/templates/accounts/email/activation_email.html index afa50e9b..3c567091 100644 --- a/app/templates/accounts/email/activation_email.html +++ b/app/templates/accounts/email/activation_email.html @@ -1,60 +1,17 @@ - - - - - Activate Your Account - - - -
-

Activate Your Account

-

Hi {{ user.username }},

-

Thank you for signing up for our service. Please click the link below to activate your account:

-

- - Activate your account - -

-

If you did not sign up for this account, please ignore this email.

-

Thank you,

-

The Team

-
- - +{% extends "email_base.html" %} + +{% block title %}Activate Your Account{% endblock %} + +{% block content %} +

Activate Your Account

+

Hi {{ user.username }},

+

Thank you for signing up for our service. Please click the link below to activate your account:

+

+ + Activate your account + +

+

If you did not sign up for this account, please ignore this email.

+

Thank you,

+

The Team

+{% endblock %} diff --git a/app/templates/app/search.html b/app/templates/app/search.html index fdc491a3..dcf8e4c7 100644 --- a/app/templates/app/search.html +++ b/app/templates/app/search.html @@ -19,11 +19,6 @@
{% trans "Search a term" %}

{% for result in search_results %} -
- {{ result }} -
- -

{{ result.heading }}

{{ result.description | truncatewords:10 }}

@@ -38,7 +33,7 @@

{{ result.heading }}

{% endif %}

- {{ result.rank }} + {{ result.rank }}

{% endfor %} @@ -52,8 +47,8 @@

{{ result.heading }}

< previous {% endif %} - Page {{ documents.number }} of {{ documents.paginator.num_pages }}. - + Page {{ documents.number }} of {{ documents.paginator.num_pages }}. + {% if documents.has_next %} next > last diff --git a/app/templates/email_base.html b/app/templates/email_base.html new file mode 100644 index 00000000..49532587 --- /dev/null +++ b/app/templates/email_base.html @@ -0,0 +1,50 @@ + + + + + {% block title %}Email{% endblock %} + + + +
+ {% block content %}{% endblock %} +
+ + diff --git a/app/templates/registration/password_reset_email.html b/app/templates/registration/password_reset_email.html index 88bafad8..c17023d1 100644 --- a/app/templates/registration/password_reset_email.html +++ b/app/templates/registration/password_reset_email.html @@ -1,55 +1,8 @@ - - - - - Password Reset - - - -
+{% block content %}

Password Reset

Hello {{ user.get_username }},

@@ -63,6 +16,4 @@

Password Reset

If you didn't request this, please ignore this email.

Thanks,

Your website team

-
- - +{% endblock %}