Compare commits

..

No commits in common. "4e953c83eac1c9ec1c2fba8c522c58739fd05e0c" and "70b3ae4bbc54a7f92701e48a15450610c52c829c" have entirely different histories.

9 changed files with 9 additions and 82 deletions

View File

@ -2,7 +2,7 @@ from django.contrib.auth.admin import UserAdmin as BaseUserAdmin
from django.contrib import admin from django.contrib import admin
from django.utils.html import format_html from django.utils.html import format_html
from .models import User, Language, Text, ReportComment, ReportAdoptionNotice, Log, Timestamp from .models import User, Language, Text, ReportComment, ReportAdoptionNotice, Log
from .models import Animal, Species, RescueOrganization, AdoptionNotice, Location, Rule, Image, ModerationAction, \ from .models import Animal, Species, RescueOrganization, AdoptionNotice, Location, Rule, Image, ModerationAction, \
Comment, Report, Announcement, AdoptionNoticeStatus, User, Subscriptions Comment, Report, Announcement, AdoptionNoticeStatus, User, Subscriptions
@ -14,7 +14,6 @@ class StatusInline(admin.StackedInline):
@admin.register(AdoptionNotice) @admin.register(AdoptionNotice)
class AdoptionNoticeAdmin(admin.ModelAdmin): class AdoptionNoticeAdmin(admin.ModelAdmin):
search_fields = ("name__icontains", "description__icontains")
inlines = [ inlines = [
StatusInline, StatusInline,
] ]
@ -51,27 +50,16 @@ class ReportAdoptionNoticeAdmin(admin.ModelAdmin):
reported_content_link.short_description = "Reported Content" 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(Animal)
admin.site.register(Species) admin.site.register(Species)
admin.site.register(RescueOrganization)
admin.site.register(Location) admin.site.register(Location)
admin.site.register(Rule) admin.site.register(Rule)
admin.site.register(Image) admin.site.register(Image)
admin.site.register(ModerationAction) admin.site.register(ModerationAction)
admin.site.register(Language) admin.site.register(Language)
admin.site.register(Text)
admin.site.register(Announcement) admin.site.register(Announcement)
admin.site.register(AdoptionNoticeStatus) admin.site.register(AdoptionNoticeStatus)
admin.site.register(Subscriptions) admin.site.register(Subscriptions)
admin.site.register(Log) admin.site.register(Log)
admin.site.register(Timestamp)

View File

@ -1,18 +0,0 @@
# 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

@ -1,18 +0,0 @@
# 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,10 +121,6 @@ class Location(models.Model):
def __str__(self): def __str__(self):
return f"{self.name} ({self.latitude:.5}, {self.longitude:.5})" return f"{self.name} ({self.latitude:.5}, {self.longitude:.5})"
@property
def str_hr(self):
return f"{self.name.split(',')[0]}"
@staticmethod @staticmethod
def get_location_from_string(location_string): def get_location_from_string(location_string):
geo_api = geo.GeoAPI() geo_api = geo.GeoAPI()
@ -181,11 +177,9 @@ class RescueOrganization(models.Model):
instagram = models.URLField(null=True, blank=True, verbose_name=_('Instagram Profil')) instagram = models.URLField(null=True, blank=True, verbose_name=_('Instagram Profil'))
facebook = models.URLField(null=True, blank=True, verbose_name=_('Facebook Profil')) facebook = models.URLField(null=True, blank=True, verbose_name=_('Facebook Profil'))
fediverse_profile = models.URLField(null=True, blank=True, verbose_name=_('Fediverse 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')) website = models.URLField(null=True, blank=True, verbose_name=_('Website'))
updated_at = models.DateTimeField(auto_now=True) updated_at = models.DateTimeField(auto_now=True)
created_at = models.DateTimeField(auto_now_add=True) created_at = models.DateTimeField(auto_now_add=True)
comment = models.TextField(verbose_name=_("Kommentar"), null=True, blank=True,)
class AdoptionNotice(models.Model): class AdoptionNotice(models.Model):
@ -218,24 +212,6 @@ class AdoptionNotice(models.Model):
def animals(self): def animals(self):
return Animal.objects.filter(adoption_notice=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 @property
def comments(self): def comments(self):
return Comment.objects.filter(adoption_notice=self) return Comment.objects.filter(adoption_notice=self)
@ -440,6 +416,7 @@ class AdoptionNoticeStatus(models.Model):
self.save() self.save()
class Animal(models.Model): class Animal(models.Model):
MALE_NEUTERED = "M_N" MALE_NEUTERED = "M_N"
MALE = "M" MALE = "M"
@ -583,6 +560,7 @@ class ModerationAction(models.Model):
private_comment = models.TextField(blank=True) private_comment = models.TextField(blank=True)
report = models.ForeignKey(Report, on_delete=models.CASCADE) report = models.ForeignKey(Report, on_delete=models.CASCADE)
def __str__(self): def __str__(self):
return f"[{self.action}]: {self.public_comment}" return f"[{self.action}]: {self.public_comment}"

View File

@ -452,13 +452,11 @@ select, .button {
.card h1 { .card h1 {
color: var(--text-three); color: var(--text-three);
text-shadow: 1px 1px var(--shadow-three); text-shadow: 1px 1px var(--shadow-three);
width: 85%;
} }
.card h2 { .card h2 {
color: var(--text-three); color: var(--text-three);
text-shadow: 1px 1px var(--shadow-three); text-shadow: 1px 1px var(--shadow-three);
width: 85%;
} }
.card img { .card img {

View File

@ -9,7 +9,6 @@ def set_timestamp(key: str):
try: try:
ts = Timestamp.objects.get(key=key) ts = Timestamp.objects.get(key=key)
ts.timestamp = timezone.now() ts.timestamp = timezone.now()
ts.save()
except Timestamp.DoesNotExist: except Timestamp.DoesNotExist:
Timestamp.objects.create(key=key, timestamp=timezone.now()) Timestamp.objects.create(key=key, timestamp=timezone.now())

View File

@ -2,7 +2,7 @@
<div class="container-cards"> <div class="container-cards">
{% if adoption_notices %} {% if adoption_notices %}
{% for adoption_notice in adoption_notices %} {% for adoption_notice in adoption_notices %}
{% include "fellchensammlung/partials/partial-adoption-notice-minimal.html" %} {% include "fellchensammlung/partials/partial-adoption-notice.html" %}
{% endfor %} {% endfor %}
{% else %} {% else %}
<p>{% translate "Keine Vermittlungen gefunden." %}</p> <p>{% translate "Keine Vermittlungen gefunden." %}</p>

View File

@ -10,9 +10,9 @@
class="fa-solid fa-flag"></i></a> class="fa-solid fa-flag"></i></a>
</div> </div>
<p> <p>
<b><i class="fa-solid fa-location-dot"></i></b> <b>Ort</b>
{% if adoption_notice.location %} {% if adoption_notice.location %}
{{ adoption_notice.location.str_hr }} {{ adoption_notice.location }}
{% else %} {% else %}
{{ adoption_notice.location_string }} {{ adoption_notice.location_string }}
{% endif %} {% endif %}

View File

@ -14,7 +14,7 @@
<p> <p>
<b>Ort</b> <b>Ort</b>
{% if adoption_notice.location %} {% if adoption_notice.location %}
{{ adoption_notice.location.str_hr }} {{ adoption_notice.location }}
{% else %} {% else %}
{{ adoption_notice.location_string }} {{ adoption_notice.location_string }}
{% endif %} {% endif %}