From ff6db1f7cf9bcdf3ace33652823f95007a3dc919 Mon Sep 17 00:00:00 2001 From: Tudor Amariei Date: Tue, 14 Jan 2025 13:57:30 +0200 Subject: [PATCH] additional ngo page modifications --- TODO.md | 13 + .../donations/common/validation/__init__.py | 0 .../common/validation/registration_number.py | 106 +++++++ .../commands/registration_numbers_cleanup.py | 28 +- backend/donations/migrations/0001_initial.py | 3 +- backend/donations/models/ngos.py | 57 +--- backend/donations/views/donations_download.py | 3 +- .../views/{my_account.py => ngo_account.py} | 186 ++++++++++-- .../views/{ngo.py => redirections.py} | 0 backend/locale/en/LC_MESSAGES/django.po | 272 ++++++++++++------ backend/locale/ro/LC_MESSAGES/django.po | 250 ++++++++++------ backend/redirectioneaza/urls.py | 8 +- backend/templates/v1/components/county.html | 2 +- .../v2/components/checkbox-input.html | 26 -- backend/templates/v2/components/input.html | 51 ---- .../templates/v2/components/input/base.html | 9 + .../v2/components/input/checkbox.html | 26 ++ .../templates/v2/components/input/county.html | 37 +++ .../templates/v2/components/input/input.html | 16 ++ .../v2/components/input/textarea.html | 14 + backend/templates/v2/form/donation.html | 28 +- .../templates/v2/ngo-account/ngo-form.html | 22 +- .../v2/ngo-account/ngo-presentation.html | 113 ++++---- .../v2/ngo-account/organization-data.html | 54 ++-- 24 files changed, 881 insertions(+), 443 deletions(-) create mode 100644 backend/donations/common/validation/__init__.py create mode 100644 backend/donations/common/validation/registration_number.py rename backend/donations/views/{my_account.py => ngo_account.py} (70%) rename backend/donations/views/{ngo.py => redirections.py} (100%) delete mode 100644 backend/templates/v2/components/checkbox-input.html delete mode 100644 backend/templates/v2/components/input.html create mode 100644 backend/templates/v2/components/input/base.html create mode 100644 backend/templates/v2/components/input/checkbox.html create mode 100644 backend/templates/v2/components/input/county.html create mode 100644 backend/templates/v2/components/input/input.html create mode 100644 backend/templates/v2/components/input/textarea.html diff --git a/TODO.md b/TODO.md index a88d5b1a..195266ab 100644 --- a/TODO.md +++ b/TODO.md @@ -1,6 +1,17 @@ # Things to do to make the front-end work properly +## Dockerfile + +### Files: + +- `docker/dockerfiles/Dockerfile.dev` + +### Issues: + +- [ ] NPM doesn't install packages properly and uses local packages instead + + ## Donation form ### Files: @@ -41,3 +52,5 @@ - [ ] The disabled form fields need to be styled properly - [ ] Connect the form to the BE properly - [ ] Check the data for changes when switching tabs +- [ ] The "save" & "get from NGO Hub" buttons should be styled the same +- [ ] Max characters validation for description & other fields diff --git a/backend/donations/common/validation/__init__.py b/backend/donations/common/validation/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/backend/donations/common/validation/registration_number.py b/backend/donations/common/validation/registration_number.py new file mode 100644 index 00000000..efb73c60 --- /dev/null +++ b/backend/donations/common/validation/registration_number.py @@ -0,0 +1,106 @@ +import re +from typing import Dict, List, Optional, Tuple + +from django.conf import settings +from django.core.exceptions import ValidationError +from django.utils.translation import gettext_lazy as _ + +ALLOWED_CHARACTERS_REGEX = r"[^RO0-9]" +REGISTRATION_NUMBER_REGEX = r"^([A-Z]{2}|)\d{2,10}$" +REGISTRATION_NUMBER_REGEX_SANS_VAT = r"^\d{2,10}$" +REGISTRATION_NUMBER_REGEX_WITH_VAT = r"^[A-Z]{2}\d{2,10}$" + + +def extract_vat_id(registration_number: str) -> Dict[str, str]: + """ + Extract the VAT ID and the registration number from a valid registration number. + :param registration_number: + A registration number that may or may not contain a VAT ID. + The registration number must have a valid format. + :return: A dictionary containing the VAT ID and the registration number. + { + "vat_id": "RO", + "registration_number": "1234567890", + } + """ + + result = { + "vat_id": "", + "registration_number": registration_number, + } + + if re.match(REGISTRATION_NUMBER_REGEX_SANS_VAT, registration_number): + return result + + result["vat_id"] = registration_number[:2] + result["registration_number"] = registration_number[2:] + + return result + + +def clean_registration_number(registration_number: str) -> Optional[str]: + """ + Clean up a registration number by uppercasing the string, then removing any whitespace or forbidden characters. + :param registration_number: The registration number to clean. + :return: The cleaned registration number. + """ + if re.match(REGISTRATION_NUMBER_REGEX, registration_number): + return registration_number + + # uppercase the string and strip of any whitespace + registration_number = registration_number.upper().strip() + + # remove all the whitespace + registration_number = re.sub(r"\s+", "", registration_number) + + # remove any forbidden characters + registration_number = re.sub(ALLOWED_CHARACTERS_REGEX, "", registration_number) + + return registration_number + + +def ngo_id_number_validator(value): + """ + Validate a registration number for an NGO. + :param value: The registration number to validate. + :return: None + """ + + reg_num: str = "".join([char for char in value.upper() if char.isalnum()]) + + if reg_num == len(reg_num) * "0": + raise ValidationError(_("The ID number cannot be all zeros")) + + if not re.match(REGISTRATION_NUMBER_REGEX, reg_num): + raise ValidationError(_("The ID number format is not valid")) + + if re.match(REGISTRATION_NUMBER_REGEX_WITH_VAT, reg_num): + reg_num = value[2:] + + if not reg_num.isdigit(): + raise ValidationError(_("The ID number must contain only digits")) + + if 2 > len(reg_num) or len(reg_num) > 10: + raise ValidationError(_("The ID number must be between 2 and 10 digits long")) + + if not settings.ENABLE_FULL_CUI_VALIDATION: + return + + control_key: str = "753217532" + + reversed_key: List[int] = [int(digit) for digit in control_key[::-1]] + reversed_cif: List[int] = [int(digit) for digit in reg_num[::-1]] + + cif_control_digit: int = reversed_cif.pop(0) + + cif_key_pairs: Tuple[int, ...] = tuple( + cif_digit * key_digit for cif_digit, key_digit in zip(reversed_cif, reversed_key) + ) + control_result: int = sum(cif_key_pairs) * 10 % 11 + + if control_result == cif_control_digit: + return + elif control_result == 10 and cif_control_digit == 0: + return + + raise ValidationError(_("The ID number is not valid")) diff --git a/backend/donations/management/commands/registration_numbers_cleanup.py b/backend/donations/management/commands/registration_numbers_cleanup.py index 9a960c31..45171e44 100644 --- a/backend/donations/management/commands/registration_numbers_cleanup.py +++ b/backend/donations/management/commands/registration_numbers_cleanup.py @@ -4,12 +4,15 @@ from django.core.exceptions import ValidationError from django.core.management import BaseCommand -from donations.models.ngos import ( - Ngo, +from donations.common.validation.registration_number import ( REGISTRATION_NUMBER_REGEX, - REGISTRATION_NUMBER_REGEX_SANS_VAT, + clean_registration_number, + extract_vat_id, ngo_id_number_validator, ) +from donations.models.ngos import ( + Ngo, +) class Command(BaseCommand): @@ -55,7 +58,7 @@ def clean_ngo(self, ngo_id: int) -> Dict[str, str]: def clean_ngo_registration_number(self, ngo: Ngo) -> Dict[str, str]: initial_registration_number = ngo.registration_number - cleaned_registration_number = self._clean_up_registration_number(initial_registration_number) + cleaned_registration_number = clean_registration_number(initial_registration_number) if not re.match(REGISTRATION_NUMBER_REGEX, cleaned_registration_number): self.stdout.write( @@ -90,7 +93,7 @@ def clean_ngo_registration_number(self, ngo: Ngo) -> Dict[str, str]: ), } - vat_information = self._extract_vat_id(cleaned_registration_number) + vat_information = extract_vat_id(cleaned_registration_number) ngo.vat_id = vat_information["vat_id"] ngo.registration_number = vat_information["registration_number"] @@ -120,21 +123,6 @@ def _clean_up_registration_number(reg_num: str) -> Optional[str]: return reg_num - @staticmethod - def _extract_vat_id(reg_num: str) -> Dict[str, str]: - result = { - "vat_id": "", - "registration_number": reg_num, - } - - if re.match(REGISTRATION_NUMBER_REGEX_SANS_VAT, reg_num): - return result - - result["vat_id"] = reg_num[:2] - result["registration_number"] = reg_num[2:] - - return result - @staticmethod def _validate_registration_number(reg_num: str) -> bool: try: diff --git a/backend/donations/migrations/0001_initial.py b/backend/donations/migrations/0001_initial.py index 262b1132..72dcf4dd 100644 --- a/backend/donations/migrations/0001_initial.py +++ b/backend/donations/migrations/0001_initial.py @@ -5,6 +5,7 @@ import django.db.models.functions.text from django.db import migrations, models +import donations.common.validation.registration_number import donations.models.donors import donations.models.ngos @@ -138,7 +139,7 @@ class Migration(migrations.Migration): db_index=True, max_length=100, unique=True, - validators=[donations.models.ngos.ngo_id_number_validator], + validators=[donations.common.validation.registration_number.ngo_id_number_validator], verbose_name="registration number", ), ), diff --git a/backend/donations/models/ngos.py b/backend/donations/models/ngos.py index ce7aabee..b4f62db1 100644 --- a/backend/donations/models/ngos.py +++ b/backend/donations/models/ngos.py @@ -1,7 +1,6 @@ import logging import re from functools import partial -from typing import List, Tuple from django.conf import settings from django.core.cache import cache @@ -13,16 +12,13 @@ from django.utils.translation import gettext_lazy as _ from donations.common.models_hashing import hash_id_secret +from donations.common.validation.registration_number import REGISTRATION_NUMBER_REGEX_WITH_VAT, ngo_id_number_validator ALL_NGOS_CACHE_KEY = "ALL_NGOS" ALL_NGO_IDS_CACHE_KEY = "ALL_NGO_IDS" FRONTPAGE_NGOS_KEY = "FRONTPAGE_NGOS" FRONTPAGE_STATS_KEY = "FRONTPAGE_NGOS_STATS" -REGISTRATION_NUMBER_REGEX = r"^([A-Z]{2}|)\d{2,10}$" -REGISTRATION_NUMBER_REGEX_SANS_VAT = r"^\d{2,10}$" -REGISTRATION_NUMBER_REGEX_WITH_VAT = r"^[A-Z]{2}\d{2,10}$" - logger = logging.getLogger(__name__) @@ -58,47 +54,6 @@ def ngo_slug_validator(value): raise ValidationError(error_message) -def ngo_id_number_validator(value): - reg_num: str = "".join([char for char in value.upper() if char.isalnum()]) - - if reg_num == len(reg_num) * "0": - raise ValidationError(_("The ID number cannot be all zeros")) - - if not re.match(REGISTRATION_NUMBER_REGEX, reg_num): - raise ValidationError(_("The ID number format is not valid")) - - if re.match(REGISTRATION_NUMBER_REGEX_WITH_VAT, reg_num): - reg_num = value[2:] - - if not reg_num.isdigit(): - raise ValidationError(_("The ID number must contain only digits")) - - if 2 > len(reg_num) or len(reg_num) > 10: - raise ValidationError(_("The ID number must be between 2 and 10 digits long")) - - if not settings.ENABLE_FULL_CUI_VALIDATION: - return - - control_key: str = "753217532" - - reversed_key: List[int] = [int(digit) for digit in control_key[::-1]] - reversed_cif: List[int] = [int(digit) for digit in reg_num[::-1]] - - cif_control_digit: int = reversed_cif.pop(0) - - cif_key_pairs: Tuple[int, ...] = tuple( - cif_digit * key_digit for cif_digit, key_digit in zip(reversed_cif, reversed_key) - ) - control_result: int = sum(cif_key_pairs) * 10 % 11 - - if control_result == cif_control_digit: - return - elif control_result == 10 and cif_control_digit == 0: - return - - raise ValidationError(_("The ID number is not valid")) - - class NgoActiveManager(models.Manager): def get_queryset(self): return super().get_queryset().filter(is_active=True) @@ -194,10 +149,12 @@ class Ngo(models.Model): db_index=True, ) - # originally: tel phone = models.CharField(verbose_name=_("telephone"), blank=True, null=False, default="", max_length=30) - email = models.EmailField(verbose_name=_("email"), blank=True, null=False, default="", db_index=True) + + display_email = models.BooleanField(verbose_name=_("display email"), db_index=True, default=False) + display_phone = models.BooleanField(verbose_name=_("display phone"), db_index=True, default=False) + website = models.URLField(verbose_name=_("website"), blank=True, null=False, default="") # originally: verified @@ -283,6 +240,10 @@ def deactivate(self, commit: bool = True): if commit: self.save() + @property + def full_registration_number(self): + return f"{self.vat_id}{self.registration_number}" if self.vat_id else self.registration_number + @staticmethod def delete_prefilled_form(ngo_id): try: diff --git a/backend/donations/views/donations_download.py b/backend/donations/views/donations_download.py index 00603c27..1c4f7b9f 100644 --- a/backend/donations/views/donations_download.py +++ b/backend/donations/views/donations_download.py @@ -20,9 +20,10 @@ from django.utils.translation import gettext_lazy as _ from localflavor.ro.ro_counties import COUNTIES_CHOICES +from donations.common.validation.registration_number import REGISTRATION_NUMBER_REGEX_SANS_VAT from donations.models.donors import Donor from donations.models.jobs import Job, JobDownloadError, JobStatusChoices -from donations.models.ngos import REGISTRATION_NUMBER_REGEX_SANS_VAT, Ngo +from donations.models.ngos import Ngo from redirectioneaza.common.messaging import send_email logger = logging.getLogger(__name__) diff --git a/backend/donations/views/my_account.py b/backend/donations/views/ngo_account.py similarity index 70% rename from backend/donations/views/my_account.py rename to backend/donations/views/ngo_account.py index fd952339..6ea48086 100644 --- a/backend/donations/views/my_account.py +++ b/backend/donations/views/ngo_account.py @@ -1,3 +1,4 @@ +import datetime from collections import OrderedDict from typing import List, Optional @@ -19,15 +20,48 @@ from redirectioneaza.common.cache import cache_decorator from users.models import User +from ..common.validation.registration_number import clean_registration_number, extract_vat_id, ngo_id_number_validator from ..models.donors import Donor from ..models.jobs import Job, JobStatusChoices -from ..models.ngos import Ngo, ngo_id_number_validator +from ..models.ngos import Ngo from .api import CheckNgoUrl from .base import BaseVisibleTemplateView UserModel = get_user_model() +def validate_iban_number(bank_account) -> Optional[str]: + if not bank_account: + return None + + if len(bank_account) != 24: + return _("The IBAN number must have 24 characters") + + if not bank_account.isalnum(): + return _("The IBAN number must contain only letters and digits") + + if not bank_account.startswith("RO"): + return _("The IBAN number must start with 'RO'") + + return None + + +def validate_registration_number(ngo, registration_number) -> Optional[str]: + try: + ngo_id_number_validator(registration_number) + except ValidationError: + return f'CIF "{registration_number}" pare incorect' + + reg_num_query: QuerySet[Ngo] = Ngo.objects.filter(registration_number=registration_number) + if ngo.pk: + reg_num_query = reg_num_query.exclude(pk=ngo.pk) + + if reg_num_query.exists(): + return f'CIF "{registration_number}" este înregistrat deja' + + return "" + + class MyAccountDetailsView(BaseVisibleTemplateView): template_name = "ngo/my-account-details.html" title = _("My Account Details") @@ -130,7 +164,7 @@ def get(self, request: HttpRequest, *args, **kwargs): "years": list(grouped_donors.keys()), } - download_expired = not now.date() > settings.DONATIONS_LIMIT + timezone.timedelta( + download_expired = not now.date() > settings.DONATIONS_LIMIT + datetime.timedelta( days=settings.TIMEDELTA_DONATIONS_LIMIT_DOWNLOAD_DAYS ) @@ -145,9 +179,9 @@ def get(self, request: HttpRequest, *args, **kwargs): last_job_date = ngo_jobs[0].date_created last_job_status = ngo_jobs[0].status - timedelta = timezone.timedelta(0) + timedelta = datetime.timedelta(0) if last_job_status != JobStatusChoices.ERROR: - timedelta = timezone.timedelta(minutes=settings.TIMEDELTA_FORMS_DOWNLOAD_MINUTES) + timedelta = datetime.timedelta(minutes=settings.TIMEDELTA_FORMS_DOWNLOAD_MINUTES) if last_job_date > now - timedelta: last_job_was_recent = True @@ -186,7 +220,7 @@ def delete_prefilled_form(ngo_id): return Ngo.delete_prefilled_form(ngo_id) -class NgoDetailsView(BaseVisibleTemplateView): +class NewNgoDetailsView(BaseVisibleTemplateView): template_name = "ngo-account/organization-data.html" title = _("Organization details") @@ -196,6 +230,10 @@ def get_context_data(self, **kwargs): user: User = self.request.user ngo: Ngo = user.ngo if user.ngo else None + has_ngohub = None + if ngo: + has_ngohub = ngo.ngohub_org_id is not None + context.update( { "title": "Date organizație", @@ -203,15 +241,9 @@ def get_context_data(self, **kwargs): "user": user, "ngo": ngo, "ngo_url": self.request.build_absolute_uri(reverse("twopercent", kwargs={"ngo_url": ngo.slug})), - } - ) - - if not ngo: - return context - - context.update( - { - "has_ngohub": ngo.ngohub_org_id is not None, + # XXX: Temporarily disabled + "has_ngohub": has_ngohub, + # "has_ngohub": False, # has_ngohub, } ) @@ -221,9 +253,6 @@ def get_context_data(self, **kwargs): def get(self, request, *args, **kwargs): user = request.user - if user.has_perm("users.can_view_old_dashboard"): - return redirect(reverse("admin-ngos")) - if not user.is_authenticated or not user.ngo: return redirect(reverse("contul-meu")) @@ -231,6 +260,127 @@ def get(self, request, *args, **kwargs): return render(request, self.template_name, context) + @method_decorator(login_required(login_url=reverse_lazy("login"))) + def post(self, request, *args, **kwargs): + post = request.POST + user = request.user + + if not user.is_authenticated: + raise PermissionDenied() + + context = self.get_context_data() + + # TODO: move this to two separate pages + # TODO: add all the fields + current_tab = post.get("current-tab", "organization-data") + context["current_tab"] = current_tab + + errors: List[str] = [] + + ngo: Ngo = user.ngo + + must_refresh_prefilled_form = False + is_new_ngo = False + + if not ngo: + is_new_ngo = True + + ngo = Ngo() + + ngo.is_verified = False + ngo.is_active = True + + is_fully_editable = ngo.ngohub_org_id is None + + if is_fully_editable: + registration_number = clean_registration_number(post.get("cif", "")) + registration_number_errors: str = validate_registration_number(ngo, registration_number) + + if registration_number_errors: + errors.append(registration_number_errors) + + vat_information = extract_vat_id(registration_number) + + if ngo.registration_number != vat_information["registration_number"]: + ngo.registration_number = vat_information["registration_number"] + must_refresh_prefilled_form = True + + if ngo.vat_id != vat_information["vat_id"]: + ngo.vat_id = vat_information["vat_id"] + must_refresh_prefilled_form = True + + ngo_name = post.get("name", "").strip() + if ngo.name != ngo_name: + ngo.name = ngo_name + + ngo.phone = post.get("contact-phone", "").strip() + ngo.email = post.get("contact-email", "").strip() + + ngo.website = post.get("website", "").strip() + ngo.address = post.get("address", "").strip() + ngo.county = post.get("county", "").strip() + ngo.active_region = post.get("active-region", "").strip() + + ngo.display_email = post.get("display-email", "").strip() == "on" + ngo.display_phone = post.get("display-phone", "").strip() == "on" + + if errors: + return render(request, self.template_name, context) + + if is_new_ngo: + user.ngo = ngo + user.save() + elif must_refresh_prefilled_form: + async_task("donations.views.ngo_account.delete_prefilled_form", ngo.id) + + return render(request, self.template_name, context) + + +class NgoDetailsView(BaseVisibleTemplateView): + template_name = "ngo-account/organization-data.html" + title = _("Organization details") + + 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( + # { + # "title": "Date organizație", + # "counties": settings.FORM_COUNTIES_NATIONAL, + # "user": user, + # "ngo": ngo, + # "ngo_url": self.request.build_absolute_uri(reverse("twopercent", kwargs={"ngo_url": ngo.slug})), + # } + # ) + # + # if not ngo: + # return context + # + # context.update( + # { + # "has_ngohub": ngo.ngohub_org_id is not None, + # } + # ) + + return context + + # @method_decorator(login_required(login_url=reverse_lazy("login"))) + # def get(self, request, *args, **kwargs): + # user = request.user + # + # if user.has_perm("users.can_view_old_dashboard"): + # return redirect(reverse("admin-ngos")) + # + # if not user.is_authenticated or not user.ngo: + # return redirect(reverse("contul-meu")) + # + # context = self.get_context_data(**kwargs) + # + # return render(request, self.template_name, context) + @method_decorator(login_required(login_url=reverse_lazy("login"))) def post(self, request, *args, **kwargs): post = request.POST @@ -328,7 +478,7 @@ def post(self, request, *args, **kwargs): # Delete the NGO's old prefilled form if must_refresh_prefilled_form: - async_task("donations.views.my_account.delete_prefilled_form", ngo.id) + async_task("donations.views.ngo_account.delete_prefilled_form", ngo.id) if is_new_ngo: user.ngo = ngo diff --git a/backend/donations/views/ngo.py b/backend/donations/views/redirections.py similarity index 100% rename from backend/donations/views/ngo.py rename to backend/donations/views/redirections.py diff --git a/backend/locale/en/LC_MESSAGES/django.po b/backend/locale/en/LC_MESSAGES/django.po index 1b252d65..5075b8fe 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: 2025-01-09 18:25+0200\n" +"POT-Creation-Date: 2025-01-14 12:27+0200\n" "PO-Revision-Date: 2024-02-28 15:45+0000\n" "Last-Translator: Tudor Amariei \n" "Language-Team: English \n" "Language-Team: Romanian {{ county_name }} {% endfor %} -{% endif %} \ No newline at end of file +{% endif %} diff --git a/backend/templates/v2/components/checkbox-input.html b/backend/templates/v2/components/checkbox-input.html deleted file mode 100644 index e7a8507b..00000000 --- a/backend/templates/v2/components/checkbox-input.html +++ /dev/null @@ -1,26 +0,0 @@ -
-
- - - - - - - -
-
- - diff --git a/backend/templates/v2/components/input.html b/backend/templates/v2/components/input.html deleted file mode 100644 index 2ed9e916..00000000 --- a/backend/templates/v2/components/input.html +++ /dev/null @@ -1,51 +0,0 @@ -{% load i18n %} - - diff --git a/backend/templates/v2/components/input/base.html b/backend/templates/v2/components/input/base.html new file mode 100644 index 00000000..99e130ef --- /dev/null +++ b/backend/templates/v2/components/input/base.html @@ -0,0 +1,9 @@ + diff --git a/backend/templates/v2/components/input/checkbox.html b/backend/templates/v2/components/input/checkbox.html new file mode 100644 index 00000000..a921e816 --- /dev/null +++ b/backend/templates/v2/components/input/checkbox.html @@ -0,0 +1,26 @@ +
+
+ + + + + + + +
+
+ + diff --git a/backend/templates/v2/components/input/county.html b/backend/templates/v2/components/input/county.html new file mode 100644 index 00000000..ccd19aac --- /dev/null +++ b/backend/templates/v2/components/input/county.html @@ -0,0 +1,37 @@ +{% extends 'components/input/base.html' %} + +{% block input %} + + + + +{% endblock %} diff --git a/backend/templates/v2/components/input/input.html b/backend/templates/v2/components/input/input.html new file mode 100644 index 00000000..53381f05 --- /dev/null +++ b/backend/templates/v2/components/input/input.html @@ -0,0 +1,16 @@ +{% extends 'components/input/base.html' %} + +{% block input %} + + + +{% endblock %} diff --git a/backend/templates/v2/components/input/textarea.html b/backend/templates/v2/components/input/textarea.html new file mode 100644 index 00000000..caae1786 --- /dev/null +++ b/backend/templates/v2/components/input/textarea.html @@ -0,0 +1,14 @@ +{% extends 'components/input/base.html' %} + +{% block input %} + + + +{% endblock %} diff --git a/backend/templates/v2/form/donation.html b/backend/templates/v2/form/donation.html index ec4eba26..42d89e75 100644 --- a/backend/templates/v2/form/donation.html +++ b/backend/templates/v2/form/donation.html @@ -50,32 +50,32 @@

