Skip to content
Merged
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
2 changes: 2 additions & 0 deletions memberportal/api_admin_tools/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,8 @@ def put(self, request, member_id):
member.profile.screen_name = body.get("screenName")
member.profile.vehicle_registration_plate = body.get("vehicleRegistrationPlate")
member.profile.exclude_from_email_export = body.get("excludeFromEmailExport")
if config.ENABLE_PRONOUNS:
member.profile.preferred_pronouns = body.get("pronouns")

member.save()
member.profile.save()
Expand Down
8 changes: 7 additions & 1 deletion memberportal/api_general/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ def get(self, request):
"footer": config.SMS_FOOTER,
},
"enableStatsPage": config.ENABLE_STATS_PAGE,
"enablePronouns": config.ENABLE_PRONOUNS,
}

keys = {"stripePublishableKey": config.STRIPE_PUBLISHABLE_KEY}
Expand Down Expand Up @@ -408,6 +409,9 @@ def get(self, request):
"permissions": {"staff": user.is_staff},
}

if config.ENABLE_PRONOUNS:
response["pronouns"] = p.preferred_pronouns

return Response(response)

def put(self, request):
Expand Down Expand Up @@ -443,6 +447,8 @@ def put(self, request):
p.phone = body.get("phone")
p.screen_name = body.get("screenName")
p.vehicle_registration_plate = body.get("vehicleRegistrationPlate")
if config.ENABLE_PRONOUNS:
p.preferred_pronouns = body.get("pronouns")

request.user.save()
p.save()
Expand Down Expand Up @@ -664,7 +670,7 @@ def post(self, request):
first_name=body.get("firstName"),
last_name=body.get("lastName"),
screen_name=body.get("screenName"),
preferred_pronouns=body.get("preferred_pronouns"),
preferred_pronouns=body.get("pronouns"),
phone=body.get("mobile"),
vehicle_registration_plate=body.get("vehicleRegistrationPlate"),
)
Expand Down
5 changes: 5 additions & 0 deletions memberportal/membermatters/constance_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
"",
"A site wide banner that can display useful information. Leave empty to turn off.",
),
"ENABLE_PRONOUNS": (
True,
"Enable optional pronoun fields in profiles.",
),
# Email config
"EMAIL_SYSADMIN": (
"example@example.com",
Expand Down Expand Up @@ -401,6 +405,7 @@
"SITE_NAME",
"SITE_OWNER",
"SITE_LOCALE_CURRENCY",
"ENABLE_PRONOUNS",
"GOOGLE_ANALYTICS_MEASUREMENT_ID",
"SITE_BANNER",
"METRICS_INTERVAL",
Expand Down
7 changes: 5 additions & 2 deletions memberportal/profile/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ class Meta:
first_name = models.CharField("First Name", max_length=30)
last_name = models.CharField("Last Name", max_length=30)
preferred_pronouns = models.CharField(
"Preferred Pronouns", blank=True, null=True, max_length=30
"Pronouns", blank=True, null=True, max_length=30
)
phone_regex = RegexValidator(
regex=r"^\+?1?\d{9,15}$",
Expand Down Expand Up @@ -518,7 +518,7 @@ def get_basic_profile(self):
Returns a user's profile with a basic amount of info.
:return: {}
"""
return {
data = {
"id": self.user.id,
"admin": self.user.is_staff,
"email": self.user.email,
Expand Down Expand Up @@ -560,6 +560,9 @@ def get_basic_profile(self):
},
"subscriptionStatus": self.subscription_status,
}
if config.ENABLE_PRONOUNS:
data["pronouns"] = self.preferred_pronouns
return data

def get_access_permissions(self, ignore_user_state=False):
"""
Expand Down
5 changes: 3 additions & 2 deletions src-frontend/src/components/Account/RegistrationCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,11 @@
]"
/>
<q-input
v-model="form.preferred_pronouns"
v-if="features?.enablePronouns"
v-model="form.pronouns"
class="col-12 col-sm-6"
filled
:label="$t('form.preferred_pronouns')"
:label="$t('form.pronouns')"
/>
<q-input
v-model="form.mobile"
Expand Down
17 changes: 13 additions & 4 deletions src-frontend/src/components/AdminTools/ManageMember.vue
Original file line number Diff line number Diff line change
Expand Up @@ -202,15 +202,21 @@
</q-input>

<q-input
v-model="profileForm.preferred_pronouns"
v-if="
features?.enablePronouns
"
v-model="profileForm.pronouns"
outlined
:debounce="debounceLength"
:label="$t('form.preferred_pronouns')"
@update:model-value="saveChange('preferred_pronouns')"
:label="$t('form.pronouns')"
:rules="[
(val) => validateMax30(val) || $t('validation.max30'),
]"
@update:model-value="saveChange('pronouns')"
>
<template #append>
<saved-notification
:success="saved.preferred_pronouns"
:success="saved.pronouns"
:error="saved.error"
/>
</template>
Expand Down Expand Up @@ -1418,6 +1424,7 @@ export default defineComponent({
rfidCard: '',
firstName: '',
lastName: '',
pronouns: '',
phone: '',
screenName: '',
vehicleRegistrationPlate: '',
Expand All @@ -1430,6 +1437,7 @@ export default defineComponent({
rfidCard: false,
firstName: false,
lastName: false,
pronouns: false,
phone: false,
screenName: false,
vehicleRegistrationPlate: false,
Expand Down Expand Up @@ -1466,6 +1474,7 @@ export default defineComponent({
this.profileForm.rfidCard = this.selectedMember.rfid;
this.profileForm.firstName = this.selectedMember.name.first;
this.profileForm.lastName = this.selectedMember.name.last;
this.profileForm.pronouns = this.selectedMember.pronouns;
this.profileForm.phone = this.selectedMember.phone;
this.profileForm.screenName = this.selectedMember.screenName;
this.profileForm.vehicleRegistrationPlate =
Expand Down
27 changes: 16 additions & 11 deletions src-frontend/src/components/ProfileForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,34 +38,36 @@
</q-input>

<q-input
v-model="form.preferred_pronouns"
v-model="form.lastName"
outlined
:debounce="debounceLength"
:label="$t('form.preferred_pronouns')"
@update:model-value="saveChange('preferred_pronouns')"
:label="$t('form.lastName')"
:rules="[
(val) => validateNotEmpty(val) || $t('validation.cannotBeEmpty'),
]"
@update:model-value="saveChange('lastName')"
>
<template v-slot:append>
<saved-notification
:success="saved.preferred_pronouns"
:success="saved.lastName"
show-text
:error="saved.error"
/>
</template>
</q-input>

<q-input
v-model="form.lastName"
v-if="features?.enablePronouns"
v-model="form.pronouns"
outlined
:debounce="debounceLength"
:label="$t('form.lastName')"
:rules="[
(val) => validateNotEmpty(val) || $t('validation.cannotBeEmpty'),
]"
@update:model-value="saveChange('lastName')"
:label="$t('form.pronouns')"
:rules="[(val) => validateMax30(val) || $t('validation.max30')]"
@update:model-value="saveChange('pronouns')"
>
<template v-slot:append>
<saved-notification
:success="saved.lastName"
:success="saved.pronouns"
show-text
:error="saved.error"
/>
Expand Down Expand Up @@ -149,6 +151,7 @@ export default {
email: '',
firstName: '',
lastName: '',
pronouns: '',
phone: '',
screenName: '',
vehicleRegistrationPlate: '',
Expand All @@ -160,6 +163,7 @@ export default {
email: false,
firstName: false,
lastName: false,
pronouns: false,
phone: false,
screenName: false,
vehicleRegistrationPlate: false,
Expand All @@ -172,6 +176,7 @@ export default {
this.form.email = this.profile.email;
this.form.firstName = this.profile.firstName;
this.form.lastName = this.profile.lastName;
this.form.pronouns = this.profile.pronouns;
this.form.phone = this.profile.phone;
this.form.screenName = this.profile.screenName;
this.form.vehicleRegistrationPlate =
Expand Down
1 change: 1 addition & 0 deletions src-frontend/src/i18n/en-AU/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ export default {
rfidCard: 'RFID Card',
firstName: 'First Name *',
lastName: 'Last Name *',
pronouns: 'Pronouns',
mobile: 'Mobile Number *',
screenName: 'Screen / Nickname *',
date: 'Date',
Expand Down