Link paypal hints when generating users
This commit is contained in:
parent
b4510831f6
commit
cac6a7223f
|
@ -324,7 +324,7 @@ class TrainingViewSet(Base, Retrieve, Create, Update):
|
||||||
user = member.user
|
user = member.user
|
||||||
|
|
||||||
training1 = models.Training.objects.filter(user=user, session=session)
|
training1 = models.Training.objects.filter(user=user, session=session)
|
||||||
if training1.exists()
|
if training1.exists():
|
||||||
raise exceptions.ValidationError(dict(non_field_errors='Already registered.'))
|
raise exceptions.ValidationError(dict(non_field_errors='Already registered.'))
|
||||||
|
|
||||||
self.update_cert(session, member, status)
|
self.update_cert(session, member, status)
|
||||||
|
|
|
@ -25,11 +25,11 @@ print('Generating Users')
|
||||||
count = 0
|
count = 0
|
||||||
|
|
||||||
for member in members:
|
for member in members:
|
||||||
if member.user:
|
|
||||||
continue
|
|
||||||
|
|
||||||
print('Member', member.id, member.first_name, member.last_name)
|
print('Member', member.id, member.first_name, member.last_name)
|
||||||
|
|
||||||
|
if not member.user:
|
||||||
|
print(' No user, generating.')
|
||||||
|
|
||||||
if not member.first_name.isalpha():
|
if not member.first_name.isalpha():
|
||||||
print(' Non-alpha first name.')
|
print(' Non-alpha first name.')
|
||||||
|
|
||||||
|
@ -59,27 +59,27 @@ for member in members:
|
||||||
member.user = user
|
member.user = user
|
||||||
member.save()
|
member.save()
|
||||||
|
|
||||||
x = models.Transaction.objects.filter(member_id=member.id)
|
x = models.Transaction.objects.filter(user=None, member_id=member.id)
|
||||||
x.update(user=user)
|
print(' Linking', x.count(), 'transactions')
|
||||||
print(' Linked', x.count(), 'transactions')
|
x.update(user=member.user)
|
||||||
|
|
||||||
x = models.Card.objects.filter(member_id=member.id)
|
x = models.Card.objects.filter(user=None, member_id=member.id)
|
||||||
x.update(user=user)
|
print(' Linking', x.count(), 'cards')
|
||||||
print(' Linked', x.count(), 'cards')
|
x.update(user=member.user)
|
||||||
|
|
||||||
x = models.Training.objects.filter(member_id=member.id)
|
x = models.Training.objects.filter(user=None, member_id=member.id)
|
||||||
x.update(user=user)
|
print(' Linking', x.count(), 'trainings')
|
||||||
print(' Linked', x.count(), 'trainings')
|
x.update(user=member.user)
|
||||||
|
|
||||||
x = models.PayPalHint.objects.filter(member_id=member.id)
|
x = models.PayPalHint.objects.filter(user=None, member_id=member.id)
|
||||||
x.update(user=user)
|
print(' Linking', x.count(), 'paypal hints')
|
||||||
print(' Linked', x.count(), 'paypal hints')
|
x.update(user=member.user)
|
||||||
|
|
||||||
|
|
||||||
count += 1
|
count += 1
|
||||||
print()
|
print()
|
||||||
|
|
||||||
print('Generated', count, 'users.')
|
print('Processed', count, 'members.')
|
||||||
|
|
||||||
print('Deleting orphan cards...')
|
print('Deleting orphan cards...')
|
||||||
count = models.Card.objects.filter(user__isnull=True).delete()[0]
|
count = models.Card.objects.filter(user__isnull=True).delete()[0]
|
||||||
|
|
Loading…
Reference in New Issue
Block a user