Added model for special galleries.

This commit is contained in:
Miguel Astor
2026-03-24 15:06:48 -04:00
parent 77d83c58d1
commit 5a6632491a
5 changed files with 122 additions and 3 deletions

27
viewer/models.py Normal file
View File

@@ -0,0 +1,27 @@
from django.utils import timezone
from django.conf import settings
from django.db.models import (
Model,
BooleanField,
DateTimeField,
IntegerField,
FilePathField,
ForeignKey,
CASCADE
)
class Image(Model):
"""
User relations to a specific image file by path.
"""
user = ForeignKey(settings.AUTH_USER_MODEL, blank=False, null=False, on_delete=CASCADE)
path = FilePathField(path=settings.GALLERY_ROOT, blank=False, null=False)
favorite = BooleanField(blank=False, null=False, default=False)
last_visited = DateTimeField(blank=False, null=False, default=timezone.now)
visits = IntegerField(blank=False, null=False, default=0)
class meta:
ordering = ["pk"]
get_latest_by = "-last_visited"