Explain when people need to sign up for Spaceport

master
Tanner Collin 3 years ago
parent b8dc5467d8
commit 64e7f4d8f4
  1. 23
      apiserver/apiserver/api/serializers.py
  2. 14
      webclient/src/LoginSignup.js
  3. 29
      webclient/src/PasswordReset.js

@ -84,6 +84,21 @@ class TransactionSerializer(serializers.ModelSerializer):
member = get_object_or_404(models.Member, id=validated_data['member_id'])
if member.user:
validated_data['user'] = member.user
if validated_data['account_type'] != 'Clearing':
if validated_data['amount'] == 0:
raise ValidationError(dict(account_type='You can\'t have a $0 {} transaction. Do you want "Membership Adjustment"?'.format(validated_data['account_type'])))
elif validated_data['amount'] < 0.1:
raise ValidationError(dict(amount='Don\'t try and trick me.'))
if validated_data['account_type'] == 'PayPal':
msg = 'Manual PayPal transaction added:\n' + str(validated_data)
utils.alert_tanner(msg)
if validated_data['account_type'] in ['Interac', 'Dream Pmt', 'Square Pmt', 'PayPal']:
if not validated_data.get('reference_number', None):
raise ValidationError(dict(reference_number='This field is required.'))
return super().create(validated_data)
def update(self, instance, validated_data):
@ -632,8 +647,12 @@ class MyPasswordChangeSerializer(PasswordChangeSerializer):
class MyPasswordResetSerializer(PasswordResetSerializer):
def validate_email(self, email):
if not User.objects.filter(email__iexact=email).exists():
logging.info('Email not found: ' + email)
raise ValidationError('Not found.')
if models.Member.objects.filter(old_email__iexact=email).exists():
logging.info('Email hasn\'t migrated to Spaceport yet: ' + email)
raise ValidationError('Not on Spaceport.')
else:
logging.info('Email not found: ' + email)
raise ValidationError('Not found.')
return super().validate_email(email)
def save(self):

@ -40,11 +40,6 @@ export function LoginForm(props) {
>
<Header size='medium'>Log In to Spaceport</Header>
<Message warning>
<Message.Header>First time at the new portal?</Message.Header>
<p>Sign up below from Protospace Wi-Fi / computers.</p>
</Message>
<Form.Input
label='Username'
name='username'
@ -109,6 +104,11 @@ export function SignupForm(props) {
const interval = setInterval(getStatus, 500);
const data = { ...input, email: input.email.toLowerCase(), bypass_code: bypass_code, request_id: request_id };
if (bypass_code) {
data.existing_member = true;
}
requester('/registration/', 'POST', '', data)
.then(res => {
clearInterval(interval);
@ -161,7 +161,7 @@ export function SignupForm(props) {
error={error.email}
/>
<Form.Group grouped>
{!!bypass_code || <Form.Group grouped>
<Form.Radio
label='I have an account on the old portal'
name='existing_member'
@ -178,7 +178,7 @@ export function SignupForm(props) {
onChange={handleValues}
error={!!error.existing_member}
/>
</Form.Group>
</Form.Group>}
<Form.Input
label='Password'

@ -37,7 +37,7 @@ function ResetForm() {
});
return (
<Form onSubmit={handleSubmit} error={error.email == 'Not found.'}>
<Form onSubmit={handleSubmit} error={!!error.email}>
<Form.Input
label='Email'
name='email'
@ -45,11 +45,28 @@ function ResetForm() {
error={error.email}
/>
<Message
error
header='Email not found in Spaceport'
content='Ask a director if you forgot which one you used.'
/>
{error.email == 'Not found.' &&
<Message
error
header='Email not found in Spaceport'
content='Ask a director if you forgot which one you used.'
/>
}
{error.email == 'Not on Spaceport.' &&
<Message
error
header={'You haven\'t registered to Spaceport yet'}
content={
<>
Please sign up to the new portal here:<br />
<Link to='/#outside-protospace-15c7b5'>
Spaceport Registration
</Link>
</>
}
/>
}
<Form.Button loading={loading} error={error.non_field_errors}>
Submit

Loading…
Cancel
Save