ckeditor added and single bird help
This commit is contained in:
parent
a8196bc5c9
commit
371ecda4cc
7 changed files with 34 additions and 9 deletions
|
@ -18,7 +18,7 @@ class FallenBirdAdmin(admin.ModelAdmin):
|
|||
|
||||
@admin.register(Bird)
|
||||
class BirdAdmin(admin.ModelAdmin):
|
||||
list_display = ["name", "description"]
|
||||
list_display = ["name"]
|
||||
|
||||
|
||||
@admin.register(BirdStatus)
|
||||
|
|
|
@ -2,6 +2,7 @@ from datetime import date
|
|||
from uuid import uuid4
|
||||
|
||||
from aviary.models import Aviary
|
||||
from ckeditor.fields import RichTextField
|
||||
from django.conf import settings
|
||||
from django.db import models
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
@ -59,9 +60,9 @@ class FallenBird(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"))
|
||||
description = models.CharField(max_length=4096, verbose_name=_("Hilfetext"))
|
||||
description = RichTextField(blank=True, null=True)
|
||||
|
||||
class Meta:
|
||||
verbose_name = _("Vogel")
|
||||
|
|
|
@ -4,10 +4,14 @@
|
|||
<div class="row">
|
||||
<div class="col-lg-8 mb-3">
|
||||
<h3>Hilfesammlung</h3>
|
||||
{% for bird in birds %}
|
||||
<h4>{{ bird.name }}</h4>
|
||||
<p>{{ bird.description }}</p>
|
||||
{% endfor %}
|
||||
<ul>
|
||||
{% for bird in birds %}
|
||||
<li>
|
||||
<a href="{% url 'bird_help_single' bird.id %}">{{ bird.name }}</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock content %}
|
10
app/bird/templates/bird/bird_help_single.html
Normal file
10
app/bird/templates/bird/bird_help_single.html
Normal 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 %}
|
|
@ -5,6 +5,7 @@ from .views import (
|
|||
bird_create,
|
||||
bird_delete,
|
||||
bird_help,
|
||||
bird_help_single,
|
||||
bird_inactive,
|
||||
bird_recover,
|
||||
bird_recover_all,
|
||||
|
@ -17,6 +18,7 @@ urlpatterns = [
|
|||
path("create/", bird_create, name="bird_create"),
|
||||
path("delete/<id>", bird_delete, name="bird_delete"),
|
||||
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/all", bird_recover_all, name="bird_recover_all"),
|
||||
path("<id>/", bird_single, name="bird_single"),
|
||||
|
|
|
@ -36,11 +36,18 @@ def bird_create(request):
|
|||
|
||||
@login_required(login_url="account_login")
|
||||
def bird_help(request):
|
||||
birds = Bird.objects.all()
|
||||
birds = Bird.objects.all().order_by("name")
|
||||
context = {"birds": birds}
|
||||
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")
|
||||
def bird_all(request):
|
||||
birds = FallenBird.objects.filter(Q(status="1") | Q(status="2")).annotate(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue