summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSunil Shetye2025-03-04 15:21:55 +0530
committerSunil Shetye2025-03-04 15:21:55 +0530
commitcd79a435e83a5d079dadf92d952691ac57b6d28e (patch)
tree0ff1585b16331ec63d40e0b01616e68855c84273
parent1bf031e8b7943bb24a8c841e2cff1c4316b58f0d (diff)
downloadCommon-Interface-Project-cd79a435e83a5d079dadf92d952691ac57b6d28e.tar.gz
Common-Interface-Project-cd79a435e83a5d079dadf92d952691ac57b6d28e.tar.bz2
Common-Interface-Project-cd79a435e83a5d079dadf92d952691ac57b6d28e.zip
check expire_at also
-rw-r--r--blocks/simulationAPI/models.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/blocks/simulationAPI/models.py b/blocks/simulationAPI/models.py
index 63be2eed..0da06972 100644
--- a/blocks/simulationAPI/models.py
+++ b/blocks/simulationAPI/models.py
@@ -28,13 +28,19 @@ class Session(models.Model):
return
old_instance = old_instances.first()
- if old_instance.app_name == self.app_name:
+ if old_instance.app_name == self.app_name and old_instance.expire_at > timezone.now():
self.count += 1
- kwargs['update_fields'] = ['count']
+ kwargs['update_fields'] = {'count'}
super().save(*args, **kwargs)
return
- raise ValidationError("mismatch: Cannot update app name.")
+ if old_instance.app_name != self.app_name:
+ raise ValidationError("mismatch: Cannot update app name.")
+
+ if old_instance.expire_at <= timezone.now():
+ raise ValidationError("mismatch: Cannot update expired session.")
+
+ raise ValidationError("mismatch: Cannot update.")
def __str__(self):
return self.session_id