From 1405a9509449ad7bb1b82769c713766efe59f4b8 Mon Sep 17 00:00:00 2001 From: Benjamin Bach Date: Sun, 14 Jul 2024 19:18:33 +0200 Subject: [PATCH] Waiting list function: WaitingListEntry model for people that can be invited in the future --- .gitignore | 4 +++ .pre-commit-config.yaml | 6 ++-- pyproject.toml | 2 +- src/membership/admin.py | 15 +++++---- ...itinglistentry_alter_membership_options.py | 32 +++++++++++++++++++ src/membership/models.py | 15 +++++++++ 6 files changed, 64 insertions(+), 10 deletions(-) create mode 100644 src/membership/migrations/0006_waitinglistentry_alter_membership_options.py diff --git a/.gitignore b/.gitignore index 86b4cf9..6f40a53 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,7 @@ db.sqlite3 .env venv/ .venv/ + + +# collectstatic +src/static/ diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index fc9fe36..c7f2a83 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,5 +1,5 @@ default_language_version: - python: python3.12 + python: python3 exclude: ^.*\b(migrations)\b.*$ repos: - repo: https://github.com/pre-commit/pre-commit-hooks @@ -15,8 +15,8 @@ repos: - id: check-toml - id: end-of-file-fixer - id: trailing-whitespace - - repo: https://github.com/charliermarsh/ruff-pre-commit - rev: 'v0.4.4' + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: 'v0.5.2' hooks: - id: ruff args: diff --git a/pyproject.toml b/pyproject.toml index 5346347..5434ff2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -115,7 +115,7 @@ extend-exclude = [ line-length = 120 [tool.ruff.lint] -select = ["ALL"] +# select = ["ALL"] ignore = [ "G004", # Logging statement uses f-string "ANN101", # Missing type annotation for `self` in method diff --git a/src/membership/admin.py b/src/membership/admin.py index 465764f..325167f 100644 --- a/src/membership/admin.py +++ b/src/membership/admin.py @@ -1,20 +1,23 @@ from django.contrib import admin -from .models import Membership -from .models import MembershipType -from .models import SubscriptionPeriod +from . import models -@admin.register(Membership) +@admin.register(models.Membership) class MembershipAdmin(admin.ModelAdmin): pass -@admin.register(MembershipType) +@admin.register(models.MembershipType) class MembershipTypeAdmin(admin.ModelAdmin): pass -@admin.register(SubscriptionPeriod) +@admin.register(models.SubscriptionPeriod) class SubscriptionPeriodAdmin(admin.ModelAdmin): pass + + +@admin.register(models.WaitingListEntry) +class WaitingListEntryAdmin(admin.ModelAdmin): + pass diff --git a/src/membership/migrations/0006_waitinglistentry_alter_membership_options.py b/src/membership/migrations/0006_waitinglistentry_alter_membership_options.py new file mode 100644 index 0000000..a993b63 --- /dev/null +++ b/src/membership/migrations/0006_waitinglistentry_alter_membership_options.py @@ -0,0 +1,32 @@ +# Generated by Django 5.0.6 on 2024-07-14 16:22 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('membership', '0005_member'), + ] + + operations = [ + migrations.CreateModel( + name='WaitingListEntry', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('modified', models.DateTimeField(auto_now=True, verbose_name='modified')), + ('created', models.DateTimeField(auto_now_add=True, verbose_name='created')), + ('email', models.EmailField(max_length=254)), + ('geography', models.CharField(blank=True, null=True, verbose_name='geography')), + ('comment', models.TextField(blank=True)), + ], + options={ + 'verbose_name': 'waiting list entry', + 'verbose_name_plural': 'waiting list entries', + }, + ), + migrations.AlterModelOptions( + name='membership', + options={'verbose_name': 'medlemskab', 'verbose_name_plural': 'medlemskaber'}, + ), + ] diff --git a/src/membership/models.py b/src/membership/models.py index 730133f..09146a1 100644 --- a/src/membership/models.py +++ b/src/membership/models.py @@ -111,3 +111,18 @@ class MembershipType(CreatedModifiedAbstract): def __str__(self) -> str: return self.name + + +class WaitingListEntry(CreatedModifiedAbstract): + """People who for some reason could want to be added to a waiting list and invited to join later.""" + + email = models.EmailField() + geography = models.CharField(verbose_name=_("geography"), blank=True, null=True) + comment = models.TextField(blank=True) + + def __str__(self) -> str: + return self.email + + class Meta: + verbose_name = _("waiting list entry") + verbose_name_plural = _("waiting list entries")