diff --git a/backend/hub/urls.py b/backend/hub/urls.py index 3ba5c84d..db9b0848 100644 --- a/backend/hub/urls.py +++ b/backend/hub/urls.py @@ -14,6 +14,7 @@ CommitteeCandidatesListView, CommitteeOrganizationListView, ElectorCandidatesListView, + HealthView, HomeView, OrganizationDetailView, OrganizationListView, @@ -29,6 +30,7 @@ urlpatterns = [ path("", HomeView.as_view(), name="home"), + path(_("health/"), HealthView.as_view(), name="health"), path(_("candidates/"), CandidateListView.as_view(), name="candidates"), path( _("candidates/register/"), diff --git a/backend/hub/views.py b/backend/hub/views.py index b740e0a7..53ac67aa 100644 --- a/backend/hub/views.py +++ b/backend/hub/views.py @@ -55,6 +55,58 @@ UserModel = get_user_model() +class HealthView(View): + # noinspection PyMethodMayBeStatic + def get(self, request): + base_response = { + "status": "ok", + "timestamp": datetime.now().isoformat(), + "version": settings.VERSION, + "revision": settings.REVISION, + } + + user = request.user + + if user.is_anonymous: + return JsonResponse(base_response) + + base_response["user"] = { + "email": user.email, + } + + if user.organization: + base_response["user"]["organization"] = { + "name": user.organization.name, + "raf": user.organization.registration_number, + } + + if not user.is_impersonate and not user.is_staff: + return JsonResponse(base_response) + + if user.is_staff: + base_response["user"].update( + { + "is_staff": user.is_staff, + "is_superuser": user.is_superuser, + "is_impersonate": user.is_impersonate, + } + ) + + if not user.is_impersonate: + return JsonResponse(base_response) + + base_response["user"]["is_impersonate"] = user.is_impersonate + + base_response["impersonator"] = { + "email": user.impersonator.email, + "is_staff": user.impersonator.is_staff, + "is_superuser": user.impersonator.is_superuser, + "is_impersonate": user.impersonator.is_impersonate, + } + + return JsonResponse(base_response) + + class MenuMixin(ContextMixin): def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) diff --git a/backend/locale/en/LC_MESSAGES/django.po b/backend/locale/en/LC_MESSAGES/django.po index fc476795..40e74f80 100644 --- a/backend/locale/en/LC_MESSAGES/django.po +++ b/backend/locale/en/LC_MESSAGES/django.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-10-29 17:00+0200\n" +"POT-Creation-Date: 2024-10-30 10:15+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -522,7 +522,7 @@ msgstr "" msgid "I agree to the {terms_url} of the VotONG platform" msgstr "" -#: hub/forms.py:105 hub/forms.py:188 hub/views.py:409 +#: hub/forms.py:105 hub/forms.py:188 hub/views.py:458 msgid "An organization with the same email address is already registered." msgstr "" @@ -1497,87 +1497,91 @@ msgstr "" msgid "published" msgstr "" -#: hub/urls.py:32 -msgid "candidates/" +#: hub/urls.py:33 +msgid "health/" msgstr "" #: hub/urls.py:34 +msgid "candidates/" +msgstr "" + +#: hub/urls.py:36 msgid "candidates/register/" msgstr "" -#: hub/urls.py:38 +#: hub/urls.py:40 msgid "candidates//" msgstr "" -#: hub/urls.py:39 +#: hub/urls.py:41 msgid "candidates//vote/" msgstr "" -#: hub/urls.py:40 +#: hub/urls.py:42 msgid "candidates//support/" msgstr "" -#: hub/urls.py:41 +#: hub/urls.py:43 msgid "candidates//revoke/" msgstr "" -#: hub/urls.py:42 +#: hub/urls.py:44 msgid "candidates//status-confirm/" msgstr "" -#: hub/urls.py:43 +#: hub/urls.py:45 msgid "candidates//update/" msgstr "" -#: hub/urls.py:44 +#: hub/urls.py:46 msgid "candidates/votes/" msgstr "" -#: hub/urls.py:45 +#: hub/urls.py:47 msgid "candidates/results/" msgstr "" -#: hub/urls.py:47 +#: hub/urls.py:49 msgid "candidates/ces-results/" msgstr "" -#: hub/urls.py:49 +#: hub/urls.py:51 msgid "committee/ngos/" msgstr "" -#: hub/urls.py:50 +#: hub/urls.py:52 msgid "committee/candidates/" msgstr "" -#: hub/urls.py:51 +#: hub/urls.py:53 msgid "ngos/" msgstr "" -#: hub/urls.py:53 +#: hub/urls.py:55 msgid "ngos/register" msgstr "" -#: hub/urls.py:57 +#: hub/urls.py:59 msgid "ngos/" msgstr "" -#: hub/urls.py:58 +#: hub/urls.py:60 msgid "ngos//vote/" msgstr "" -#: hub/urls.py:59 +#: hub/urls.py:61 msgid "ngos//update" msgstr "" -#: hub/urls.py:60 +#: hub/urls.py:62 msgid "ngo-update/" msgstr "" -#: hub/views.py:69 +#: hub/views.py:118 msgid "Thank you! We'll get in touch soon!" msgstr "" -#: hub/views.py:320 +#: hub/views.py:369 #, python-format msgid "" "Thank you for signing up! The form you filled in has reached us. Someone " @@ -1585,22 +1589,22 @@ msgid "" "validated. If you have any further questions, send us a message at %s." msgstr "" -#: hub/views.py:361 +#: hub/views.py:410 msgid "" "The organization does not have the voting domain set. To be able to vote, " "please set the voting domain." msgstr "" -#: hub/views.py:402 +#: hub/views.py:451 msgid "You must write a rejection message." msgstr "" -#: hub/views.py:859 +#: hub/views.py:908 #, python-format msgid "Please wait %(minutes_threshold)s minutes before updating again." msgstr "" -#: hub/workers/update_organization.py:228 +#: hub/workers/update_organization.py:226 msgid "Error updating organization" msgstr "" diff --git a/backend/locale/ro/LC_MESSAGES/django.po b/backend/locale/ro/LC_MESSAGES/django.po index 0cb8397a..b5ab9b7e 100644 --- a/backend/locale/ro/LC_MESSAGES/django.po +++ b/backend/locale/ro/LC_MESSAGES/django.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-10-29 17:00+0200\n" +"POT-Creation-Date: 2024-10-30 10:15+0200\n" "PO-Revision-Date: 2020-04-23 17:54+0300\n" "Last-Translator: \n" "Language-Team: \n" @@ -536,7 +536,7 @@ msgstr "Termeni și condiții" msgid "I agree to the {terms_url} of the VotONG platform" msgstr "Sunt de acord cu {terms_url} ale platformei VotONG" -#: hub/forms.py:105 hub/forms.py:188 hub/views.py:409 +#: hub/forms.py:105 hub/forms.py:188 hub/views.py:458 msgid "An organization with the same email address is already registered." msgstr "O organizație cu aceeași adresă de email este deja înregistrată." @@ -1558,87 +1558,91 @@ msgstr "publicat la" msgid "published" msgstr "publicat" -#: hub/urls.py:32 +#: hub/urls.py:33 +msgid "health/" +msgstr "health/" + +#: hub/urls.py:34 msgid "candidates/" msgstr "candidatura/" -#: hub/urls.py:34 +#: hub/urls.py:36 msgid "candidates/register/" msgstr "candidatura/inregistrare/" -#: hub/urls.py:38 +#: hub/urls.py:40 msgid "candidates//" msgstr "candidatura/" -#: hub/urls.py:39 +#: hub/urls.py:41 msgid "candidates//vote/" msgstr "candidatura//vot/" -#: hub/urls.py:40 +#: hub/urls.py:42 msgid "candidates//support/" msgstr "candidatura//sustinere/" -#: hub/urls.py:41 +#: hub/urls.py:43 msgid "candidates//revoke/" msgstr "candidatura//revocare/" -#: hub/urls.py:42 +#: hub/urls.py:44 msgid "candidates//status-confirm/" msgstr "candidatura//confirma-starea/" -#: hub/urls.py:43 +#: hub/urls.py:45 msgid "candidates//update/" msgstr "candidatura//actualizare/" -#: hub/urls.py:44 +#: hub/urls.py:46 msgid "candidates/votes/" msgstr "candidatura/voturi/" -#: hub/urls.py:45 +#: hub/urls.py:47 msgid "candidates/results/" msgstr "candidatura/rezultate/" -#: hub/urls.py:47 +#: hub/urls.py:49 msgid "candidates/ces-results/" msgstr "candidatura/ces-rezultate/" -#: hub/urls.py:49 +#: hub/urls.py:51 msgid "committee/ngos/" msgstr "comisie/organizatii/" -#: hub/urls.py:50 +#: hub/urls.py:52 msgid "committee/candidates/" msgstr "comisie/candidatura/" -#: hub/urls.py:51 +#: hub/urls.py:53 msgid "ngos/" msgstr "organizatii/" -#: hub/urls.py:53 +#: hub/urls.py:55 msgid "ngos/register" msgstr "organizatii/inregistrare" -#: hub/urls.py:57 +#: hub/urls.py:59 msgid "ngos/" msgstr "organizatii/" -#: hub/urls.py:58 +#: hub/urls.py:60 msgid "ngos//vote/" msgstr "organizatii//vot/" -#: hub/urls.py:59 +#: hub/urls.py:61 msgid "ngos//update" msgstr "organizatii//actualizare" -#: hub/urls.py:60 +#: hub/urls.py:62 msgid "ngo-update/" msgstr "org-actualizare/" -#: hub/views.py:69 +#: hub/views.py:118 msgid "Thank you! We'll get in touch soon!" msgstr "Mulțumim! Vă vom contacta în curând!" -#: hub/views.py:320 +#: hub/views.py:369 #, python-format msgid "" "Thank you for signing up! The form you filled in has reached us. Someone " @@ -1649,7 +1653,7 @@ msgstr "" "noastră vă va contacta imediat ce organizația trece de procesul de validare. " "Dacă aveți întrebări suplimentare, ne puteți trimite un mesaj la %s." -#: hub/views.py:361 +#: hub/views.py:410 msgid "" "The organization does not have the voting domain set. To be able to vote, " "please set the voting domain." @@ -1658,18 +1662,18 @@ msgstr "" "exercita votul) pentru a te înscrie ca elector sau pentru a nominaliza un " "candidat." -#: hub/views.py:402 +#: hub/views.py:451 msgid "You must write a rejection message." msgstr "Trebuie să completați un motiv de respingere." -#: hub/views.py:859 +#: hub/views.py:908 #, python-format msgid "Please wait %(minutes_threshold)s minutes before updating again." msgstr "" "Vă rugăm așteptați %(minutes_threshold)s minute înainte de a actualiza din " "nou organizația." -#: hub/workers/update_organization.py:228 +#: hub/workers/update_organization.py:226 msgid "Error updating organization" msgstr "Eroare la actualizarea organizației"