add icon field to platform, use everywhere

This commit is contained in:
2024-09-14 11:07:38 +02:00
parent c40764a02f
commit b0b1bb2d42
13 changed files with 152 additions and 78 deletions

View File

@ -3,6 +3,7 @@ from datetime import timedelta
from django.core.exceptions import ValidationError
from django.db import models
from django.db.models import F, Sum
from django.template.defaultfilters import slugify
from django.utils import timezone
from common.time import format_duration
@ -25,11 +26,17 @@ class Game(models.Model):
class Platform(models.Model):
name = models.CharField(max_length=255)
group = models.CharField(max_length=255, null=True, blank=True, default=None)
icon = models.SlugField(blank=True)
created_at = models.DateTimeField(auto_now_add=True)
def __str__(self):
return self.name
def save(self, *args, **kwargs):
if not self.icon:
self.icon = slugify(self.name)
super().save(*args, **kwargs)
class Edition(models.Model):
class Meta: