New WaitingListEntry (#33)
All checks were successful
continuous-integration/drone/push Build is passing

Sorted the pre-commit things... some were because of `src/static` being included, and some have been fixed in another PR 🎉

Reviewed-on: #33
Reviewed-by: valberg <valberg@orn.li>
Co-authored-by: Benjamin Bach <benjamin@overtag.dk>
Co-committed-by: Benjamin Bach <benjamin@overtag.dk>
This commit is contained in:
Benjamin Bach 2024-07-31 22:49:46 +00:00 committed by valberg
parent 0cf579c5f6
commit 865bc6c7bd
7 changed files with 93 additions and 27 deletions

4
.gitignore vendored
View file

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

View file

@ -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

View file

@ -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

View file

@ -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."""

View file

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

View file

@ -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")

View file

@ -1,5 +0,0 @@
[pytest]
testpaths = .
python_files = tests.py test_*.py *_tests.py
DJANGO_SETTINGS_MODULE = project.settings
#norecursedirs = dist tmp* .svn .*