Representation of an image in the admin view

This commit is contained in:
reverend 2022-12-25 12:20:13 +01:00
parent b0d9c46eb2
commit 8c06ce09fa
1 changed files with 22 additions and 1 deletions

View File

@ -1,7 +1,12 @@
import uuid
from django.db import models from django.db import models
from django.core.exceptions import ValidationError from django.core.exceptions import ValidationError
from django.utils.translation import gettext as _ from django.utils.translation import gettext as _
def get_uuid():
return str(uuid.uuid4())
class Visitor(models.Model): class Visitor(models.Model):
""" """
Stores information about a visitor of this application. Stores information about a visitor of this application.
@ -10,7 +15,8 @@ class Visitor(models.Model):
""" """
session_id = models.CharField( session_id = models.CharField(
_('A cookie set by this application to identify a visitor by session'), _('A cookie set by this application to identify a visitor by session'),
max_length=50 max_length=50,
default=get_uuid
) )
name = models.CharField( name = models.CharField(
_('Human readable, self assigned name of the visitor'), _('Human readable, self assigned name of the visitor'),
@ -67,6 +73,13 @@ class Image(models.Model):
An image contains the path to the image file and several information An image contains the path to the image file and several information
like description, uploader and affiliation to galleries. like description, uploader and affiliation to galleries.
""" """
title = models.CharField(
_('Title of the image'),
max_length=100,
null=True,
blank=True
)
description = models.TextField( description = models.TextField(
_('An optional description of the Image'), _('An optional description of the Image'),
null=True null=True
@ -105,3 +118,11 @@ class Image(models.Model):
related_name='images' related_name='images'
) )
def __str__(self):
if self.title:
return self.title
elif self.description:
return self.description[:100]
else:
return super.__str__()