Skip to content

Commit

Permalink
WIP: 100-klubben
Browse files Browse the repository at this point in the history
Part of #63
  • Loading branch information
jonatanskogsfors committed Oct 1, 2024
1 parent 939186e commit 6b046ac
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -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å'),
),
]
3 changes: 2 additions & 1 deletion batadasen/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
40 changes: 40 additions & 0 deletions batadasen/templates/batadasen/hundraklubben_list.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{% extends 'base.html' %}
{% load i18n %}

{% block title %}Medlemmar{% endblock %}

{% block content %}
<h2>100-klubben</h2>
<table class="table table-sm">
<tr>
<th>Medlemsnummer</th>
<th>Namn</th>
</tr>
{% for person in object_list|dictsort:"member_number" %}
{% if person.hundred_club %}
<tr>
<td><a href="{% url 'batadasen:person_detail' person.member_number %}">{{ person.member_number }}</a></td>
<td>{{ person.first_name }} {% if person.spex_name %}"{{ person.spex_name }}" {% endif %}{{ person.last_name }}</td>
</tr>
{% endif %}
{% endfor %}
</table>
{% if perms.batadasen.view_performances %}
<h2>Kandidater</h2>
<table class="table table-sm">
<tr>
<th>Medlemsnummer</th>
<th>Namn</th>
<th>Rapporterade föreställningar</th>
</tr>
{% for person in object_list|dictsort:"member_number" %}
{% if not person.hundred_club %}
<tr>
<td><a href="{% url 'batadasen:person_detail' person.member_number %}">{{ person.member_number }}</a></td>
<td>{{ person.first_name }} {% if person.spex_name %}"{{ person.spex_name }}" {% endif %}{{ person.last_name }}</td>
<td>{{ person.performances_count }}</td>
</tr>
{% endif %}
{% endfor %}
{% endif %}
{% endblock %}
1 change: 1 addition & 0 deletions batadasen/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -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/<int:pk>/', 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/<int:pk>/', views.ProductionDetailView.as_view(), name='production_detail'),
path('api/users', views.UserList.as_view()),
Expand Down
11 changes: 11 additions & 0 deletions batadasen/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 6b046ac

Please sign in to comment.