ckeditor added and single bird help

This commit is contained in:
gw3000 2023-07-20 20:18:11 +02:00
parent a8196bc5c9
commit 371ecda4cc
7 changed files with 34 additions and 9 deletions

View file

@ -18,7 +18,7 @@ class FallenBirdAdmin(admin.ModelAdmin):
@admin.register(Bird) @admin.register(Bird)
class BirdAdmin(admin.ModelAdmin): class BirdAdmin(admin.ModelAdmin):
list_display = ["name", "description"] list_display = ["name"]
@admin.register(BirdStatus) @admin.register(BirdStatus)

View file

@ -2,6 +2,7 @@ from datetime import date
from uuid import uuid4 from uuid import uuid4
from aviary.models import Aviary from aviary.models import Aviary
from ckeditor.fields import RichTextField
from django.conf import settings from django.conf import settings
from django.db import models from django.db import models
from django.utils.translation import gettext_lazy as _ from django.utils.translation import gettext_lazy as _
@ -59,9 +60,9 @@ class FallenBird(models.Model):
class Bird(models.Model): class Bird(models.Model):
id = models.UUIDField(primary_key=True, default=uuid4, editable=False) id = models.BigAutoField(primary_key=True)
name = models.CharField(max_length=256, unique=True, verbose_name=_("Bezeichnung")) name = models.CharField(max_length=256, unique=True, verbose_name=_("Bezeichnung"))
description = models.CharField(max_length=4096, verbose_name=_("Hilfetext")) description = RichTextField(blank=True, null=True)
class Meta: class Meta:
verbose_name = _("Vogel") verbose_name = _("Vogel")

View file

@ -4,10 +4,14 @@
<div class="row"> <div class="row">
<div class="col-lg-8 mb-3"> <div class="col-lg-8 mb-3">
<h3>Hilfesammlung</h3> <h3>Hilfesammlung</h3>
{% for bird in birds %} <ul>
<h4>{{ bird.name }}</h4> {% for bird in birds %}
<p>{{ bird.description }}</p> <li>
{% endfor %} <a href="{% url 'bird_help_single' bird.id %}">{{ bird.name }}</a>
</li>
{% endfor %}
</ul>
</div> </div>
</div> </div>
{% endblock content %} {% endblock content %}

View file

@ -0,0 +1,10 @@
{% extends "base.html" %}
{% load static %}
{% block content %}
<div class="row">
<div class="col-lg-8 mb-3">
<h3>{{ bird.name }}</h3>
<p>{{ bird.description|safe }}</p>
</div>
</div>
{% endblock content %}

View file

@ -5,6 +5,7 @@ from .views import (
bird_create, bird_create,
bird_delete, bird_delete,
bird_help, bird_help,
bird_help_single,
bird_inactive, bird_inactive,
bird_recover, bird_recover,
bird_recover_all, bird_recover_all,
@ -17,6 +18,7 @@ urlpatterns = [
path("create/", bird_create, name="bird_create"), path("create/", bird_create, name="bird_create"),
path("delete/<id>", bird_delete, name="bird_delete"), path("delete/<id>", bird_delete, name="bird_delete"),
path("help/", bird_help, name="bird_help"), path("help/", bird_help, name="bird_help"),
path("help/<id>", bird_help_single, name="bird_help_single"),
path("recover/<id>", bird_recover, name="bird_recover"), path("recover/<id>", bird_recover, name="bird_recover"),
path("recover/all", bird_recover_all, name="bird_recover_all"), path("recover/all", bird_recover_all, name="bird_recover_all"),
path("<id>/", bird_single, name="bird_single"), path("<id>/", bird_single, name="bird_single"),

View file

@ -36,11 +36,18 @@ def bird_create(request):
@login_required(login_url="account_login") @login_required(login_url="account_login")
def bird_help(request): def bird_help(request):
birds = Bird.objects.all() birds = Bird.objects.all().order_by("name")
context = {"birds": birds} context = {"birds": birds}
return render(request, "bird/bird_help.html", context) return render(request, "bird/bird_help.html", context)
@login_required(login_url="account_login")
def bird_help_single(request, id):
bird = Bird.objects.all().get(id=id)
context = {"bird": bird}
return render(request, "bird/bird_help_single.html", context)
@login_required(login_url="account_login") @login_required(login_url="account_login")
def bird_all(request): def bird_all(request):
birds = FallenBird.objects.filter(Q(status="1") | Q(status="2")).annotate( birds = FallenBird.objects.filter(Q(status="1") | Q(status="2")).annotate(

View file

@ -3,6 +3,7 @@ crispy-bootstrap5>=0.6
django-allauth>=0.50 django-allauth>=0.50
django-bootstrap-datepicker-plus>=4.0 django-bootstrap-datepicker-plus>=4.0
django-bootstrap-modal-forms>=2 django-bootstrap-modal-forms>=2
django-ckeditor>=6.6
django-crispy-forms>=1 django-crispy-forms>=1
django-environ==0.9.0 django-environ==0.9.0
django-environ>=0.9 django-environ>=0.9
@ -10,4 +11,4 @@ django-jazzmin>=2.6.0
gunicorn>=20.1 gunicorn>=20.1
names>=0.3.0 names>=0.3.0
psycopg2-binary>=2.9 psycopg2-binary>=2.9
whitenoise>=6.5 whitenoise>=6.5