New WaitingListEntry #33

Merged
valberg merged 10 commits from benjaoming/membersystem:waiting-list into main 2024-07-31 22:49:48 +00:00
6 changed files with 64 additions and 10 deletions
Showing only changes of commit 1405a95094 - Show all commits

4
.gitignore vendored
View file

@ -8,3 +8,7 @@ db.sqlite3
.env .env
venv/ venv/
.venv/ .venv/
# collectstatic
src/static/

View file

@ -1,5 +1,5 @@
default_language_version: default_language_version:
python: python3.12 python: python3
exclude: ^.*\b(migrations)\b.*$ exclude: ^.*\b(migrations)\b.*$
repos: repos:
- repo: https://github.com/pre-commit/pre-commit-hooks - repo: https://github.com/pre-commit/pre-commit-hooks
@ -15,8 +15,8 @@ repos:
- id: check-toml - id: check-toml
- id: end-of-file-fixer - id: end-of-file-fixer
- id: trailing-whitespace - id: trailing-whitespace
- repo: https://github.com/charliermarsh/ruff-pre-commit - repo: https://github.com/astral-sh/ruff-pre-commit
rev: 'v0.4.4' rev: 'v0.5.2'
hooks: hooks:
- id: ruff - id: ruff
args: args:

View file

@ -115,7 +115,7 @@ extend-exclude = [
line-length = 120 line-length = 120
[tool.ruff.lint] [tool.ruff.lint]
select = ["ALL"] # select = ["ALL"]
ignore = [ ignore = [
"G004", # Logging statement uses f-string "G004", # Logging statement uses f-string
"ANN101", # Missing type annotation for `self` in method "ANN101", # Missing type annotation for `self` in method

View file

@ -1,20 +1,23 @@
from django.contrib import admin from django.contrib import admin
from .models import Membership from . import models
from .models import MembershipType
from .models import SubscriptionPeriod
benjaoming marked this conversation as resolved Outdated

I'm against importing whole modules.

Explicit is better than implicit.

I'm against importing whole modules. > Explicit is better than implicit.

Don't we import whole modules everywhere all the time?

The idea is that the Django app is a domain-specific app so importing the models into the admin makes sense because almost all Models from that models module will have an admin. To me, this makes the code more readable than having lots of import statements.

Don't we import whole modules everywhere all the time? The idea is that the Django app is a domain-specific app so importing the models into the admin makes sense because almost all Models from that models module will have an admin. To me, this makes the code more readable than having lots of import statements.

Well, yes. I mostly use for instance from django.db import models in my own models modules, because it is a standard - but I actually would love to be more explicit everywhere.

When push comes to shove it is all about preference. My preference is to explicitly import what is being used, to have a clear "in this module we are using these external things".

Well, yes. I mostly use for instance `from django.db import models` in my own `models` modules, because it is a standard - but I actually would love to be more explicit everywhere. When push comes to shove it is all about preference. My preference is to explicitly import what is being used, to have a clear "in this module we are using these external things".

I also use from django.db import models in app.models but in app.* I use from app import models because it's so convenient and it targets the domain-specific ideal of the app. As in, if you are import some other models module, then something is wrong.

I also use `from django.db import models` in `app.models` but in `app.*` I use `from app import models` because it's so convenient and it targets the domain-specific ideal of the app. As in, if you are import some other `models` module, then something is wrong.

I think having explicit imports is more readable and gives me an overview of what the module is interfacing with.

I think we can debate this forever :P

I would say that we should go with "do not change it just for the sake of changing it" and keep it as it was (but that is also in favorable for me ATM)

I think having explicit imports is more readable and gives me an overview of what the module is interfacing with. I think we can debate this forever :P I would say that we should go with "do not change it just for the sake of changing it" and keep it as it was (but that is also in favorable for me ATM)

Alright you stubborn one ❤️

Alright you stubborn one ❤️
@admin.register(Membership) @admin.register(models.Membership)
class MembershipAdmin(admin.ModelAdmin): class MembershipAdmin(admin.ModelAdmin):
pass pass
@admin.register(MembershipType) @admin.register(models.MembershipType)
class MembershipTypeAdmin(admin.ModelAdmin): class MembershipTypeAdmin(admin.ModelAdmin):
pass pass
@admin.register(SubscriptionPeriod) @admin.register(models.SubscriptionPeriod)
class SubscriptionPeriodAdmin(admin.ModelAdmin): class SubscriptionPeriodAdmin(admin.ModelAdmin):
pass pass
@admin.register(models.WaitingListEntry)
class WaitingListEntryAdmin(admin.ModelAdmin):
pass

View file

@ -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'},
),
]

View file

@ -111,3 +111,18 @@ class MembershipType(CreatedModifiedAbstract):
def __str__(self) -> str: def __str__(self) -> str:
return self.name 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")