From 865bc6c7bded11705d4476021e1585fe8150b9fd Mon Sep 17 00:00:00 2001 From: Benjamin Bach Date: Wed, 31 Jul 2024 22:49:46 +0000 Subject: [PATCH] New WaitingListEntry (#33) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sorted the pre-commit things... some were because of `src/static` being included, and some have been fixed in another PR 🎉 Reviewed-on: https://git.data.coop/data.coop/membersystem/pulls/33 Reviewed-by: valberg Co-authored-by: Benjamin Bach Co-committed-by: Benjamin Bach --- .gitignore | 4 ++ Makefile | 4 +- README.md | 54 +++++++++++-------- src/membership/admin.py | 6 +++ ...itinglistentry_alter_membership_options.py | 32 +++++++++++ src/membership/models.py | 15 ++++++ src/pytest.ini | 5 -- 7 files changed, 93 insertions(+), 27 deletions(-) create mode 100644 src/membership/migrations/0006_waitinglistentry_alter_membership_options.py delete mode 100644 src/pytest.ini 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/Makefile b/Makefile index a577606..0eeaafa 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,5 @@ DOCKER_COMPOSE = COMPOSE_DOCKER_CLI_BUILD=1 DOCKER_BUILDKIT=1 docker compose DOCKER_RUN = ${DOCKER_COMPOSE} run -u `id -u` -DOCKER_BUILD = DOCKER_BUILDKIT=1 docker build MANAGE_EXEC = python /app/src/manage.py MANAGE_COMMAND = ${DOCKER_RUN} app ${MANAGE_EXEC} @@ -21,3 +20,6 @@ shell: manage_command: ${MANAGE_COMMAND} ${ARGS} + +build: + ${DOCKER_COMPOSE} build diff --git a/README.md b/README.md index 2524f93..a91763d 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,6 @@ There are two ways to setup the development environment. - Using the Docker Compose setup provided in this repository. - Using [hatch](https://hatch.pypa.io/) in your host OS. - ### Using Docker Compose Working with the Docker Compose setup is made easy with the `Makefile` provided in the repository. @@ -21,24 +20,37 @@ Working with the Docker Compose setup is made easy with the `Makefile` provided 1. Setup .env file -An example .env file is provided in the repository. You can copy it to .env file using the following command: + An example .env file is provided in the repository. You can copy it to .env file using the following command: -```bash -cp .env.example .env -``` + ```bash + cp .env.example .env + ``` -The default values in the .env file are suitable for the docker-compose setup. + The default values in the .env file are suitable for the docker-compose setup. 2. Migrate -```bash -make migrate -``` + ```bash + make migrate + ``` 3. Run the development server + ```bash + make run + ``` + +#### Building and running other things + ```bash -make run +# Build the containers +make build + +# Create a superuser +make createsuperuser + +# Create Django migrations (after this, maybe you need to change file permissions in volume) +make makemigrations ``` ### Using hatch @@ -53,25 +65,25 @@ make run 1. Setup .env file -An example .env file is provided in the repository. You can copy it to .env file using the following command: + An example .env file is provided in the repository. You can copy it to .env file using the following command: -```bash -cp .env.example .env -``` + ```bash + cp .env.example .env + ``` -Edit the .env file and set the values for the environment variables, especially the database variables. + Edit the .env file and set the values for the environment variables, especially the database variables. 2. Run migrate -```bash -hatch run dev:migrate -``` + ```bash + hatch run dev:migrate + ``` 3. Run the development server -```bash -hatch run dev:server -``` + ```bash + hatch run dev:server + ``` #### Updating requirements diff --git a/src/membership/admin.py b/src/membership/admin.py index 2cf7030..4ee0163 100644 --- a/src/membership/admin.py +++ b/src/membership/admin.py @@ -5,6 +5,7 @@ from django.contrib import admin from .models import Membership from .models import MembershipType from .models import SubscriptionPeriod +from .models import WaitingListEntry @admin.register(Membership) @@ -20,3 +21,8 @@ class MembershipTypeAdmin(admin.ModelAdmin): @admin.register(SubscriptionPeriod) class SubscriptionPeriodAdmin(admin.ModelAdmin): """Admin for SubscriptionPeriod model.""" + + +@admin.register(WaitingListEntry) +class WaitingListEntryAdmin(admin.ModelAdmin): + """Admin for WaitingList model.""" 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..9c2d923 --- /dev/null +++ b/src/membership/migrations/0006_waitinglistentry_alter_membership_options.py @@ -0,0 +1,32 @@ +# Generated by Django 5.0.7 on 2024-07-20 20:45 + +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, default='', 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 502aa66..4fec013 100644 --- a/src/membership/models.py +++ b/src/membership/models.py @@ -139,3 +139,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, default="") + 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") diff --git a/src/pytest.ini b/src/pytest.ini deleted file mode 100644 index 9929fa7..0000000 --- a/src/pytest.ini +++ /dev/null @@ -1,5 +0,0 @@ -[pytest] -testpaths = . -python_files = tests.py test_*.py *_tests.py -DJANGO_SETTINGS_MODULE = project.settings -#norecursedirs = dist tmp* .svn .*