Skip to content

Commit

Permalink
Fix: make the social_insurance_number field optional.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mahmoud-Emad committed Mar 12, 2024
1 parent 1705d1b commit 2d18ccd
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 14 deletions.
5 changes: 1 addition & 4 deletions client/src/components/AddUser.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

<v-text-field v-model="address" label="Address" density="comfortable" :rules="addressRules"></v-text-field>
<v-text-field v-model="social_insurance_number" label="Social Insurance Number" type="number"
density="comfortable" :rules="socialInsuranceRules"></v-text-field>
density="comfortable"></v-text-field>
</v-col>
<v-col cols="6">
<v-text-field v-model="telegram_link" label="Telegram" density="comfortable"
Expand Down Expand Up @@ -83,14 +83,12 @@ import {
mobileRules,
jobRules,
addressRules,
socialInsuranceRules,
telegramRules,
requiredStringRules,
requiredRules
} from '@/utils'
import { formatDate } from '@/utils'
import { useAsyncState } from '@vueuse/core'
import { ApiClientBase } from '@/clients/api/base'
export default {
name: 'AddUser',
Expand Down Expand Up @@ -254,7 +252,6 @@ export default {
mobileRules,
jobRules,
addressRules,
socialInsuranceRules,
telegramRules,
requiredStringRules,
requiredRules,
Expand Down
4 changes: 1 addition & 3 deletions client/src/components/UpdateUser.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
<v-text-field v-model="selectedUser.address" label="Address" density="comfortable"
:rules="addressRules"></v-text-field>
<v-text-field v-model="selectedUser.social_insurance_number" label="Social Insurance Number" type="number"
density="comfortable" :rules="socialInsuranceRules"></v-text-field>
density="comfortable"></v-text-field>
</v-col>
<v-col cols="6" v-if="selectedUser">
<v-text-field v-model="selectedUser.telegram_link" label="Telegram" density="comfortable"
Expand Down Expand Up @@ -110,7 +110,6 @@ import {
mobileRules,
jobRules,
addressRules,
socialInsuranceRules,
telegramRules,
requiredStringRules,
requiredRules,
Expand Down Expand Up @@ -282,7 +281,6 @@ export default {
addressRules,
supervisorPage,
supervisorCount,
socialInsuranceRules,
telegramRules,
requiredStringRules,
requiredRules,
Expand Down
12 changes: 6 additions & 6 deletions client/src/utils/validators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ export const addressRules = [
(v: string) =>
(v && v.length >= 3 && v.length <= 50) || 'Address must be between 3 and 50 characters.'
]
export const socialInsuranceRules = [
(v: string) => typeof v === 'string' || 'Social Number must be a string.',
(v: string) => !!v || 'Social Number is required.',
(v: string) =>
(v && v.length >= 3 && v.length <= 50) || 'Social Number must be between 3 and 50 characters.'
]
// export const socialInsuranceRules = [
// (v: string) => typeof v === 'string' || 'Social Number must be a string.',
// (v: string) => !!v || 'Social Number is required.',
// (v: string) =>
// (v && v.length >= 3 && v.length <= 50) || 'Social Number must be between 3 and 50 characters.'
// ]
export const telegramRules = [
(v: string) => typeof v === 'string' || 'Telegram must be a string.',
(v: string) => !!v || 'Telegram is required.',
Expand Down
2 changes: 1 addition & 1 deletion server/cshr/models/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class User(AbstractBaseUser, TimeStamp):
skills = models.ManyToManyField(UserSkills, related_name="skills", blank=True)
user_type = models.CharField(max_length=20, choices=USER_TYPE.choices)
gender = models.CharField(max_length=20, choices=GENDER_TYPE.choices)
social_insurance_number = models.CharField(max_length=45)
social_insurance_number = models.CharField(max_length=45, null=True, blank=True)
address = models.CharField(max_length=150)
job_title = models.CharField(max_length=150)
USERNAME_FIELD = "email"
Expand Down

0 comments on commit 2d18ccd

Please sign in to comment.