Skip to content

Commit

Permalink
Update the registration and login
Browse files Browse the repository at this point in the history
- allow both NGO Hub and user/pass registration
- remove code that is no longer necessary
- redirect old URLs to the signup page
  • Loading branch information
tudoramariei committed Nov 7, 2024
1 parent 33e0827 commit 21f4e93
Show file tree
Hide file tree
Showing 17 changed files with 720 additions and 483 deletions.
11 changes: 8 additions & 3 deletions backend/donations/views/account_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def _send_password_reset_email(self, user: UserModel):

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

def get(self, request, *args, **kwargs):
# if the user is logged in, then redirect
Expand All @@ -104,6 +104,8 @@ def get(self, request, *args, **kwargs):
def post(self, request: HttpRequest, **kwargs):
context = self.get_context_data(**kwargs)

# TODO: if the account appears in NGO Hub, redirect them to the NGO Hub login page

form = LoginForm(request.POST)
if not form.is_valid():
context["errors"] = form.errors
Expand Down Expand Up @@ -175,10 +177,13 @@ def post(self, request, *args, **kwargs):


class SignupView(BaseTemplateView):
template_name = "cont-nou.html"
title = "Cont nou"
template_name = "account/register.html"
title = _("New account")

def get(self, request, *args, **kwargs):
if request.user.is_authenticated:
return redirect(reverse("contul-meu"))

context = self.get_context_data(**kwargs)

return render(request, self.template_name, context)
Expand Down
17 changes: 3 additions & 14 deletions backend/donations/views/site.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
from django.conf import settings
from django.db.models import QuerySet
from django.http import HttpResponse
from django.shortcuts import redirect, render
from django.urls import reverse
from django.shortcuts import render
from django.utils import timezone
from django.utils.translation import gettext_lazy as _
from django.views.generic import TemplateView

from partners.models import DisplayOrderingChoices
from redirectioneaza.common.cache import cache_decorator
from ..models.main import ALL_NGOS_CACHE_KEY, ALL_NGO_IDS_CACHE_KEY, Donor, FRONTPAGE_NGOS_KEY, Ngo

from ..models.main import ALL_NGO_IDS_CACHE_KEY, ALL_NGOS_CACHE_KEY, FRONTPAGE_NGOS_KEY, Donor, Ngo


class HomePage(TemplateView):
Expand Down Expand Up @@ -76,17 +76,6 @@ def get(self, request, *args, **kwargs):
return render(request, self.template_name, context)


class ForNgoHandler(TemplateView):
template_name = "for-ngos.html"

def get(self, request, *args, **kwargs):
if request.user.is_authenticated:
return redirect(reverse("contul-meu"))

context = {"title": "Pentru ONG-uri"}
return render(request, self.template_name, context)


class NgoListHandler(TemplateView):
template_name = "all-ngos.html"

Expand Down
Loading

0 comments on commit 21f4e93

Please sign in to comment.