feat: Add image basics
This commit is contained in:
parent
57a483df24
commit
15e1d65089
@ -33,6 +33,7 @@ dependencies = [
|
||||
"whitenoise",
|
||||
"model_bakery",
|
||||
"markdown",
|
||||
"Pillow",
|
||||
]
|
||||
dynamic = ["version", "readme"]
|
||||
|
||||
|
@ -0,0 +1,36 @@
|
||||
# Generated by Django 5.0.3 on 2024-03-18 16:08
|
||||
|
||||
import django.db.models.deletion
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('fellchensammlung', '0003_markdowncontent'),
|
||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Image',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('title', models.CharField(max_length=200)),
|
||||
('image', models.ImageField(upload_to='images')),
|
||||
('alt_text', models.TextField(max_length=2000)),
|
||||
('uploaded_by', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
|
||||
],
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='adoptionnotice',
|
||||
name='photos',
|
||||
field=models.ManyToManyField(blank=True, to='fellchensammlung.image'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='animal',
|
||||
name='photos',
|
||||
field=models.ManyToManyField(blank=True, to='fellchensammlung.image'),
|
||||
),
|
||||
]
|
@ -1,7 +1,18 @@
|
||||
from django.db import models
|
||||
from django.contrib.auth.models import User
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
|
||||
class Image(models.Model):
|
||||
title = models.CharField(max_length=200)
|
||||
image = models.ImageField(upload_to='images')
|
||||
alt_text = models.TextField(max_length=2000)
|
||||
uploaded_by = models.ForeignKey(User, on_delete=models.CASCADE)
|
||||
|
||||
def __str__(self):
|
||||
return self.title
|
||||
|
||||
|
||||
class Species(models.Model):
|
||||
"""Model representing a species of animal."""
|
||||
name = models.CharField(max_length=200, help_text=_('Enter a animal species'),
|
||||
@ -56,6 +67,7 @@ class Animal(models.Model):
|
||||
name = models.CharField(max_length=200)
|
||||
description = models.TextField(null=True, blank=True, verbose_name=_('Description'))
|
||||
species = models.ForeignKey(Species, on_delete=models.PROTECT)
|
||||
photos = models.ManyToManyField(Image, blank=True)
|
||||
|
||||
|
||||
class AdoptionNotice(models.Model):
|
||||
@ -71,6 +83,7 @@ class AdoptionNotice(models.Model):
|
||||
further_information = models.URLField(null=True, blank=True, verbose_name=_('Link to further information'))
|
||||
group_only = models.BooleanField(default=False, verbose_name=_('Only group adoption'))
|
||||
animals = models.ManyToManyField(Animal)
|
||||
photos = models.ManyToManyField(Image, blank=True)
|
||||
|
||||
|
||||
class MarkdownContent(models.Model):
|
||||
@ -85,4 +98,3 @@ class MarkdownContent(models.Model):
|
||||
|
||||
def __str__(self):
|
||||
return self.title
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user