From 64e7f4d8f4c4a34d0193e715ac4baf381b712de3 Mon Sep 17 00:00:00 2001 From: Tanner Collin Date: Thu, 11 Nov 2021 06:05:24 +0000 Subject: [PATCH] Explain when people need to sign up for Spaceport --- apiserver/apiserver/api/serializers.py | 23 ++++++++++++++++++-- webclient/src/LoginSignup.js | 14 ++++++------- webclient/src/PasswordReset.js | 29 ++++++++++++++++++++------ 3 files changed, 51 insertions(+), 15 deletions(-) diff --git a/apiserver/apiserver/api/serializers.py b/apiserver/apiserver/api/serializers.py index c1738bd..ce74f76 100644 --- a/apiserver/apiserver/api/serializers.py +++ b/apiserver/apiserver/api/serializers.py @@ -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): diff --git a/webclient/src/LoginSignup.js b/webclient/src/LoginSignup.js index 73baec9..05ede0c 100644 --- a/webclient/src/LoginSignup.js +++ b/webclient/src/LoginSignup.js @@ -40,11 +40,6 @@ export function LoginForm(props) { >
Log In to Spaceport
- - First time at the new portal? -

Sign up below from Protospace Wi-Fi / computers.

-
- { clearInterval(interval); @@ -161,7 +161,7 @@ export function SignupForm(props) { error={error.email} /> - + {!!bypass_code || - + } +
- + {error.email == 'Not found.' && + + } + + {error.email == 'Not on Spaceport.' && + + Please sign up to the new portal here:
+ + Spaceport Registration + + + } + /> + } Submit