def registration_request_action(action='deny'): if not current_user.is_authenticated() or not current_user.is_admin: return api_alert_response('Access Denied.', 400, 'danger') if action not in ['approve', 'deny']: return api_alert_response('Invalid action.', 400, 'danger') email = request.args['email'] registration_request = UserRegistrationRequest.get_by_email(email) if not registration_request: return api_alert_response('Unable to find registration.', 400, 'danger') return reply_registration_request(registration_request, action)
def validate_email(form, field): if User.get_by_email(field.data): raise ValidationError("This email is already registered") if UserRegistrationRequest.get_by_email(field.data): raise ValidationError("Registration already requested for this email.")