feat: Add basic flow to add adoption notices
This commit is contained in:
parent
8488768687
commit
0943ecae62
23
src/fellchensammlung/forms.py
Normal file
23
src/fellchensammlung/forms.py
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
from django import forms
|
||||||
|
from .models import AdoptionNotice, Animal
|
||||||
|
|
||||||
|
|
||||||
|
class DateInput(forms.DateInput):
|
||||||
|
input_type = 'date'
|
||||||
|
|
||||||
|
|
||||||
|
class AdoptionNoticeForm(forms.ModelForm):
|
||||||
|
class Meta:
|
||||||
|
model = AdoptionNotice
|
||||||
|
fields = ['name', "group_only", "further_information", "description", "searching_since"]
|
||||||
|
widgets = {
|
||||||
|
'searching_since': DateInput(),
|
||||||
|
}
|
||||||
|
|
||||||
|
class AnimalForm(forms.ModelForm):
|
||||||
|
class Meta:
|
||||||
|
model = Animal
|
||||||
|
fields = ['name', "species", "sex", "date_of_birth", "description", "photos"]
|
||||||
|
widgets = {
|
||||||
|
'date_of_birth': DateInput(),
|
||||||
|
}
|
100
src/fellchensammlung/migrations/0001_initial.py
Normal file
100
src/fellchensammlung/migrations/0001_initial.py
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
# Generated by Django 5.0.3 on 2024-03-19 16:31
|
||||||
|
|
||||||
|
import datetime
|
||||||
|
import django.db.models.deletion
|
||||||
|
from django.conf import settings
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
initial = True
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='Location',
|
||||||
|
fields=[
|
||||||
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('name', models.CharField(max_length=200)),
|
||||||
|
('postcode', models.CharField(max_length=200)),
|
||||||
|
('country', models.CharField(choices=[('DE', 'Germany'), ('AT', 'Austria'), ('CH', 'Switzerland')], max_length=20)),
|
||||||
|
('description', models.TextField(blank=True, null=True, verbose_name='Description')),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='MarkdownContent',
|
||||||
|
fields=[
|
||||||
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('title', models.CharField(max_length=100)),
|
||||||
|
('content', models.TextField()),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'verbose_name_plural': 'Markdown content',
|
||||||
|
},
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='Species',
|
||||||
|
fields=[
|
||||||
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('name', models.CharField(help_text='Enter a animal species', max_length=200, verbose_name='Name')),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'verbose_name': 'Species',
|
||||||
|
'verbose_name_plural': 'Species',
|
||||||
|
},
|
||||||
|
),
|
||||||
|
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.CreateModel(
|
||||||
|
name='RescueOrganization',
|
||||||
|
fields=[
|
||||||
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('name', models.CharField(max_length=200)),
|
||||||
|
('trusted', models.BooleanField(default=False, verbose_name='Trusted')),
|
||||||
|
('instagram', models.URLField(blank=True, null=True, verbose_name='Instagram profile')),
|
||||||
|
('facebook', models.URLField(blank=True, null=True, verbose_name='Facebook profile')),
|
||||||
|
('fediverse_profile', models.URLField(blank=True, null=True, verbose_name='Fediverse profile')),
|
||||||
|
('website', models.URLField(blank=True, null=True, verbose_name='Website')),
|
||||||
|
('location', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='fellchensammlung.location')),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='AdoptionNotice',
|
||||||
|
fields=[
|
||||||
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('created_at', models.DateField(default=datetime.datetime.now, verbose_name='Created at')),
|
||||||
|
('searching_since', models.DateField(verbose_name='Searching for a home since')),
|
||||||
|
('name', models.CharField(max_length=200)),
|
||||||
|
('description', models.TextField(blank=True, null=True, verbose_name='Description')),
|
||||||
|
('further_information', models.URLField(blank=True, null=True, verbose_name='Link to further information')),
|
||||||
|
('group_only', models.BooleanField(default=False, verbose_name='Only group adoption')),
|
||||||
|
('photos', models.ManyToManyField(blank=True, to='fellchensammlung.image')),
|
||||||
|
('organization', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='fellchensammlung.rescueorganization', verbose_name='Organization')),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='Animal',
|
||||||
|
fields=[
|
||||||
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('date_of_birth', models.DateField(verbose_name='Date of birth')),
|
||||||
|
('name', models.CharField(max_length=200)),
|
||||||
|
('description', models.TextField(blank=True, null=True, verbose_name='Description')),
|
||||||
|
('sex', models.CharField(choices=[('M_N', 'male_neutered'), ('M', 'male'), ('F_N', 'female_neutered'), ('F', 'female')], max_length=20)),
|
||||||
|
('adoption_notice', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='fellchensammlung.adoptionnotice')),
|
||||||
|
('photos', models.ManyToManyField(blank=True, to='fellchensammlung.image')),
|
||||||
|
('species', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='fellchensammlung.species')),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
]
|
@ -0,0 +1,13 @@
|
|||||||
|
{% extends "fellchensammlung/base_generic.html" %}
|
||||||
|
{% load i18n %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<h1>Vermitteln</h1>
|
||||||
|
Hier kannst du jetzt einzelne Tiere zu deiner Vermittlung hinzufügen. Lad auch gerne Fotos hoch. Gruppenfotos kannst du im nächsten Schritt hochladen.
|
||||||
|
<form method = "post" enctype="multipart/form-data">
|
||||||
|
{% csrf_token %}
|
||||||
|
{{ form.as_p }}
|
||||||
|
<button name="button_add_another_animal" type="submit">Speichern und nächstes Tier hinzufügen</button>
|
||||||
|
<button name="button_save_and_continue" type="submit">Speichern und weiter</button>
|
||||||
|
</form>
|
||||||
|
{% endblock %}
|
Loading…
Reference in New Issue
Block a user