1.1.2 fix dublicates subscribe_for_user

This commit is contained in:
SDE
2024-05-31 13:07:00 +03:00
parent 17024d7350
commit 0e5ed13794
3 changed files with 41 additions and 17 deletions

View File

@@ -46,22 +46,17 @@ class SubscribeOrder(BaseModel):
'user': self.user,
'subscribe': self.subscribe,
'last_paid_DT': datetime.now(),
'paid_period_from_DT': datetime.now(),
'paid_period_to_DT': datetime.now() + timedelta(hours=self.subscribe.period),
'receive_finish_subscribe_msg': True,
'enable': True,
# 'enable': True,
}
subscribe_for_user = SubscribeForUser.objects.create(**kwargs)
from SubscribesApp.funcs import create_subscribe_by_data
subscribe_for_user = create_subscribe_by_data(kwargs)
self.subscribe_for_user = subscribe_for_user
self.enable = False
self.save()
subscribes_for_user = SubscribeForUser.objects.filter(
user=self.user
).exclude(
id=subscribe_for_user.id
)
subscribes_for_user.update(enable=False)
subscribe_for_user.activate()
return self