Compare commits
No commits in common. "53098f8adcf085fdb0e8ff058a3035bd2d4977a3" and "4984159a61642a0d3668e85daf39472b59b86447" have entirely different histories.
53098f8adc
...
4984159a61
|
@ -8,7 +8,6 @@ import pytz
|
|||
import datetime
|
||||
import copy
|
||||
|
||||
from django.contrib.auth.models import User
|
||||
from django.utils.timezone import make_aware
|
||||
from django.db import transaction
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
|
@ -24,7 +23,7 @@ from note.models import Note, NoteClub
|
|||
from activity.models import Guest, GuestTransaction, Entry
|
||||
|
||||
from member.models import Membership
|
||||
from treasury.models import Remittance, SpecialTransactionProxy, SogeCredit
|
||||
from treasury.models import Remittance, SpecialTransactionProxy
|
||||
from ._import_utils import ImportCommand, BulkCreateManager, timed
|
||||
|
||||
MAP_TRANSACTION = dict()
|
||||
|
@ -368,30 +367,6 @@ class Command(ImportCommand):
|
|||
except:
|
||||
print("Failed to save row: " + str(row))
|
||||
|
||||
@timed
|
||||
def import_soge_credits(self):
|
||||
users = User.objects.filter(profile__registration_valid=True).order_by('pk')
|
||||
n = users.count()
|
||||
for idx, user in enumerate(users.all()):
|
||||
self.update_line(idx, n, user.username)
|
||||
soge_credit_transaction = SpecialTransaction.objects.filter(
|
||||
reason__icontains="crédit sogé",
|
||||
destination_id=user.note.id,
|
||||
)
|
||||
if soge_credit_transaction.exists():
|
||||
soge_credit_transaction = soge_credit_transaction.get()
|
||||
soge_credit = SogeCredit.objects.create(user=user, credit_transaction=soge_credit_transaction)
|
||||
memberships = Membership.objects.filter(
|
||||
user=user,
|
||||
club_id__in=[BDE_PK, KFET_PK],
|
||||
date_start__lte=soge_credit_transaction.created_at,
|
||||
date_end__gte=soge_credit_transaction.created_at + datetime.timedelta(days=61),
|
||||
).all()
|
||||
for membership in memberships:
|
||||
soge_credit.transactions.add(membership.transaction)
|
||||
soge_credit.save()
|
||||
|
||||
|
||||
@timed
|
||||
def handle(self, *args, **kwargs):
|
||||
# default args, provided by ImportCommand.
|
||||
|
@ -408,4 +383,3 @@ class Command(ImportCommand):
|
|||
self.set_roles()
|
||||
self.import_remittances(cur, kwargs["chunk"])
|
||||
self.import_checks(cur)
|
||||
self.import_soge_credits()
|
||||
|
|
Loading…
Reference in New Issue