Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions nau_openedx_extensions/custom_registration_form/forms.py
Original file line number Diff line number Diff line change
@@ -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):
Expand All @@ -30,10 +41,12 @@ class Meta:
"cc_birth_date",
"employment_situation",
"allow_newsletter",
"nif",
]

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.fields["data_authorization"].error_messages = {
"required": _("You must read and understood the Privacy Policy")
}
self.fields["nif"].validators.append(validate_nif)
Binary file modified nau_openedx_extensions/locale/en/LC_MESSAGES/django.mo
Binary file not shown.
11 changes: 6 additions & 5 deletions nau_openedx_extensions/locale/en/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -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 <EMAIL@ADDRESS>\n"
"Language: en\n"
Expand All @@ -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 ""
Expand Down
Binary file modified nau_openedx_extensions/locale/pt_PT/LC_MESSAGES/django.mo
Binary file not shown.
79 changes: 37 additions & 42 deletions nau_openedx_extensions/locale/pt_PT/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -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 <ivo.branco@fccn.pt>\n"
"Language-Team: pt_PT <LL@li.org>\n"
"Language: pt_PT\n"
"Language-Team: pt_PT <LL@li.org>\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."
Expand All @@ -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"
Expand All @@ -66,9 +66,9 @@ msgstr "Outro"

#: nau_openedx_extensions/custom_registration_form/models.py:63
msgid ""
"I have read and understood the <a href='https://www.nau.edu.pt/legal/"
"politica-de-privacidade/' rel='noopener' target='_blank'>Privacy Policy</"
"a>"
"I have read and understood the <a href='https://www.nau.edu.pt/legal"
"/politica-de-privacidade/' rel='noopener' target='_blank'>Privacy "
"Policy</a>"
msgstr ""
"Li e compreendi a <a href='https://www.nau.edu.pt/legal/politica-de-"
"privacidade/' rel='noopener' target='_blank'>Política de Privacidade</a>"
Expand Down Expand Up @@ -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 <a target='_blank' href='https://"
"www.nau.edu.pt/legal/consentimento-para-o-envio-de-"
"Li e aceito prestar o meu <a target='_blank' "
"href='https://www.nau.edu.pt/legal/consentimento-para-o-envio-de-"
"newsletters/'>consentimento para o envio de newsletters</a>"

#: nau_openedx_extensions/filters/pipeline.py:62
Expand All @@ -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!"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
6 changes: 3 additions & 3 deletions nau_openedx_extensions/settings/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
4 changes: 4 additions & 0 deletions nau_openedx_extensions/utils/nif.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down