diff --git a/batadasen/migrations/0015_alter_person_options_alter_emaillist_alias_and_more.py b/batadasen/migrations/0015_alter_person_options_alter_emaillist_alias_and_more.py new file mode 100644 index 0000000..1bfb3f0 --- /dev/null +++ b/batadasen/migrations/0015_alter_person_options_alter_emaillist_alias_and_more.py @@ -0,0 +1,28 @@ +# Generated by Django 4.1.4 on 2024-10-01 11:22 + +import batadasen.models +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('batadasen', '0014_person_email_active'), + ] + + operations = [ + migrations.AlterModelOptions( + name='person', + options={'ordering': ['member_number'], 'permissions': [('view_private_info', 'Kan se all personinfo oavsett personens inställningar'), ('view_performances', 'Kan se loggade föreställnigar')], 'verbose_name': 'person', 'verbose_name_plural': 'personer'}, + ), + migrations.AlterField( + model_name='emaillist', + name='alias', + field=batadasen.models.EmailField(help_text='Namnet på listan, det som står framför @', max_length=50, primary_key=True, serialize=False, verbose_name='alias'), + ), + migrations.AlterField( + model_name='person', + name='privacy_setting', + field=models.CharField(choices=[('PVT', 'Privat'), ('OPN', 'Öppen')], default='OPN', help_text='Privat: endast administratörer kan se dina kontaktuppgifter. Öppen: andra inloggade kan se all din information. Inga personuppgifter kommer någonsin vara synliga för icke-inloggade. Medlemsnummer och namn kommer alltid vara synligt för inloggade.', max_length=3, verbose_name='sekretessnivå'), + ), + ] diff --git a/batadasen/models.py b/batadasen/models.py index 1c65fe3..b2f8cfa 100644 --- a/batadasen/models.py +++ b/batadasen/models.py @@ -40,7 +40,8 @@ class Meta: verbose_name_plural = 'personer' ordering = ['member_number'] permissions = [ - ("view_private_info", "Kan se all personinfo oavsett personens inställningar") + ("view_private_info", "Kan se all personinfo oavsett personens inställningar"), + ("view_performances", "Kan se loggade föreställnigar"), ] class PrivacySetting(models.TextChoices): diff --git a/batadasen/templates/batadasen/hundraklubben_list.html b/batadasen/templates/batadasen/hundraklubben_list.html new file mode 100644 index 0000000..6e9ea78 --- /dev/null +++ b/batadasen/templates/batadasen/hundraklubben_list.html @@ -0,0 +1,40 @@ +{% extends 'base.html' %} +{% load i18n %} + +{% block title %}Medlemmar{% endblock %} + +{% block content %} +

100-klubben

+ + + + + + {% for person in object_list|dictsort:"member_number" %} + {% if person.hundred_club %} + + + + + {% endif %} + {% endfor %} +
MedlemsnummerNamn
{{ person.member_number }}{{ person.first_name }} {% if person.spex_name %}"{{ person.spex_name }}" {% endif %}{{ person.last_name }}
+{% if perms.batadasen.view_performances %} +

Kandidater

+ + + + + + + {% for person in object_list|dictsort:"member_number" %} + {% if not person.hundred_club %} + + + + + + {% endif %} + {% endfor %} +{% endif %} +{% endblock %} \ No newline at end of file diff --git a/batadasen/urls.py b/batadasen/urls.py index 4afc542..bbf0f7a 100644 --- a/batadasen/urls.py +++ b/batadasen/urls.py @@ -11,6 +11,7 @@ path('settings/', views.PersonSelfView.as_view(), name='person_settings'), path('settings/extra_email/', views.ExtraEmailView.as_view(), name='person_extra_email'), path('persons//', views.PersonDetailView.as_view(), name='person_detail'), + path('hundraklubben/', views.Club100.as_view(), name='hundraklubben'), path('productions/', views.ProductionListView.as_view(), name='production_list'), path('productions//', views.ProductionDetailView.as_view(), name='production_detail'), path('api/users', views.UserList.as_view()), diff --git a/batadasen/views.py b/batadasen/views.py index 599ec7a..486c5a7 100644 --- a/batadasen/views.py +++ b/batadasen/views.py @@ -154,6 +154,17 @@ def get_context_data(self, **kwargs): groups.append(result_group) context['groups'] = groups return context + +from django.db.models import Count + +@method_decorator(login_required, name='dispatch') +class Club100(ListView): + model = models.Person + annotated = model.objects.annotate( + performances_count=Count('performances') +) + queryset = annotated.filter(Q(hundred_club=True) | Q(performances_count__gte=3)) + template_name = 'batadasen/hundraklubben_list.html' @login_required def index_view(request):
MedlemsnummerNamnRapporterade föreställningar
{{ person.member_number }}{{ person.first_name }} {% if person.spex_name %}"{{ person.spex_name }}" {% endif %}{{ person.last_name }}{{ person.performances_count }}