Skip to content

Commit

Permalink
create a paginated ngo redirections page
Browse files Browse the repository at this point in the history
  • Loading branch information
tudoramariei committed Jan 15, 2025
1 parent 1028d2b commit 07a3419
Show file tree
Hide file tree
Showing 17 changed files with 638 additions and 146 deletions.
16 changes: 15 additions & 1 deletion TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@

### Files:

- `templates/v2/ngo-account/**`
- `templates/v2/ngo-account/my-organizations/**`

### Issues:

Expand All @@ -55,3 +55,17 @@
- [ ] The "save" & "get from NGO Hub" buttons should be styled the same
- [ ] Max characters validation for description & other fields
- [ ] The logo upload doesn't work properly


## Organization's redirections

### Files:

- `templates/v2/ngo-account/redirections/**`

### Issues:

- [ ] The pagination doesn't show up properly (it should be right-aligned)
- [ ] Django template: the `nr. crt./#` column from `list-header.html` & `list-items.html` should be calculated properly
- [ ] Make the generate archive button work
- [ ] Make the download table button work
1 change: 0 additions & 1 deletion backend/donations/urls.py

This file was deleted.

18 changes: 18 additions & 0 deletions backend/donations/urls_ngo_account.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from django.conf import settings
from django.contrib import admin
from django.urls import path

from donations.views.ngo_account import (
NgoDetailsView,
NgoFormsView,
NgoRedirectionsView,
)

admin.site.site_header = f"Admin | {settings.VERSION_LABEL}"


urlpatterns = [
path("prezentare/", NgoDetailsView.as_view(), name="organization-presentation"),
path("formulare/", NgoFormsView.as_view(), name="organization-forms"),
path("redirectionari/", NgoRedirectionsView.as_view(), name="organization-redirections"),
]
50 changes: 50 additions & 0 deletions backend/donations/views/ngo_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from django.utils import timezone
from django.utils.decorators import method_decorator
from django.utils.translation import gettext_lazy as _
from django.views.generic import ListView
from django_q.tasks import async_task

from redirectioneaza.common.cache import cache_decorator
Expand Down Expand Up @@ -628,3 +629,52 @@ def change_ngo_owner(ngo, new_ngo_owner):
new_owner.save()

return {"success": "Owner changed successfully"}


class NgoRedirectionsView(ListView):
template_name = "ngo-account/redirections/base.html"
title = _("Redirections")
context_object_name = "redirections"
paginate_by = 8

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

user: User = self.request.user
ngo: Ngo = user.ngo if user.ngo else None

context.update(
{
"user": user,
"ngo": ngo,
"title": self.title,
}
)

return context

def get_queryset(self):
user: User = self.request.user
ngo: Ngo = user.ngo if user.ngo else None

redirections = Donor.objects.none()
if ngo:
redirections = (
ngo.donor_set.all()
.order_by("-date_created")
.values(
"id",
"f_name",
"l_name",
"city",
"county",
"email",
"phone",
"date_created",
"two_years",
"is_anonymous",
"has_signed",
)
)

return redirections
Loading

0 comments on commit 07a3419

Please sign in to comment.