{% trans "Last name" as input_title %} - {% include "components/input.html" with input_id="last_name" input_type="text" input_name="last_name" input_autocomplete="family-name" is_required=True %} + {% include "components/input/input.html" with input_id="last_name" input_type="text" input_name="last_name" input_autocomplete="family-name" is_required=True %}
{% trans "First name" as input_title %} - {% include "components/input.html" with input_id="first_name" input_type="text" input_name="first_name" input_autocomplete="given-name" is_required=True %} + {% include "components/input/input.html" with input_id="first_name" input_type="text" input_name="first_name" input_autocomplete="given-name" is_required=True %}
{% trans "Father's initial" as input_title %} - {% include "components/input.html" with input_id="initial" input_type="text" input_name="initial" is_required=True %} + {% include "components/input/input.html" with input_id="initial" input_type="text" input_name="initial" is_required=True %}
{% trans "Personal identification number" as input_title %} - {% include "components/input.html" with input_id="cnp" input_type="text" input_name="cnp" is_required=True %} + {% include "components/input/input.html" with input_id="cnp" input_type="text" input_name="cnp" is_required=True %}
{% trans "Email" as input_title %} - {% include "components/input.html" with input_id="email_address" input_type="email" input_name="email_address" input_autocomplete="email" is_required=True %} + {% include "components/input/input.html" with input_id="email_address" input_type="email" input_name="email_address" input_autocomplete="email" is_required=True %}
{% trans "Phone number" as input_title %} - {% include "components/input.html" with input_id="phone_number" input_type="tel" input_name="phone_number" input_autocomplete="tel-national" %} + {% include "components/input/input.html" with input_id="phone_number" input_type="tel" input_name="phone_number" input_autocomplete="tel-national" %}
@@ -90,42 +90,42 @@

