diff --git a/nau_openedx_extensions/custom_registration_form/forms.py b/nau_openedx_extensions/custom_registration_form/forms.py index b26d4078..7953964c 100644 --- a/nau_openedx_extensions/custom_registration_form/forms.py +++ b/nau_openedx_extensions/custom_registration_form/forms.py @@ -1,12 +1,23 @@ """ Nau openedx extension custom forms module """ + from __future__ import absolute_import, unicode_literals +from django import forms from django.forms import ModelForm from django.utils.translation import gettext as _ from nau_openedx_extensions.custom_registration_form.models import NauUserExtendedModel +from nau_openedx_extensions.utils.nif import is_nif_valid + + +def validate_nif(value: str) -> None: + """ + Validate the nif according to the `is_nif_valid` function. + """ + if not is_nif_valid(value): + raise forms.ValidationError(_("Invalid NIF")) class NauUserExtendedForm(ModelForm): @@ -30,6 +41,7 @@ class Meta: "cc_birth_date", "employment_situation", "allow_newsletter", + "nif", ] def __init__(self, *args, **kwargs): @@ -37,3 +49,4 @@ def __init__(self, *args, **kwargs): self.fields["data_authorization"].error_messages = { "required": _("You must read and understood the Privacy Policy") } + self.fields["nif"].validators.append(validate_nif) diff --git a/nau_openedx_extensions/locale/en/LC_MESSAGES/django.mo b/nau_openedx_extensions/locale/en/LC_MESSAGES/django.mo index d6136295..5722addc 100644 Binary files a/nau_openedx_extensions/locale/en/LC_MESSAGES/django.mo and b/nau_openedx_extensions/locale/en/LC_MESSAGES/django.mo differ diff --git a/nau_openedx_extensions/locale/en/LC_MESSAGES/django.po b/nau_openedx_extensions/locale/en/LC_MESSAGES/django.po index 1676fb46..00163d45 100644 --- a/nau_openedx_extensions/locale/en/LC_MESSAGES/django.po +++ b/nau_openedx_extensions/locale/en/LC_MESSAGES/django.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PROJECT VERSION\n" "Report-Msgid-Bugs-To: equipa@nau.edu.pt\n" -"POT-Creation-Date: 2025-07-17 14:36+0100\n" +"POT-Creation-Date: 2025-08-06 10:56-0500\n" "PO-Revision-Date: 2021-02-15 15:56+0000\n" "Last-Translator: FULL NAME \n" "Language: en\n" @@ -30,15 +30,16 @@ msgstr "" msgid "You do not have permission to export certificates for this course." msgstr "" -#: nau_openedx_extensions/custom_registration_form/forms.py:38 -msgid "You must read and understood the Privacy Policy" -msgstr "" - +#: nau_openedx_extensions/custom_registration_form/forms.py:20 #: nau_openedx_extensions/custom_registration_form/models.py:25 #: nau_openedx_extensions/custom_registration_form/models.py:29 msgid "Invalid NIF" msgstr "" +#: nau_openedx_extensions/custom_registration_form/forms.py:50 +msgid "You must read and understood the Privacy Policy" +msgstr "" + #: nau_openedx_extensions/custom_registration_form/models.py:53 msgid "Student" msgstr "" diff --git a/nau_openedx_extensions/locale/pt_PT/LC_MESSAGES/django.mo b/nau_openedx_extensions/locale/pt_PT/LC_MESSAGES/django.mo index 3914b959..bc8f8c5f 100644 Binary files a/nau_openedx_extensions/locale/pt_PT/LC_MESSAGES/django.mo and b/nau_openedx_extensions/locale/pt_PT/LC_MESSAGES/django.mo differ diff --git a/nau_openedx_extensions/locale/pt_PT/LC_MESSAGES/django.po b/nau_openedx_extensions/locale/pt_PT/LC_MESSAGES/django.po index cb6d32fe..7aef938c 100644 --- a/nau_openedx_extensions/locale/pt_PT/LC_MESSAGES/django.po +++ b/nau_openedx_extensions/locale/pt_PT/LC_MESSAGES/django.po @@ -7,17 +7,16 @@ msgid "" msgstr "" "Project-Id-Version: PROJECT VERSION\n" "Report-Msgid-Bugs-To: equipa@nau.edu.pt\n" -"POT-Creation-Date: 2025-07-17 14:36+0100\n" +"POT-Creation-Date: 2025-08-06 10:56-0500\n" "PO-Revision-Date: 2025-07-17 15:32+0100\n" "Last-Translator: Ivo Branco \n" -"Language-Team: pt_PT \n" "Language: pt_PT\n" +"Language-Team: pt_PT \n" +"Plural-Forms: nplurals=2; plural=(n != 1)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" -"Plural-Forms: nplurals=2; plural=(n != 1);\n" "Generated-By: Babel 2.9.0\n" -"X-Generator: Poedit 3.6\n" #: nau_openedx_extensions/certificate_export/views.py:23 msgid "Export task started successfully." @@ -31,15 +30,16 @@ msgstr "O chave do curso fornecida é inválida." msgid "You do not have permission to export certificates for this course." msgstr "Não tem permissão para exportar certificados deste curso." -#: nau_openedx_extensions/custom_registration_form/forms.py:38 -msgid "You must read and understood the Privacy Policy" -msgstr "Deverá ler e compreender a Politica de Privacidade" - +#: nau_openedx_extensions/custom_registration_form/forms.py:20 #: nau_openedx_extensions/custom_registration_form/models.py:25 #: nau_openedx_extensions/custom_registration_form/models.py:29 msgid "Invalid NIF" msgstr "NIF inválido" +#: nau_openedx_extensions/custom_registration_form/forms.py:50 +msgid "You must read and understood the Privacy Policy" +msgstr "Deverá ler e compreender a Politica de Privacidade" + #: nau_openedx_extensions/custom_registration_form/models.py:53 msgid "Student" msgstr "Estudante" @@ -66,9 +66,9 @@ msgstr "Outro" #: nau_openedx_extensions/custom_registration_form/models.py:63 msgid "" -"I have read and understood the Privacy Policy" +"I have read and understood the Privacy " +"Policy" msgstr "" "Li e compreendi a Política de Privacidade" @@ -124,8 +124,8 @@ msgstr "Situação profissional" #: nau_openedx_extensions/custom_registration_form/models.py:103 msgid "Allow newsletter" msgstr "" -"Li e aceito prestar o meu consentimento para o envio de newsletters" #: nau_openedx_extensions/filters/pipeline.py:62 @@ -146,19 +146,19 @@ msgstr "Se achar que se trata de um erro, contacte o suporte." #: nau_openedx_extensions/filters/pipeline.py:76 #, python-format msgid "" -"You can't enroll on this course because your email domain is not " -"allowed. %(custom_message)s" +"You can't enroll on this course because your email domain is not allowed." +" %(custom_message)s" msgstr "" "Não pode inscrever-se neste curso porque o seu domínio de e-mail não é " "permitido. %(custom_message)s" #: nau_openedx_extensions/filters/pipeline.py:128 msgid "" -"You need to associate Autenticação Gov to your account or add NIF to " -"your account." +"You need to associate Autenticação Gov to your account or add NIF to your" +" account." msgstr "" -"É necessário associar a Autenticação Gov à sua conta ou adicionar o NIF " -"à sua conta." +"É necessário associar a Autenticação Gov à sua conta ou adicionar o NIF à" +" sua conta." #: nau_openedx_extensions/filters/pipeline.py:204 msgid "CSV export task started successfully!" @@ -218,8 +218,8 @@ msgid "" "Download a CSV file with the details of all certificates generated for " "this course." msgstr "" -"Descarregar um ficheiro CSV com os detalhes dos certificados gerados " -"para este curso." +"Descarregar um ficheiro CSV com os detalhes dos certificados gerados para" +" este curso." #: nau_openedx_extensions/templates/certificate_export/certificate_export.html:18 msgid "Export certificates CSVs" @@ -253,30 +253,25 @@ msgstr "Informação" msgid "Warning" msgstr "Aviso" -#: nau_openedx_extensions/templates/message_gateway/tab.html:15 -msgid "Send to:" -msgstr "Enviar para:" +#: nau_openedx_extensions/utils/admin.py:63 +msgid "Export Selected to CSV" +msgstr "Exportar selecionados para CSV" -#: nau_openedx_extensions/templates/message_gateway/tab.html:24 -msgid "Myself" -msgstr "Para mim" +#~ msgid "Send to:" +#~ msgstr "Enviar para:" -#: nau_openedx_extensions/templates/message_gateway/tab.html:33 -msgid "Staff and Administrators" -msgstr "Equipa e Administradores" +#~ msgid "Myself" +#~ msgstr "Para mim" -#: nau_openedx_extensions/templates/message_gateway/tab.html:42 -msgid "All Learners" -msgstr "Todos os estudantes" +#~ msgid "Staff and Administrators" +#~ msgstr "Equipa e Administradores" -#: nau_openedx_extensions/templates/message_gateway/tab.html:47 -msgid "Message:" -msgstr "Mensagem:" +#~ msgid "All Learners" +#~ msgstr "Todos os estudantes" -#: nau_openedx_extensions/templates/message_gateway/tab.html:57 -msgid "Send Message" -msgstr "Enviar Mensagem" +#~ msgid "Message:" +#~ msgstr "Mensagem:" + +#~ msgid "Send Message" +#~ msgstr "Enviar Mensagem" -#: nau_openedx_extensions/utils/admin.py:63 -msgid "Export Selected to CSV" -msgstr "Exportar selecionados para CSV" diff --git a/nau_openedx_extensions/settings/common.py b/nau_openedx_extensions/settings/common.py index d8473c81..00ad6e4a 100644 --- a/nau_openedx_extensions/settings/common.py +++ b/nau_openedx_extensions/settings/common.py @@ -57,9 +57,9 @@ def plugin_settings(settings): settings.NAU_CERTIFICATE_CONTEXT_EXTENSION = ( "nau_openedx_extensions.certificates.context_extender.update_cert_context" ) - settings.NAU_STUDENT_ACCOUNT_CONTEXT_EXTENSION = "nau_openedx_extensions.custom_registration_form.context_extender.update_account_view" - settings.NAU_STUDENT_SERIALIZER_CONTEXT_EXTENSION = "nau_openedx_extensions.custom_registration_form.context_extender.update_account_serializer" - settings.NAU_STUDENT_ACCOUNT_PARTIAL_UPDATE = "nau_openedx_extensions.custom_registration_form.context_extender.partial_update" + settings.NAU_STUDENT_ACCOUNT_CONTEXT_EXTENSION = "" + settings.NAU_STUDENT_SERIALIZER_CONTEXT_EXTENSION = "" + settings.NAU_STUDENT_ACCOUNT_PARTIAL_UPDATE = "" settings.NAU_COURSEWARE_MODULE = ( "nau_openedx_extensions.edxapp_wrapper.backends.courseware_h_v1" ) diff --git a/nau_openedx_extensions/utils/nif.py b/nau_openedx_extensions/utils/nif.py index c6660479..b641f42c 100644 --- a/nau_openedx_extensions/utils/nif.py +++ b/nau_openedx_extensions/utils/nif.py @@ -37,6 +37,10 @@ def controlNIF(nif): # verificar tamanho do número passado if len(nif) != LEN_NIF: return False + + if not nif.isdigit(): + return False + # verificar validade do carácter inicial do NIF # if nif[0] not in "125689": # return False