new model fields & migrations for apps.epic & apps.lyric; new FTs, ITs & UTs passing
; some styling changes effected primarily to _gatekeetper.html modal
This commit is contained in:
@@ -93,13 +93,30 @@ def create_gate_slots(sender, instance, created, **kwargs):
|
||||
GateSlot.objects.create(room=instance, slot_number=i)
|
||||
|
||||
|
||||
def select_token(user):
|
||||
if user.is_staff:
|
||||
pass_token = user.tokens.filter(token_type=Token.PASS).first()
|
||||
if pass_token:
|
||||
return pass_token
|
||||
coin = user.tokens.filter(token_type=Token.COIN, current_room__isnull=True).first()
|
||||
if coin:
|
||||
return coin
|
||||
free = user.tokens.filter(
|
||||
token_type=Token.FREE,
|
||||
expires_at__gt=timezone.now(),
|
||||
).order_by("expires_at").first()
|
||||
if free:
|
||||
return free
|
||||
return user.tokens.filter(token_type=Token.TITHE).first()
|
||||
|
||||
|
||||
def debit_token(user, slot, token):
|
||||
if token.token_type == Token.COIN:
|
||||
token.current_room = slot.room
|
||||
period = slot.room.renewal_period or timedelta(days=7)
|
||||
token.next_ready_at = timezone.now() + period
|
||||
token.save()
|
||||
else:
|
||||
elif token.token_type != Token.PASS:
|
||||
token.delete()
|
||||
slot.gamer = user
|
||||
slot.status = GateSlot.FILLED
|
||||
|
||||
Reference in New Issue
Block a user