{% trans "Street name" as input_title %} - {% include "components/input.html" with input_id="street_name" input_type="text" input_name="street_name" input_autocomplete="address-line1" is_required=True %} + {% include "components/input/input.html" with input_id="street_name" input_type="text" input_name="street_name" input_autocomplete="address-line1" is_required=True %}
{% trans "Number" as input_title %} - {% include "components/input.html" with input_id="street_number" input_type="text" input_name="street_number" is_required=True %} + {% include "components/input/input.html" with input_id="street_number" input_type="text" input_name="street_number" is_required=True %}
{% trans "Flat" as input_title %} - {% include "components/input.html" with input_id="flat" input_type="text" input_name="flat" input_autocomplete="address-line2" %} + {% include "components/input/input.html" with input_id="flat" input_type="text" input_name="flat" input_autocomplete="address-line2" %}
{% trans "Entrance" as input_title %} - {% include "components/input.html" with input_id="entrance" input_type="text" input_name="entrance" input_autocomplete="address-line3" %} + {% include "components/input/input.html" with input_id="entrance" input_type="text" input_name="entrance" input_autocomplete="address-line3" %}
{% trans "Floor" as input_title %} - {% include "components/input.html" with input_id="floor" input_type="text" input_name="floor" input_autocomplete="address-line4" %} + {% include "components/input/input.html" with input_id="floor" input_type="text" input_name="floor" input_autocomplete="address-line4" %}
{% trans "Apartment" as input_title %} - {% include "components/input.html" with input_id="apartment" input_type="text" input_name="apartment" input_autocomplete="address-line5" %} + {% include "components/input/input.html" with input_id="apartment" input_type="text" input_name="apartment" input_autocomplete="address-line5" %}
{% trans "County" as input_title %} - {% include "components/input.html" with input_id="county" input_type="text" input_name="county" input_autocomplete="address-level1" is_required=True %} + {% include "components/input/county.html" with input_id="county" input_name="county" is_required=True %}
{% trans "Locality" as input_title %} - {% include "components/input.html" with input_id="locality" input_type="text" input_name="locality" input_autocomplete="address-level2" is_required=True %} + {% include "components/input/input.html" with input_id="locality" input_type="text" input_name="locality" input_autocomplete="address-level2" is_required=True %}
diff --git a/backend/templates/v2/ngo-account/ngo-form.html b/backend/templates/v2/ngo-account/ngo-form.html index dc115154..262e08e2 100644 --- a/backend/templates/v2/ngo-account/ngo-form.html +++ b/backend/templates/v2/ngo-account/ngo-form.html @@ -1,19 +1,27 @@ {% load i18n %}
-
+ {% csrf_token %} {% include "ngo-account/components/form-title.html" with hide_ngohub_button=True %} -
+
+
- {% trans "Oficial name" as input_title %} - {% include "components/input.html" with input_id="page_name" input_type="text" input_name="page_name" placeholder="Organization name" is_required=True is_disabled=True %} + - {% trans "IBAN on form" as input_title %} - {% include "components/input.html" with input_id="iban" input_type="text" input_name="iban" placeholder="RO001234567812345678" is_required=True %} + {% trans "Titlu formular" as input_title %} + {% include "components/input/input.html" with input_id="page_name" input_type="text" input_name="page_name" placeholder="Organization name" is_required=True is_disabled=True value=ngo.name %} + + {% trans "Form description" as input_title %} + {% include "components/input/textarea.html" with input_id="description" input_title=input_title input_type="textarea" input_name="description" is_required=True value=ngo.description %} + + {% trans "IBAN on form" as input_title %} + {% include "components/input/input.html" with input_id="iban" input_type="text" input_name="iban" placeholder="RO001234567812345678" is_required=True %} + +
+
-
diff --git a/backend/templates/v2/ngo-account/ngo-presentation.html b/backend/templates/v2/ngo-account/ngo-presentation.html index 0db7850b..f012ef3b 100644 --- a/backend/templates/v2/ngo-account/ngo-presentation.html +++ b/backend/templates/v2/ngo-account/ngo-presentation.html @@ -1,77 +1,90 @@ {% load i18n %}
-
+ {% csrf_token %} {% with disable_ngohub_fields=has_ngohub %} {% include "ngo-account/components/form-title.html" %} -
+
+
-
- {% trans "Organization URL" as input_title %} - {% include "components/input.html" with input_id="organization-url" input_title=input_title input_type="text" input_name="organization-url" is_required=true value=ngo.slug %} -
+ -
+
+ {% trans "Organization URL" as input_title %} + {% include "components/input/input.html" with input_id="organization-url" input_title=input_title input_type="text" input_name="organization-url" is_required=true value=ngo.slug %} +
-
- {% trans "Name" as input_title %} - {% include "components/input.html" with input_id="name" input_title=input_title input_type="text" input_name="name" is_required=True is_disabled=disable_ngohub_fields value=ngo.name %} -
+
-
- {% trans "Logo" as input_title %} - {% include "components/input.html" with input_id="logo" input_title=input_title input_type="file" input_name="logo" is_required=True is_disabled=disable_ngohub_fields value=ngo.logo %} -
+
+ {% trans "Name" as input_title %} + {% include "components/input/input.html" with input_id="name" input_title=input_title input_type="text" input_name="name" is_required=True is_disabled=disable_ngohub_fields value=ngo.name %} +
-
- {% trans "Organization description" as input_title %} - {% include "components/input.html" with input_id="description" input_title=input_title input_type="text" input_name="description" is_required=True is_disabled=disable_ngohub_fields value=ngo.description %} -
+
+ {% trans "CUI/CIF" as input_title %} + {% include "components/input/input.html" with input_id="cif" input_title=input_title input_type="text" input_name="cif" is_required=True is_disabled=disable_ngohub_fields value=ngo.full_registration_number %} +
-
- {% trans "Organization website" as input_title %} - {% include "components/input.html" with input_id="website" input_title=input_title input_type="url" input_name="website" is_required=True is_disabled=disable_ngohub_fields value=ngo.website %} -
+
+ {% trans "Logo" as input_title %} + {% include "components/input/input.html" with input_id="logo" input_title=input_title input_type="file" input_name="logo" is_required=True is_disabled=disable_ngohub_fields value=ngo.logo %} +
-
- {% trans "Organization contact e-mail" as input_title %} - {% include "components/input.html" with input_id="contact-email" input_title=input_title input_type="email" input_name="contact-email" is_required=True is_disabled=disable_ngohub_fields value=ngo.email %} -
+
+ {% trans "Organization website" as input_title %} + {% include "components/input/input.html" with input_id="website" input_title=input_title input_type="url" input_name="website" is_required=True is_disabled=disable_ngohub_fields value=ngo.website %} +
-
- {% trans "Display e-mail in the profile" as input_title %} -
- {% include "components/checkbox-input.html" with input_id="display-email" input_title=input_title input_name="display-email" input_value=ngo.display_email %} +
+ {% trans "Organization contact e-mail" as input_title %} + {% include "components/input/input.html" with input_id="contact-email" input_title=input_title input_type="email" input_name="contact-email" is_required=True is_disabled=disable_ngohub_fields value=ngo.email %}
-
-
- {% trans "Organization contact phone" as input_title %} - {% include "components/input.html" with input_id="contact-phone" input_title=input_title input_type="tel" input_name="contact-phone" is_required=True is_disabled=disable_ngohub_fields value=ngo.phone %} -
+
+ {% trans "Display e-mail in the profile" as input_title %} +
+ {% include "components/input/checkbox.html" with input_id="display-email" input_title=input_title input_name="display-email" input_value=ngo.display_email %} +
+
-
- {% trans "Display phone in the profile" as input_title %} -
- {% include "components/checkbox-input.html" with input_id="display-phone" input_title=input_title input_name="display-phone" input_value=ngo.display_email %} +
+ {% trans "Organization contact phone" as input_title %} + {% include "components/input/input.html" with input_id="contact-phone" input_title=input_title input_type="tel" input_name="contact-phone" is_required=True is_disabled=disable_ngohub_fields value=ngo.phone %}
-
-
- {% trans "Organization address" as input_title %} - {% include "components/input.html" with input_id="address" input_title=input_title input_type="text" input_name="address" is_required=True is_disabled=disable_ngohub_fields value=ngo.address %} -
+
+ {% trans "Display phone in the profile" as input_title %} +
+ {% include "components/input/checkbox.html" with input_id="display-phone" input_title=input_title input_name="display-phone" input_value=ngo.display_email %} +
+
-
- {% trans "County" as input_title %} - {% include "components/input.html" with input_id="county" input_title=input_title input_type="text" input_name="county" is_required=True is_disabled=disable_ngohub_fields value=ngo.county %} -
+
+ {% trans "Organization address" as input_title %} + {% include "components/input/input.html" with input_id="address" input_title=input_title input_type="text" input_name="address" is_required=True is_disabled=disable_ngohub_fields value=ngo.address %} +
+ +
+ {% trans "County" as input_title %} + {% include "components/input/county.html" with input_id="county" input_title=input_title input_name="county" is_required=True is_disabled=disable_ngohub_fields value=ngo.county %} +
-
+
+ {% trans "Active region" as input_title %} + {% if has_ngohub %} + {% include "components/input/input.html" with input_id="active-region" input_title=input_title input_type="text" input_name="active-region" is_required=True is_disabled=disable_ngohub_fields value=ngo.active_region %} + {% else %} + {% include "components/input/county.html" with input_id="active-region" input_title=input_title input_name="active-region" is_required=True value=ngo.active_region %} + {% endif %} +
+ +
+
{% endwith %} diff --git a/backend/templates/v2/ngo-account/organization-data.html b/backend/templates/v2/ngo-account/organization-data.html index 7fa1e9b0..c0c723c5 100644 --- a/backend/templates/v2/ngo-account/organization-data.html +++ b/backend/templates/v2/ngo-account/organization-data.html @@ -5,52 +5,54 @@ {% block content %}
-
-

- {% trans "Organization Data" %} -

+

+ {% trans "Organization Data" %} +

-

- {% blocktrans trimmed %} - Fill out the organization's profile on redirectioneaza.ro - {% endblocktrans %} -

+

+ {% blocktrans trimmed %} + Fill out the organization's profile on redirectioneaza.ro + {% endblocktrans %} +

- {% trans "Presentation Data" as tab_presentation %} - {% trans "Form Data" as tab_form %} + {% trans "Presentation Data" as tab_presentation %} + {% trans "Form Data" as tab_form %} -
-
+ +
-
-
+
- {% include "ngo-account/ngo-presentation.html" with title=tab_presentation %} -
+ {% include "ngo-account/ngo-presentation.html" with title=tab_presentation %} +
-
- {% include "ngo-account/ngo-form.html" with title=tab_form %} + {% include "ngo-account/ngo-form.html" with title=tab_form %} +
+
- -
+ {% endwith %}