Skip to content

Commit

Permalink
Update templates' titles
Browse files Browse the repository at this point in the history
  • Loading branch information
tudoramariei committed Nov 8, 2024
1 parent 21f4e93 commit 4bcc9ad
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 14 deletions.
20 changes: 12 additions & 8 deletions backend/donations/views/account_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from redirectioneaza.common.messaging import send_email

from ..forms.account import ForgotPasswordForm, LoginForm, RegisterForm, ResetPasswordForm
from .base import BaseTemplateView
from .base import BaseVisibleTemplateView

logger = logging.getLogger(__name__)

Expand All @@ -25,9 +25,9 @@ def django_login(request, user) -> None:
login(request, user, backend="django.contrib.auth.backends.ModelBackend")


class ForgotPasswordView(BaseTemplateView):
class ForgotPasswordView(BaseVisibleTemplateView):
template_name = "resetare-parola.html"
title = "Resetare parola"
title = _("Reset password")

def get(self, request, *args, **kwargs):
context = self.get_context_data(**kwargs)
Expand Down Expand Up @@ -79,7 +79,7 @@ def _send_password_reset_email(self, user: UserModel):
)


class LoginView(BaseTemplateView):
class LoginView(BaseVisibleTemplateView):
template_name = "account/login.html"
title = _("Sign In")

Expand Down Expand Up @@ -144,14 +144,17 @@ def post(self, request: HttpRequest, **kwargs):
return render(request, self.template_name, context)


class LogoutView(BaseTemplateView):
class LogoutView(BaseVisibleTemplateView):
title = _("Sign Out")

def get(self, request, *args, **kwargs):
logout(request)
return redirect("/")


class SetPasswordView(BaseTemplateView):
class SetPasswordView(BaseVisibleTemplateView):
template_name = "parola-noua.html"
title = _("Set New Password")

def post(self, request, *args, **kwargs):
context = self.get_context_data(**kwargs)
Expand All @@ -176,7 +179,7 @@ def post(self, request, *args, **kwargs):
return redirect(reverse("contul-meu"))


class SignupView(BaseTemplateView):
class SignupView(BaseVisibleTemplateView):
template_name = "account/register.html"
title = _("New account")

Expand Down Expand Up @@ -258,14 +261,15 @@ def post(self, request, *args, **kwargs):
return redirect(reverse("contul-meu"))


class VerificationView(BaseTemplateView):
class VerificationView(BaseVisibleTemplateView):
"""
handler used to:
v - verify new account
p - reset user password
"""

template_name = "parola-noua.html"
title = _("Verification")

def get(self, request, *args, **kwargs):
context = self.get_context_data(**kwargs)
Expand Down
3 changes: 3 additions & 0 deletions backend/donations/views/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from django.urls import reverse, reverse_lazy
from django.utils import timezone
from django.utils.decorators import method_decorator
from django.utils.translation import gettext as _
from django.views.decorators.csrf import csrf_exempt
from django.views.generic import TemplateView

Expand All @@ -26,6 +27,8 @@


class UpdateFromNgohub(BaseTemplateView):
title = _("Update from ")

def post(self, request, *args, **kwargs):
redirect_success = redirect(reverse("organization"))
redirect_error = redirect(reverse("organization"))
Expand Down
9 changes: 8 additions & 1 deletion backend/donations/views/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

class BaseTemplateView(TemplateView):
user_model = get_user_model()
title: str = ""

def _get_checked_property(self, property_name: str, default_value: str) -> Any:
is_production: bool = settings.ENVIRONMENT == "development"
Expand All @@ -20,6 +19,14 @@ def _get_checked_property(self, property_name: str, default_value: str) -> Any:

return property_value or default_value

def get_context_data(self, **kwargs):
return super().get_context_data(**kwargs)


class BaseVisibleTemplateView(BaseTemplateView):
user_model = get_user_model()
title: str = ""

def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)

Expand Down
15 changes: 10 additions & 5 deletions backend/donations/views/my_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@
from ..models.jobs import Job, JobStatusChoices
from ..models.main import Donor, Ngo, ngo_id_number_validator
from .api import CheckNgoUrl
from .base import BaseTemplateView
from .base import BaseVisibleTemplateView

UserModel = get_user_model()


class MyAccountDetailsView(BaseTemplateView):
class MyAccountDetailsView(BaseVisibleTemplateView):
template_name = "ngo/my-account-details.html"
title = _("My Account Details")

@method_decorator(login_required(login_url=reverse_lazy("login")))
def get(self, request, *args, **kwargs):
Expand All @@ -53,7 +54,9 @@ def post(self, request, *args, **kwargs):
return render(request, self.template_name, context)


class ArchiveDownloadLinkView(BaseTemplateView):
class ArchiveDownloadLinkView(BaseVisibleTemplateView):
title = _("Download archive")

@method_decorator(login_required(login_url=reverse_lazy("login")))
def get(self, request: HttpRequest, job_id, *args, **kwargs):
user: User = request.user
Expand Down Expand Up @@ -87,8 +90,9 @@ def get(self, request: HttpRequest, job_id, *args, **kwargs):
return redirect(job.zip.url)


class MyAccountView(BaseTemplateView):
class MyAccountView(BaseVisibleTemplateView):
template_name = "ngo/my-account.html"
title = _("My Account")

@staticmethod
@cache_decorator(timeout=settings.TIMEOUT_CACHE_SHORT, cache_key_prefix="DONORS_BY_DONATION_YEAR")
Expand Down Expand Up @@ -181,8 +185,9 @@ def delete_prefilled_form(ngo_id):
return Ngo.delete_prefilled_form(ngo_id)


class NgoDetailsView(BaseTemplateView):
class NgoDetailsView(BaseVisibleTemplateView):
template_name = "ngo/ngo-details.html"
title = _("Organization details")

def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
Expand Down

0 comments on commit 4bcc9ad

Please sign in to comment.