Compare commits

..

12 Commits

Author SHA1 Message Date
4e953c83ea feat: Add comment field to RescueOrg
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2024-11-09 10:09:46 +01:00
2212df4729 feat: add sex coding 2024-11-09 10:03:04 +01:00
98d67381c6 feat: mark location with fa icon 2024-11-08 08:49:27 +01:00
e02672c2bb feat: Make sure flag stays in line 2024-11-08 08:11:22 +01:00
c3dd9faa85 feat: Use truncated location 2024-11-08 07:42:34 +01:00
9f977e35c2 feat: Use minimal view for listing ANs on index 2024-11-08 07:35:37 +01:00
3269d5a39a feat: add search for text 2024-11-07 23:16:47 +01:00
d96a44bbdd feat: search case-insensitive 2024-11-07 22:13:55 +01:00
2641b2e7bf feat: add search in admin for ANs 2024-11-07 22:01:21 +01:00
50c1a4f2c6 fix: save timestamp 2024-11-07 21:58:12 +01:00
573630f9ee feat: allow filtering and searching rescue orgs 2024-11-07 21:57:58 +01:00
1a09b7859f feat: add e-mail to rescue organization 2024-11-07 21:41:33 +01:00
9 changed files with 82 additions and 9 deletions

View File

@ -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)

View File

@ -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'),
),
]

View File

@ -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'),
),
]

View File

@ -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}"

View File

@ -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 {

View File

@ -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())

View File

@ -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>

View File

@ -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 %}

View File

@ -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 %}