Compare commits
11 Commits
develop
...
9511b46af0
| Author | SHA1 | Date | |
|---|---|---|---|
| 9511b46af0 | |||
| 5b906a7708 | |||
| d68e836b57 | |||
| fe77f1da8d | |||
| 78b71690c0 | |||
| 3b9ee95abc | |||
| b4e50364de | |||
| b014b3b227 | |||
| 99bfe460ee | |||
| d4c7caa42d | |||
| 32c8fc88cf |
@@ -9,6 +9,7 @@ host=localhost
|
||||
secret=CHANGE-ME
|
||||
debug=True
|
||||
internal_ips=["127.0.0.1"]
|
||||
cache=False
|
||||
|
||||
[database]
|
||||
backend=sqlite3
|
||||
|
||||
@@ -40,6 +40,7 @@ dependencies = [
|
||||
"django-widget-tweaks",
|
||||
"django-super-deduper",
|
||||
"django-allauth[mfa]",
|
||||
"django_debug_toolbar",
|
||||
]
|
||||
|
||||
dynamic = ["version", "readme"]
|
||||
@@ -49,7 +50,6 @@ develop = [
|
||||
"pytest",
|
||||
"coverage",
|
||||
"model_bakery",
|
||||
"debug_toolbar",
|
||||
]
|
||||
docs = [
|
||||
"sphinx",
|
||||
|
||||
@@ -17,6 +17,21 @@ from django.utils.translation import gettext_lazy as _
|
||||
from .tools.model_helpers import AdoptionNoticeStatusChoices
|
||||
|
||||
|
||||
def export_to_csv_generic(model, queryset):
|
||||
meta = model._meta
|
||||
field_names = [field.name for field in meta.fields]
|
||||
|
||||
response = HttpResponse(content_type='text/csv')
|
||||
response['Content-Disposition'] = 'attachment; filename={}.csv'.format(meta)
|
||||
writer = csv.writer(response)
|
||||
|
||||
writer.writerow(field_names)
|
||||
for obj in queryset:
|
||||
row = writer.writerow([getattr(obj, field) for field in field_names])
|
||||
|
||||
return response
|
||||
|
||||
|
||||
@admin.register(AdoptionNotice)
|
||||
class AdoptionNoticeAdmin(admin.ModelAdmin):
|
||||
search_fields = ("name__icontains", "description__icontains")
|
||||
@@ -49,17 +64,7 @@ class UserAdmin(admin.ModelAdmin):
|
||||
return format_html('<a href="{}">{} Adoption Notices</a>', url, count)
|
||||
|
||||
def export_as_csv(self, request, queryset):
|
||||
meta = self.model._meta
|
||||
field_names = [field.name for field in meta.fields]
|
||||
|
||||
response = HttpResponse(content_type='text/csv')
|
||||
response['Content-Disposition'] = 'attachment; filename={}.csv'.format(meta)
|
||||
writer = csv.writer(response)
|
||||
|
||||
writer.writerow(field_names)
|
||||
for obj in queryset:
|
||||
row = writer.writerow([getattr(obj, field) for field in field_names])
|
||||
|
||||
response = export_to_csv_generic(self.model, queryset)
|
||||
return response
|
||||
|
||||
export_as_csv.short_description = _("Ausgewählte User exportieren")
|
||||
@@ -169,6 +174,13 @@ class LogAdmin(admin.ModelAdmin):
|
||||
ordering = ["-created_at"]
|
||||
list_filter = ("action",)
|
||||
list_display = ("action", "user", "created_at")
|
||||
actions = ("export_as_csv",)
|
||||
|
||||
def export_as_csv(self, request, queryset):
|
||||
response = export_to_csv_generic(Log, queryset)
|
||||
return response
|
||||
|
||||
export_as_csv.short_description = _("Ausgewählte Logs exportieren")
|
||||
|
||||
|
||||
admin.site.register(Animal)
|
||||
|
||||
13
src/fellchensammlung/management/commands/print-settings.py
Normal file
13
src/fellchensammlung/management/commands/print-settings.py
Normal file
@@ -0,0 +1,13 @@
|
||||
from django.core.management import BaseCommand
|
||||
|
||||
from notfellchen import settings
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
help = 'Print the current settings'
|
||||
|
||||
def handle(self, *args, **options):
|
||||
for key in settings.__dir__():
|
||||
if key.startswith("_") or key == "SECRET_KEY":
|
||||
continue
|
||||
print(f"{key} = {getattr(settings, key)}")
|
||||
@@ -419,7 +419,6 @@ class AdoptionNotice(models.Model):
|
||||
|
||||
@property
|
||||
def num_per_sex(self):
|
||||
print(f"{self.pk} x")
|
||||
num_per_sex = dict()
|
||||
for sex in SexChoices:
|
||||
num_per_sex[sex] = len([animal for animal in self.animals if animal.sex == sex])
|
||||
|
||||
@@ -71,7 +71,22 @@
|
||||
value="{{ rescue_org.pk }}">
|
||||
<input type="hidden" name="action" value="checked">
|
||||
<button class="" type="submit">{% translate "Organisation geprüft" %}</button>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
<div class="card-footer-item is-warning">
|
||||
<form method="post">
|
||||
{% csrf_token %}
|
||||
<input type="hidden"
|
||||
name="rescue_organization_id"
|
||||
value="{{ rescue_org.pk }}">
|
||||
<input type="hidden" name="action" value="toggle_active_communication">
|
||||
<button class="" type="submit">
|
||||
{% if rescue_org.ongoing_communication %}
|
||||
{% translate "Aktive Kommunikation beendet" %}
|
||||
{% else %}
|
||||
{% translate "Aktive Kommunikation" %}
|
||||
{% endif %}
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
<div class="card-footer-item is-danger">
|
||||
|
||||
@@ -81,6 +81,9 @@ def is_404(url):
|
||||
class RequestProfiler:
|
||||
data = []
|
||||
|
||||
def clear(self):
|
||||
self.data = []
|
||||
|
||||
def add_status(self, status):
|
||||
self.data.append((time.time(), status))
|
||||
|
||||
|
||||
@@ -867,6 +867,9 @@ def rescue_organization_check(request, context=None):
|
||||
if action == "checked":
|
||||
rescue_org.set_checked()
|
||||
Log.objects.create(user=request.user, action="rescue_organization_checked", )
|
||||
elif action == "toggle_active_communication":
|
||||
rescue_org.ongoing_communication = not rescue_org.ongoing_communication
|
||||
rescue_org.save()
|
||||
elif action == "set_species_url":
|
||||
species_url_form = SpeciesURLForm(request.POST)
|
||||
|
||||
@@ -929,7 +932,7 @@ def exclude_from_regular_check(request, rescue_organization_id, source="organiza
|
||||
if to_be_excluded:
|
||||
Log.objects.create(user=request.user,
|
||||
action="rescue_organization_excluded_from_check",
|
||||
text=f"New status: {form.cleaned_data["regular_check_status"]}")
|
||||
text=f"New status: {form.cleaned_data['regular_check_status']}")
|
||||
|
||||
return redirect(reverse(source))
|
||||
else:
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -75,8 +75,19 @@ except configparser.NoSectionError:
|
||||
DEBUG = config.getboolean('django', 'debug', fallback=False)
|
||||
|
||||
# Internal IPs
|
||||
raw_config_value = config.get("django", "internal_ips", fallback=[])
|
||||
INTERNAL_IPS = json.loads(raw_config_value)
|
||||
internal_ip_raw_config_value = config.get("django", "internal_ips", fallback=None)
|
||||
if internal_ip_raw_config_value:
|
||||
INTERNAL_IPS = json.loads(internal_ip_raw_config_value)
|
||||
|
||||
# Cache
|
||||
if config.getboolean('django', 'cache', fallback=False):
|
||||
CACHES = {
|
||||
"default": {
|
||||
"BACKEND": "django.core.cache.backends.locmem.LocMemCache",
|
||||
"LOCATION": "uniques-snowflake",
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
""" DATABASE """
|
||||
DB_BACKEND = config.get("database", "backend", fallback="sqlite3")
|
||||
@@ -245,7 +256,9 @@ MIDDLEWARE = [
|
||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||
# Needs to be after SessionMiddleware and before CommonMiddleware
|
||||
'django.middleware.locale.LocaleMiddleware',
|
||||
"django.middleware.cache.UpdateCacheMiddleware",
|
||||
'django.middleware.common.CommonMiddleware',
|
||||
"django.middleware.cache.FetchFromCacheMiddleware",
|
||||
'django.middleware.csrf.CsrfViewMiddleware',
|
||||
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
||||
'django.contrib.messages.middleware.MessageMiddleware',
|
||||
|
||||
Reference in New Issue
Block a user