Commit 676825d4 authored by Luko van der Maas's avatar Luko van der Maas

Merge branch 'feature/admin-fields-search-etc' into 'master'

Add useful features to model admins

See merge request !1286
parents 0a7f54e9 b8c7dddd
......@@ -176,7 +176,7 @@ class MemberGroupMembershipAdmin(TranslatedModelAdmin):
list_select_related = ('member', 'group',)
search_fields = ('member__first_name', 'member__last_name',
'member__email')
date_hierarchy = 'since'
actions = ('export',)
def changelist_view(self, request, extra_context=None):
......@@ -222,4 +222,6 @@ class MemberGroupMembershipAdmin(TranslatedModelAdmin):
@admin.register(models.Mentorship)
class MentorshipAdmin(admin.ModelAdmin):
"""Manage the mentorships"""
list_select_related = ('member',)
autocomplete_fields = ('member',)
search_fields = ('member__first_name', 'member__last_name')
list_filter = ('year',)
......@@ -6,7 +6,7 @@ import datetime
from django.contrib import admin, messages
from django.contrib.auth.admin import UserAdmin as BaseUserAdmin
from django.contrib.auth.models import User
from django.db.models import Q
from django.db.models import Q, Count
from django.http import HttpResponse
from django.utils import timezone
from django.utils.translation import ugettext_lazy as _
......@@ -87,6 +87,29 @@ class AgeListFilter(admin.SimpleListFilter):
return queryset
class HasPermissionsFilter(admin.SimpleListFilter):
title = _('Has individual permissions')
parameter_name = 'permissions'
def lookups(self, request, model_admin):
return (
('yes', _('Yes')),
('no', _('No')),
)
def queryset(self, request, queryset):
if not self.value():
return queryset
queryset = queryset.annotate(
permission_count=Count('user_permissions'))
if self.value() == 'yes':
return queryset.filter(permission_count__gt=0)
return queryset.filter(permission_count=0)
class UserAdmin(BaseUserAdmin):
change_list_template = 'admin/members/change_list.html'
form = forms.UserChangeForm
......@@ -98,10 +121,12 @@ class UserAdmin(BaseUserAdmin):
inlines = (ProfileInline, MembershipInline,)
list_filter = (MembershipTypeListFilter,
'is_superuser',
HasPermissionsFilter,
'groups',
AgeListFilter,
'profile__event_permissions',
'profile__starting_year',
'profile__auto_renew')
'profile__auto_renew',)
add_fieldsets = (
(None, {
......
This diff was suppressed by a .gitattributes entry.
......@@ -7,8 +7,8 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-04-09 21:17+0200\n"
"PO-Revision-Date: 2019-04-09 21:18+0200\n"
"POT-Creation-Date: 2019-06-07 16:35+0200\n"
"PO-Revision-Date: 2019-06-07 16:37+0200\n"
"Last-Translator: Thom Wiggers <thom@thomwiggers.nl>\n"
"Language-Team: \n"
"Language: nl\n"
......@@ -42,6 +42,18 @@ msgstr "< 18"
msgid "Unknown"
msgstr "Onbekend"
#: admin.py
msgid "Has individual permissions"
msgstr "Heeft individuele permissies"
#: admin.py
msgid "Yes"
msgstr "Ja"
#: admin.py
msgid "No"
msgstr "Nee"
#: admin.py forms.py
msgid "First name"
msgstr "Voornaam"
......@@ -148,10 +160,6 @@ msgstr "Verifieer je nieuwe e-mailadres"
msgid "Your email address has been changed"
msgstr "Je e-mailadres is aangepast"
#: forms.py
msgid "Please enter a bank account"
msgstr "Voer een bankrekening in"
#: forms.py
msgid "Send welcome email"
msgstr "Stuur welkomste-mails"
......@@ -164,10 +172,6 @@ msgstr "Deze e-mail zal het gegenereerde wachtwoord bevatten"
msgid "Email address"
msgstr "E-mailadres"
#: models.py
msgid "Access the Sentry backend"
msgstr "Toegang tot the Sentry backend"
#: models.py
msgid "Access NextCloud as admin"
msgstr "Toegang tot NextCloud als admin"
......@@ -357,33 +361,16 @@ msgid "Receive the Thalia Newsletter"
msgstr "Ontvang de Thalia nieuwsbrief"
#: models.py
msgid ""
"Yes, I want Thalia to take the membership fees from my bank account through "
"direct debit for each year."
msgstr ""
"Ja, ik wil dat Thalia verschuldigde lidmaatschapsgelden elk jaar van mijn "
"bankrekening afschrijft."
msgid "Yes, enable auto renewal."
msgstr "Ja, verleng automatisch."
#: models.py
msgid "No, I will pay the contribution myself"
msgstr "Nee, ik zal de contributie zelf betalen"
msgid "No, manual renewal required."
msgstr "Nee, handmatige verlenging vereist."
#: models.py
msgid "Direct debit"
msgstr "Automatische afschijving"
#: models.py
msgid "Each year, have Thalia take the membership fees from my bank account"
msgstr ""
"Laat Thalia elk jaar het lidmaatschapsgeld van mijn bankrekening afschrijven"
#: models.py
msgid "Bank account"
msgstr "Bankrekening"
#: models.py
msgid "Bank account for direct debit"
msgstr "Bankrekening voor automatische afschrijving"
msgid "Automatically renew membership"
msgstr "Lidmaatschap automatisch verlengen"
#: models.py
msgid "Display name"
......@@ -503,64 +490,18 @@ msgstr "Ouder"
msgid "Export IBANs for Direct Debit"
msgstr "Exporteer IBANs voor automatische incasso"
#: templates/members/account.html templates/members/edit_profile.html
#: templates/members/email_change.html
#: templates/members/edit_profile.html templates/members/user.html
msgid "edit profile"
msgstr "profiel bewerken"
#: templates/members/edit_profile.html templates/members/email_change.html
#: templates/members/email_change_confirmed.html
#: templates/members/email_change_requested.html
#: templates/members/email_change_verified.html templates/members/index.html
#: templates/members/profile.html
#: templates/members/profile.html templates/members/user.html
msgid "members"
msgstr "leden"
#: templates/members/account.html
msgid "Account"
msgstr "Account"
#: templates/members/account.html
#, python-format
msgid "You’re currently logged in as <strong>%(user)s</strong>"
msgstr "U bent momenteel ingelogd als <strong>%(user)s</strong>"
#: templates/members/account.html
msgid "show public profile"
msgstr "bekijk publieke profielpagina"
#: templates/members/account.html
msgid "Take a look at your own profile."
msgstr "Bekijk je eigen profielpagina."
#: templates/members/account.html
msgid "manage membership"
msgstr "lidmaatschap beheren"
#: templates/members/account.html
msgid "Get information about your membership or renew it."
msgstr "Bekijk je lidmaatschap of vernieuw deze indien nodig."
#: templates/members/account.html templates/members/edit_profile.html
msgid "edit profile"
msgstr "profiel bewerken"
#: templates/members/account.html
msgid "Edit your profile and avatar."
msgstr "Bewerk je profiel en profielafbeelding."
#: templates/members/account.html
msgid "change password"
msgstr "wachtwoord wijzigen"
#: templates/members/account.html
msgid "Change your accounts' password."
msgstr "Wijzig het wachtwoord van je account."
#: templates/members/account.html
msgid "logout"
msgstr "uitloggen"
#: templates/members/account.html
msgid "Leave the restricted area of the website."
msgstr "Verlaat het beveiligde gedeelte van de website."
#: templates/members/edit_profile.html
msgid "Your profile has been updated successfully."
msgstr "Je profiel is succesvol opgeslagen."
......@@ -1048,6 +989,59 @@ msgstr "Statistieken"
msgid "Total amount of Thalia members"
msgstr "Totaal aantal Thalialeden"
#: templates/members/user.html
msgid "Account"
msgstr "Account"
#: templates/members/user.html
#, python-format
msgid "You’re currently logged in as <strong>%(user)s</strong>"
msgstr "U bent momenteel ingelogd als <strong>%(user)s</strong>"
#: templates/members/user.html
msgid "show public profile"
msgstr "bekijk publieke profielpagina"
#: templates/members/user.html
msgid "Take a look at your own profile."
msgstr "Bekijk je eigen profielpagina."
#: templates/members/user.html
msgid "manage membership"
msgstr "lidmaatschap beheren"
#: templates/members/user.html
msgid "Get information about your membership or renew it."
msgstr "Bekijk je lidmaatschap of vernieuw deze indien nodig."
#: templates/members/user.html
msgid "Edit your profile and avatar."
msgstr "Bewerk je profiel en profielafbeelding."
#: templates/members/user.html
msgid "manage bank account(s)"
msgstr "bankrekening(en) beheren"
#: templates/members/user.html
msgid "Change the financial information known to Thalia."
msgstr "Verander de financiële informatie bekend bij Thalia."
#: templates/members/user.html
msgid "change password"
msgstr "wachtwoord wijzigen"
#: templates/members/user.html
msgid "Change your accounts' password."
msgstr "Wijzig het wachtwoord van je account."
#: templates/members/user.html
msgid "logout"
msgstr "uitloggen"
#: templates/members/user.html
msgid "Leave the restricted area of the website."
msgstr "Verlaat het beveiligde gedeelte van de website."
#: views.py
msgid "Unknown membership history"
msgstr "Onbekende lidmaatschap geschiedenis"
......
......@@ -24,7 +24,7 @@ class NewsletterEventInline(NewsletterItemInline):
class NewsletterAdmin(TranslatedModelAdmin):
"""Manage the newsletters"""
#: available fields in the admin overview list
list_display = ('title', 'date', 'sent',)
list_display = ('title', 'date', 'send_date', 'sent',)
#: available inlines in the admin change form
inlines = (NewsletterItemInline, NewsletterEventInline,)
#: available fieldsets in the admin change form
......@@ -35,6 +35,10 @@ class NewsletterAdmin(TranslatedModelAdmin):
)
}),
)
#: available fields for searching
search_fields = ('title', 'description')
#: field to use for date filtering
date_hierarchy = 'date'
def change_view(self, request, object_id, form_url=''):
"""
......
......@@ -17,6 +17,7 @@ class PartnerAdmin(admin.ModelAdmin):
prepopulated_fields = {"slug": ("name",)}
list_display = ('name', 'is_active', 'is_main_partner',)
search_fields = ('name', 'city')
inlines = (PartnerImageInline,)
fieldsets = (
......@@ -46,7 +47,7 @@ class VacancyAdmin(admin.ModelAdmin):
"""Class to show vacancies in the admin."""
list_display = ('title', 'partner', 'company_name', 'expiration_date')
search_fields = ('title', 'partner__name', 'company_name',)
fieldsets = (
(None, {
'fields': ('title', 'description', 'link',)
......@@ -70,8 +71,9 @@ class VacancyAdmin(admin.ModelAdmin):
class PartnerEventAdmin(TranslatedModelAdmin):
"""Class to show partner events in the admin."""
fields = ['partner', 'other_partner', 'title', 'description', 'location',
'start', 'end', 'url', 'published']
fields = ('partner', 'other_partner', 'title', 'description', 'location',
'start', 'end', 'url', 'published')
list_display = ('title', 'start', 'end',
'partner', 'published')
list_filter = ('start', 'published')
search_fields = ('title', 'partner__name')
......@@ -224,13 +224,14 @@ class BankAccountAdmin(admin.ModelAdmin):
list_display = ('iban', 'owner_link', 'last_used',
'valid_from', 'valid_until')
list_filter = (ValidAccountFilter,)
list_filter = (ValidAccountFilter, 'owner__profile__auto_renew')
fields = ('created_at', 'last_used', 'owner', 'iban', 'bic', 'initials',
'last_name', 'mandate_no', 'valid_from', 'valid_until',
'signature')
readonly_fields = ('created_at',)
search_fields = ('owner__username', 'owner__first_name',
'owner__last_name', 'iban')
autocomplete_fields = ('owner',)
actions = ['set_last_used']
form = BankAccountAdminForm
......
......@@ -8,6 +8,7 @@ from django.contrib import admin
from django.contrib import messages
from django.core.exceptions import ValidationError
from django.core.files.base import File
from django.db.models import Count
from django.utils.translation import ugettext_lazy as _
from utils.translation import TranslatedModelAdmin
......@@ -82,7 +83,7 @@ def save_photo(request, archive_file, photo, album):
class AlbumAdmin(TranslatedModelAdmin):
list_display = ('title', 'date', 'hidden', 'shareable')
list_display = ('title', 'date', 'num_photos', 'hidden', 'shareable')
fields = ('title', 'slug', 'date', 'hidden', 'shareable', 'album_archive',
'_cover')
search_fields = ('title', 'date')
......@@ -91,6 +92,15 @@ class AlbumAdmin(TranslatedModelAdmin):
prepopulated_fields = {'slug': ('date', 'title_en',)}
form = AlbumForm
def get_queryset(self, request):
return Album.objects.annotate(photos_count=Count('photo'))
def num_photos(self, obj):
"""Pretty-print the number of photos"""
return obj.photos_count
num_photos.short_description = _('Number of photos')
num_photos.admin_order_field = 'photos_count'
def save_model(self, request, obj, form, change):
obj.save()
......
from django.conf import settings
from django.contrib import admin
from django.core.exceptions import PermissionDenied
from django.urls import reverse, path
......@@ -16,12 +17,21 @@ from events.services import is_organiser
class ProductAdmin(admin.ModelAdmin):
list_display = ('name', 'price', 'available')
list_filter = ('available', 'restricted')
search_fields = ('name',)
@admin.register(PizzaEvent)
class PizzaEventAdmin(admin.ModelAdmin):
list_display = ('title', 'orders')
list_display = ('title', 'start', 'end', 'notification_enabled', 'orders')
date_hierarchy = 'start'
exclude = ('end_reminder',)
search_fields = [f'event__title_{l[0]}' for l in settings.LANGUAGES]
def notification_enabled(self, obj):
return obj.send_notification
notification_enabled.short_description = _('reminder')
notification_enabled.admin_order_field = 'send_notification'
notification_enabled.boolean = True
def orders(self, obj):
url = reverse('admin:pizzas_pizzaevent_details', kwargs={'pk': obj.pk})
......
......@@ -25,7 +25,7 @@ class PizzaOrderSummary(TemplateView):
'is_popup': False,
'save_as': False,
'save_on_top': False,
'title': capfirst(_('pizza order summary')),
'title': capfirst(_('order summary')),
'original': capfirst(_('summary')),
'pizza_event': event
})
......@@ -74,7 +74,7 @@ class PizzaOrderDetails(TemplateView):
'is_popup': False,
'save_as': False,
'save_on_top': False,
'title': capfirst(_('pizza order overview')),
'title': capfirst(_('order overview')),
'original': str(event),
'pizza_event': event
})
......
This diff was suppressed by a .gitattributes entry.
......@@ -7,8 +7,8 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-03-02 16:51+0100\n"
"PO-Revision-Date: 2019-03-02 16:51+0100\n"
"POT-Creation-Date: 2019-06-07 16:41+0200\n"
"PO-Revision-Date: 2019-06-07 16:41+0200\n"
"Last-Translator: Thom Wiggers <thom@thomwiggers.nl>\n"
"Language-Team: \n"
"Language: nl\n"
......@@ -16,12 +16,27 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Generator: Poedit 2.2.1\n"
"X-Generator: Poedit 2.2.3\n"
#: admin.py
#, python-brace-format
msgid "<strong><a href=\"{link}\">Orders</a></strong>"
msgstr "<strong><a href=\"{link}\">Bestellingen</a></strong>"
msgid "reminder"
msgstr "herinnering"
#: admin.py templates/pizzas/admin/summary.html
msgid "Orders"
msgstr "Bestellingen"
#: admin_views.py
msgid "order summary"
msgstr "bestellingssamenvatting"
#: admin_views.py
msgid "summary"
msgstr "samenvatting"
#: admin_views.py
msgid "order overview"
msgstr "bestellingsoverzicht"
#: api/serializers.py models.py
msgid "Either specify a member or a name"
......@@ -67,51 +82,95 @@ msgstr ""
msgid "Order restricted products"
msgstr "Bestel beperkte producten"
#: models.py
msgid "name"
msgstr "naam"
#: models.py
msgid "Use this for non-members"
msgstr "Vul dit in voor niet-leden"
#: models.py templates/pizzas/admin/orders.html
msgid "payment"
msgstr "betaling"
#: models.py templates/pizzas/admin/orders.html
#: templates/pizzas/admin/summary.html
msgid "product"
msgstr "product"
#: models.py
msgid "event"
msgstr "evenement"
#: models.py
#, python-brace-format
msgid "Order by {member_name}: {product}"
msgstr "Bestelling van {member_name}: {product}"
#: templates/pizzas/add_order.html
msgid "Add order"
msgstr "Nieuwe bestelling toevoegen"
#: templates/pizzas/admin/orders.html templates/pizzas/admin/summary.html
msgid "Home"
msgstr "Voorpagina"
#: templates/pizzas/add_order.html templates/pizzas/index.html
#: templates/pizzas/orders.html templates/pizzas/overview.html
msgid "pizzas"
msgstr "pizza's"
#: templates/pizzas/admin/orders.html
msgid "overview"
msgstr "overzicht"
#: templates/pizzas/add_order.html
#, python-format
msgid "Add order for %(title)s"
msgstr "Bestelling toevoegen voor %(title)s"
#: templates/pizzas/admin/orders.html
msgid "all products"
msgstr "alle producten"
#: templates/pizzas/add_order.html templates/pizzas/index.html
#: templates/pizzas/orders.html
msgid "Name"
msgstr "Naam"
#: templates/pizzas/admin/orders.html
msgid "all events"
msgstr "alle evenementen"
#: templates/pizzas/add_order.html templates/pizzas/orders.html
#: templates/pizzas/overview.html
msgid "Product"
msgstr "Product"
#: templates/pizzas/admin/orders.html
msgid "first name"
msgstr "voornaam"
#: templates/pizzas/add_order.html
msgid "Add"
msgstr "Toevoegen"
#: templates/pizzas/admin/orders.html
msgid "last name"
msgstr "achternaam"
#: templates/pizzas/add_order.html
#, python-format
msgid ""
"A more generic version of this form is<br>also available in the <a href="
"\"%(url_pizzas_order_add)s\">administration back-end</a>."
msgstr ""
"Een meer generieke versie van dit formulier<br>is ook beschikbaar in de <a "
"href=\"%(url_pizzas_order_add)s\">back-end</a>."
#: templates/pizzas/admin/orders.html
msgid "add"
msgstr "toevoegen"
#: templates/pizzas/admin/orders.html
msgid "None"
msgstr "Geen"
#: templates/pizzas/admin/orders.html
msgid "Card"
msgstr "Pin"
#: templates/pizzas/admin/orders.html
msgid "Cash"
msgstr "Contant"
#: templates/pizzas/admin/orders.html templates/pizzas/admin/summary.html
msgid "Nobody ordered yet"
msgstr "Nog geen bestellingen"
#: templates/pizzas/admin/summary.html
msgid "back"
msgstr "terug"
#: templates/pizzas/admin/summary.html
msgid "price"
msgstr "prijs"
#: templates/pizzas/admin/summary.html
msgid "amount"
msgstr "aantal"
#: templates/pizzas/admin/summary.html
msgid "total"
msgstr "totaal"
#: templates/pizzas/index.html
msgid "pizzas"
msgstr "pizza's"
#: templates/pizzas/index.html
#, python-format
......@@ -122,11 +181,11 @@ msgstr "Bestel eten voor %(title)s"
msgid "There is no current event for which you can order food"
msgstr "Er is nu geen evenement waar je eten voor kunt bestellen"
#: templates/pizzas/index.html templates/pizzas/orders.html
#: templates/pizzas/index.html
msgid "All products"
msgstr "Alle producten"
#: templates/pizzas/index.html templates/pizzas/orders.html
#: templates/pizzas/index.html
msgid "All events"
msgstr "Alle evenementen"
......@@ -161,11 +220,15 @@ msgstr "De bestelling is nog niet betaald."
msgid "Current order"
msgstr "Huidige bestelling"
#: templates/pizzas/index.html
msgid "Name"
msgstr "Naam"
#: templates/pizzas/index.html
msgid "Description"
msgstr "Omschrijving"
#: templates/pizzas/index.html templates/pizzas/overview.html
#: templates/pizzas/index.html
msgid "Price"
msgstr "Prijs"
......@@ -202,55 +265,10 @@ msgstr "Bestellen"
msgid "Are you sure you want to modify your order?"
msgstr "Weet je zeker dat je de bestelling aan wilt passen?"
#: templates/pizzas/orders.html templates/pizzas/overview.html
#, python-format
msgid "Orders for %(title)s"
msgstr "Bestellingen voor %(title)s"
#: templates/pizzas/orders.html
msgid "Overview"
msgstr "Overzicht"
#: templates/pizzas/orders.html
msgid "Paid"
msgstr "Betaald"
#: templates/pizzas/orders.html
msgid "Yes"
msgstr "Ja"
#: templates/pizzas/orders.html
msgid "No"
msgstr "Nee"
#: templates/pizzas/orders.html
msgid "Are you sure you want to delete this order?"
msgstr "Weet je zeker dat je de bestelling wilt verwijderen?"
#: templates/pizzas/orders.html templates/pizzas/overview.html
msgid "Nobody ordered yet"
msgstr "Nog geen bestellingen"
#: templates/pizzas/overview.html
msgid "Back"
msgstr "Terug"
#: templates/pizzas/overview.html
msgid "Amount"
msgstr "Aantal"
#: templates/pizzas/overview.html
msgid "Total"
msgstr "Totaal"
#: views.py
msgid "Your order could not be found."
msgstr "Je bestelling kont niet worden gevonden."
#: views.py
msgid "Your order has been cancelled."
msgstr "Je bestelling is geannuleerd."
#: views.py
msgid "Your order was successful."
msgstr "Je bestelling is succesvol."
msgid "Your order could not be found."
msgstr "Je bestelling kont niet worden gevonden."
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment