Skip to content

Commit

Permalink
fixup! ✨(dashboard) move core abstract model in models.py
Browse files Browse the repository at this point in the history
  • Loading branch information
ssorin committed Nov 22, 2024
1 parent da71533 commit 7516200
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 35 deletions.
3 changes: 1 addition & 2 deletions src/dashboard/apps/consent/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
from django.utils.translation import gettext_lazy as _

from apps.auth.models import DashboardUser as User
from apps.core.base import DashboardBase
from apps.core.models import DeliveryPoint
from apps.core.models import DashboardBase, DeliveryPoint


class Consent(DashboardBase):
Expand Down
32 changes: 0 additions & 32 deletions src/dashboard/apps/core/base.py

This file was deleted.

28 changes: 27 additions & 1 deletion src/dashboard/apps/core/models.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,37 @@
"""Dashboard core app models."""

import uuid

from django.db import models
from django.utils import timezone
from django.utils.translation import gettext_lazy as _

from apps.auth.models import DashboardUser as User

from .base import DashboardBase

class DashboardBase(models.Model):
"""Abstract base model, providing common fields and functionality.
Attributes:
- id (UUIDField): serves as the primary key, automatically generated, not editable.
- created_at (DateTimeField): records when the object was created, not editable by
default.
- updated_at (DateTimeField): records when the object was last updated, editable.
"""

id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
created_at = models.DateTimeField(
_("created at"), editable=False, default=timezone.now
)
updated_at = models.DateTimeField(_("updated at"), null=True, blank=True)

class Meta: # noqa: D106
abstract = True

def save(self, *args, **kwargs):
"""Update the updated_at timestamps."""
self.updated_at = timezone.now()
return super(DashboardBase, self).save(*args, **kwargs)


class Entity(DashboardBase):
Expand Down

0 comments on commit 7516200

Please sign in to comment.