Skip to content
Snippets Groups Projects
Commit ae1eeca6 authored by Marte Fossum's avatar Marte Fossum
Browse files

Add tests and frontend

parent 4505dad3
No related branches found
No related tags found
1 merge request!351Add support for SO numbers
Pipeline #160449 failed
This commit is part of merge request !351. Comments created here will be created in the context of that merge request.
......@@ -12,6 +12,7 @@
"lastName": "Last name",
"dateOfBirth": "Date of birth",
"nationalIdNumber": "National ID number",
"nationalIdNumberSo": "National ID number",
"roleType": "Role",
"roleStartDate": "From",
"roleEndDate": "To (including)",
......@@ -174,6 +175,7 @@
"guestRegisterWizardText": {
"identityHeader": "Identify yourself ",
"identityBody": "Enter your Norwegian national identity number if you have one. <1>Otherwise</1> use passport information.",
"identityBody_soNumber": "Enter your Norwegian national identity number if you have one. SO-number is a valid identity number. <1>Otherwise</1> use passport information.",
"yourContactInformation": "Your contact information",
"contactInformationDescription": "Fill in missing fields",
"yourGuestPeriod": "Your guest period",
......
......@@ -12,6 +12,7 @@
"lastName": "Etternavn",
"dateOfBirth": "Fødselsdato",
"nationalIdNumber": "Fødselsnummer/D-nummer",
"nationalIdNumberSo": "Fødselsnummer/D-nummer/SO-nummer",
"roleType": "Gjesterolle",
"roleStartDate": "Fra",
"roleEndDate": "Til og med",
......@@ -174,6 +175,7 @@
"guestRegisterWizardText": {
"identityHeader": "Identifiser deg ",
"identityBody": "Fyll inn ditt norske fødselsnummer hvis du har. <1>Eller</1> nasjonalitet og passnummer.",
"identityBody_soNumber": "Fyll inn ditt norske fødselsnummer hvis du har, SO-nummer er gyldig ID-nummer. <1>Eller</1> nasjonalitet og passnummer.",
"yourContactInformation": "Din kontaktinfo",
"contactInformationDescription": "Fyll inn manglende informasjon",
"yourGuestPeriod": "Din gjesteperiode",
......
......@@ -12,6 +12,7 @@
"lastName": "Etternamn",
"dateOfBirth": "Fødselsdato",
"nationalIdNumber": "Fødselsnummer/D-nummer",
"nationalIdNumberSo": "Fødselsnummer/D-nummer/SO-nummer",
"roleType": "Gjesterolle",
"roleStartDate": "Frå",
"roleEndDate": "Til og med",
......@@ -174,6 +175,7 @@
"guestRegisterWizardText": {
"identityHeader": "Identifiser deg ",
"identityBody": "Fyll inn enten ditt norske fødselsnummer, om du har det, <1>eller</1> nasjonalitet og passnummer.",
"identityBody_soNumber": "Fyll inn enten ditt norske fødselsnummer, om du har det, SO-nummer er gyldig ID-nummer. <1>Eller</1> nasjonalitet og passnummer.",
"yourContactInformation": "Din kontaktinformasjon",
"contactInformationDescription": "Fyll inn manglande informasjon",
"yourGuestPeriod": "Din gjesteperiode",
......
......@@ -71,3 +71,5 @@ const sentryProjectId: string = env.REACT_APP_SENTRY_PROJECT_ID as string
const sentryHost: string = env.REACT_APP_SENTRY_HOST as string
export const sentryEnabled: boolean = sentryHost !== undefined
export const sentryDsn: string = `https://${sentryPublicKey}@${sentryHost}/${sentryProjectId}`
export const allowSoNumbers: boolean = false
......@@ -33,6 +33,7 @@ import {
extractGenderOrBlank,
extractBirthdateFromNationalId,
} from 'utils'
import { allowSoNumbers } from 'appConfig'
import { GuestInviteInformation } from '../guestDataForm'
import { GuestRegisterData } from '../enteredGuestData'
import { GuestRegisterCallableMethods } from '../guestRegisterCallableMethods'
......@@ -574,7 +575,7 @@ const GuestRegisterStep = forwardRef(
{t('guestRegisterWizardText.identityHeader')}
</Typography>
<Typography>
<Trans i18nKey="common:guestRegisterWizardText.identityBody">
<Trans i18nKey="common:guestRegisterWizardText.identityBody" context={ allowSoNumbers ? "soNumber": ""}>
Enter national identity number if you have one.
<strong>Otherwise</strong> use passport information.
</Trans>
......@@ -593,7 +594,7 @@ const GuestRegisterStep = forwardRef(
render={({ field }) => (
<TextField
id="nationalIdNumber"
label={t('input.nationalIdNumber')}
label={allowSoNumbers ? t('input.nationalIdNumberSo'): t('input.nationalIdNumber')}
error={!!errors.nationalIdNumber}
value={field.value}
onChange={field.onChange}
......
from greg.utils import is_valid_id_number, is_valid_so_number
from django.conf import settings
def test_so_number():
so_number = "25529312345"
settings.ALLOW_SO_NUMBERS = True
assert is_valid_id_number(so_number)
assert is_valid_so_number(so_number)
def test_not_allow_so_number():
so_number = "25529312345"
settings.ALLOW_SO_NUMBERS = False
assert is_valid_id_number(so_number) == False
assert is_valid_so_number(so_number) == False
def test_not_valid_so_number():
so_number = "25529322345"
settings.ALLOW_SO_NUMBERS = True
assert is_valid_id_number(so_number) == False
assert is_valid_so_number(so_number) == False
......@@ -40,9 +40,8 @@ def is_valid_so_number(input_digits: str) -> bool:
return False
if month > 50:
SO_NUMBER = True
month -= 50
input_digits = day + str(month) + year + pnr
month = _check_month(month)
input_digits = day + month + year + pnr
return SO_NUMBER and _check_birthdate(input_digits, is_dnumber=False)
......@@ -89,6 +88,13 @@ def _check_birthdate(digits: str, is_dnumber: bool) -> bool:
return True
def _check_month(month: int) -> str:
month -= 50
if month < 10:
return "0" + str(month)
return str(month)
def _compute_checksum(input_digits: str) -> bool:
d = [int(s) for s in input_digits]
k1 = 11 - (
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment