Add field for custom wiki username in database

This commit is contained in:
Tanner Collin 2022-04-28 21:11:56 +00:00
parent 7d85e96b49
commit c2f9295585
4 changed files with 15 additions and 2 deletions

View File

@ -59,6 +59,7 @@ class Member(models.Model):
monthly_fees = models.IntegerField(default=55, blank=True, null=True)
is_allowed_entry = models.BooleanField(default=True)
discourse_username = models.CharField(default='', max_length=40, blank=True, null=True)
mediawiki_username = models.CharField(default='', max_length=40, blank=True, null=True)
allow_last_scanned = models.BooleanField(default=True)
history = HistoricalRecords(excluded_fields=['member_forms'])

View File

@ -208,6 +208,7 @@ class MemberSerializer(serializers.ModelSerializer):
'rabbit_cert_date',
'trotec_cert_date',
'is_allowed_entry',
'mediawiki_username',
]
def update(self, instance, validated_data):
@ -275,6 +276,7 @@ class AdminMemberSerializer(MemberSerializer):
'old_email',
'is_director',
'is_staff',
'mediawiki_username',
]
def update(self, instance, validated_data):
@ -624,6 +626,8 @@ class MyPasswordChangeSerializer(PasswordChangeSerializer):
first_name=self.user.member.first_name,
)
data['username'] = self.user.member.mediawiki_username or self.user.username
if utils_auth.wiki_is_configured():
if request_id: utils_stats.set_progress(request_id, 'Changing Wiki password...')
if utils_auth.set_wiki_password(data) != 200:
@ -687,6 +691,8 @@ class MyPasswordResetConfirmSerializer(PasswordResetConfirmSerializer):
first_name=self.user.member.first_name,
)
data['username'] = self.user.member.mediawiki_username or self.user.username
if utils_auth.wiki_is_configured():
if request_id: utils_stats.set_progress(request_id, 'Changing Wiki password...')
if utils_auth.set_wiki_password(data) != 200:
@ -761,6 +767,7 @@ class SpaceportAuthSerializer(LoginSerializer):
data['email'] = user.email
data['first_name'] = user.member.first_name
data['username'] = user.member.mediawiki_username or user.username
utils_auth.set_wiki_password(data)
data['username'] = user.member.discourse_username or user.username

View File

@ -250,8 +250,13 @@ export function AccountForm(props) {
{...makeProps('emergency_contact_phone')}
/>
{member.mediawiki_username && <div className='field'>
<label>Custom Wiki Username</label>
<p>{member.mediawiki_username}</p>
</div>}
{member.discourse_username && <Form.Input
label='Forum Username'
label='Custom Forum Username'
autoComplete='off'
{...makeProps('discourse_username')}
/>}

View File

@ -110,7 +110,7 @@ export function AuthWiki(props) {
<Header size='small'>Success!</Header>
<p>You can now log into the Wiki:</p>
{user && <p>
Username: {user.username}<br/>
Username: {user.member.mediawiki_username || user.username}<br/>
Password: [this Spaceport password]
</p>}
<p><a href='https://wiki.protospace.ca/index.php?title=Special:UserLogin&returnto=Welcome+to+Protospace' rel='noopener noreferrer'>Protospace Wiki</a></p>