Compare commits
12 Commits
70b3ae4bbc
...
4e953c83ea
Author | SHA1 | Date | |
---|---|---|---|
4e953c83ea | |||
2212df4729 | |||
98d67381c6 | |||
e02672c2bb | |||
c3dd9faa85 | |||
9f977e35c2 | |||
3269d5a39a | |||
d96a44bbdd | |||
2641b2e7bf | |||
50c1a4f2c6 | |||
573630f9ee | |||
1a09b7859f |
@ -2,7 +2,7 @@ from django.contrib.auth.admin import UserAdmin as BaseUserAdmin
|
||||
from django.contrib import admin
|
||||
from django.utils.html import format_html
|
||||
|
||||
from .models import User, Language, Text, ReportComment, ReportAdoptionNotice, Log
|
||||
from .models import User, Language, Text, ReportComment, ReportAdoptionNotice, Log, Timestamp
|
||||
|
||||
from .models import Animal, Species, RescueOrganization, AdoptionNotice, Location, Rule, Image, ModerationAction, \
|
||||
Comment, Report, Announcement, AdoptionNoticeStatus, User, Subscriptions
|
||||
@ -14,6 +14,7 @@ class StatusInline(admin.StackedInline):
|
||||
|
||||
@admin.register(AdoptionNotice)
|
||||
class AdoptionNoticeAdmin(admin.ModelAdmin):
|
||||
search_fields = ("name__icontains", "description__icontains")
|
||||
inlines = [
|
||||
StatusInline,
|
||||
]
|
||||
@ -50,16 +51,27 @@ class ReportAdoptionNoticeAdmin(admin.ModelAdmin):
|
||||
reported_content_link.short_description = "Reported Content"
|
||||
|
||||
|
||||
@admin.register(RescueOrganization)
|
||||
class RescueOrganizationAdmin(admin.ModelAdmin):
|
||||
search_fields = ("name__icontains",)
|
||||
list_display = ("name", "trusted", "allows_using_materials", "website")
|
||||
list_filter = ("allows_using_materials", "trusted",)
|
||||
|
||||
|
||||
@admin.register(Text)
|
||||
class TextAdmin(admin.ModelAdmin):
|
||||
search_fields = ("title__icontains", "text_code__icontains",)
|
||||
|
||||
|
||||
admin.site.register(Animal)
|
||||
admin.site.register(Species)
|
||||
admin.site.register(RescueOrganization)
|
||||
admin.site.register(Location)
|
||||
admin.site.register(Rule)
|
||||
admin.site.register(Image)
|
||||
admin.site.register(ModerationAction)
|
||||
admin.site.register(Language)
|
||||
admin.site.register(Text)
|
||||
admin.site.register(Announcement)
|
||||
admin.site.register(AdoptionNoticeStatus)
|
||||
admin.site.register(Subscriptions)
|
||||
admin.site.register(Log)
|
||||
admin.site.register(Timestamp)
|
||||
|
@ -0,0 +1,18 @@
|
||||
# Generated by Django 5.1.1 on 2024-11-07 20:41
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('fellchensammlung', '0013_alter_log_user'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='rescueorganization',
|
||||
name='email',
|
||||
field=models.EmailField(blank=True, max_length=254, null=True, verbose_name='E-Mail'),
|
||||
),
|
||||
]
|
@ -0,0 +1,18 @@
|
||||
# Generated by Django 5.1.1 on 2024-11-09 09:09
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('fellchensammlung', '0014_rescueorganization_email'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='rescueorganization',
|
||||
name='comment',
|
||||
field=models.TextField(blank=True, null=True, verbose_name='Kommentar'),
|
||||
),
|
||||
]
|
@ -121,6 +121,10 @@ class Location(models.Model):
|
||||
def __str__(self):
|
||||
return f"{self.name} ({self.latitude:.5}, {self.longitude:.5})"
|
||||
|
||||
@property
|
||||
def str_hr(self):
|
||||
return f"{self.name.split(',')[0]}"
|
||||
|
||||
@staticmethod
|
||||
def get_location_from_string(location_string):
|
||||
geo_api = geo.GeoAPI()
|
||||
@ -177,9 +181,11 @@ class RescueOrganization(models.Model):
|
||||
instagram = models.URLField(null=True, blank=True, verbose_name=_('Instagram Profil'))
|
||||
facebook = models.URLField(null=True, blank=True, verbose_name=_('Facebook Profil'))
|
||||
fediverse_profile = models.URLField(null=True, blank=True, verbose_name=_('Fediverse Profil'))
|
||||
email = models.EmailField(null=True, blank=True, verbose_name=_('E-Mail'))
|
||||
website = models.URLField(null=True, blank=True, verbose_name=_('Website'))
|
||||
updated_at = models.DateTimeField(auto_now=True)
|
||||
created_at = models.DateTimeField(auto_now_add=True)
|
||||
comment = models.TextField(verbose_name=_("Kommentar"), null=True, blank=True,)
|
||||
|
||||
|
||||
class AdoptionNotice(models.Model):
|
||||
@ -212,6 +218,24 @@ class AdoptionNotice(models.Model):
|
||||
def animals(self):
|
||||
return Animal.objects.filter(adoption_notice=self)
|
||||
|
||||
@property
|
||||
def sexes(self):
|
||||
sexes = set()
|
||||
for animal in self.animals:
|
||||
sexes.update(animal.sex)
|
||||
return sexes
|
||||
|
||||
def sex_code(self):
|
||||
if len(self.sexes) > 1:
|
||||
return "mixed"
|
||||
elif self.sexes.pop() == Animal.MALE:
|
||||
return "male"
|
||||
elif self.sexes.pop() == Animal.FEMALE:
|
||||
return "female"
|
||||
else:
|
||||
return "mixed"
|
||||
|
||||
|
||||
@property
|
||||
def comments(self):
|
||||
return Comment.objects.filter(adoption_notice=self)
|
||||
@ -416,7 +440,6 @@ class AdoptionNoticeStatus(models.Model):
|
||||
self.save()
|
||||
|
||||
|
||||
|
||||
class Animal(models.Model):
|
||||
MALE_NEUTERED = "M_N"
|
||||
MALE = "M"
|
||||
@ -560,7 +583,6 @@ class ModerationAction(models.Model):
|
||||
private_comment = models.TextField(blank=True)
|
||||
report = models.ForeignKey(Report, on_delete=models.CASCADE)
|
||||
|
||||
|
||||
def __str__(self):
|
||||
return f"[{self.action}]: {self.public_comment}"
|
||||
|
||||
|
@ -452,11 +452,13 @@ select, .button {
|
||||
.card h1 {
|
||||
color: var(--text-three);
|
||||
text-shadow: 1px 1px var(--shadow-three);
|
||||
width: 85%;
|
||||
}
|
||||
|
||||
.card h2 {
|
||||
color: var(--text-three);
|
||||
text-shadow: 1px 1px var(--shadow-three);
|
||||
width: 85%;
|
||||
}
|
||||
|
||||
.card img {
|
||||
|
@ -9,6 +9,7 @@ def set_timestamp(key: str):
|
||||
try:
|
||||
ts = Timestamp.objects.get(key=key)
|
||||
ts.timestamp = timezone.now()
|
||||
ts.save()
|
||||
except Timestamp.DoesNotExist:
|
||||
Timestamp.objects.create(key=key, timestamp=timezone.now())
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
<div class="container-cards">
|
||||
{% if adoption_notices %}
|
||||
{% for adoption_notice in adoption_notices %}
|
||||
{% include "fellchensammlung/partials/partial-adoption-notice.html" %}
|
||||
{% include "fellchensammlung/partials/partial-adoption-notice-minimal.html" %}
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
<p>{% translate "Keine Vermittlungen gefunden." %}</p>
|
||||
|
@ -10,9 +10,9 @@
|
||||
class="fa-solid fa-flag"></i></a>
|
||||
</div>
|
||||
<p>
|
||||
<b>Ort</b>
|
||||
<b><i class="fa-solid fa-location-dot"></i></b>
|
||||
{% if adoption_notice.location %}
|
||||
{{ adoption_notice.location }}
|
||||
{{ adoption_notice.location.str_hr }}
|
||||
{% else %}
|
||||
{{ adoption_notice.location_string }}
|
||||
{% endif %}
|
||||
|
@ -14,7 +14,7 @@
|
||||
<p>
|
||||
<b>Ort</b>
|
||||
{% if adoption_notice.location %}
|
||||
{{ adoption_notice.location }}
|
||||
{{ adoption_notice.location.str_hr }}
|
||||
{% else %}
|
||||
{{ adoption_notice.location_string }}
|
||||
{% endif %}
|
||||
|
Loading…
Reference in New Issue
Block a user