Commit acec89d8 authored by BAIRE Anthony's avatar BAIRE Anthony
Browse files

force model validation on .save()

parent 7a793b87
Pipeline #40277 failed with stage
in 1 minute and 19 seconds
......@@ -32,8 +32,29 @@ def generate_token(length=32):
return get_random_string(length)
class BaseModel(models.Model):
"""Base model for all allgo models
class TimeStampModel(models.Model):
This base class overrides .save() to enforce validation of the model
constraints before creating or updating an entry.
The validation is automatically peformed unless `force_insert` or
`force_update` is true.
see also:
def save(self, force_insert=False, force_update=False, **kw):
if not (force_insert or force_update):
super().save(force_insert, force_update, **kw)
class Meta:
abstract = True
class TimeStampModel(BaseModel):
An abstract base class model that provides self-updating ``created_at`` and
``updated_at`` fields.
......@@ -46,7 +67,7 @@ class TimeStampModel(models.Model):
abstract = True
class AllgoUser(models.Model):
class AllgoUser(BaseModel):
Class linked to the Django user management. If there is a need to add a
field related to a user, it should be added here and not in the auth_user
......@@ -74,7 +95,7 @@ class AllgoUser(models.Model):
return [a.docker_name for a in Webapp.objects.filter(]
class DockerOs(models.Model):
class DockerOs(BaseModel):
Contains the different Operating Systems that a user can choose from to
build its container.
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment