Merge branch 'waiting-list' into payment-updates

This commit is contained in:
Benjamin Bach 2024-07-21 16:11:53 +02:00
commit e27bc7969d
No known key found for this signature in database
GPG key ID: 486F0D69C845416E
10 changed files with 117 additions and 46 deletions

4
.gitignore vendored
View file

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

View file

@ -15,9 +15,7 @@ WORKDIR /app
RUN groupadd -g 1000 www && useradd -u 1000 -ms /bin/bash -g www www
COPY --chown=www:www . .
RUN mkdir /app/src/static && \
chown www:www /app/src/static && \
apt-get update && \
RUN apt-get update && \
apt-get install -y \
binutils \
libpq-dev \
@ -29,9 +27,15 @@ RUN mkdir /app/src/static && \
libgdk-pixbuf2.0-0 \
libffi-dev \
shared-mime-info \
gettext && \
pip install --no-cache-dir -r $REQUIREMENTS_FILE && \
django-admin compilemessages
gettext
COPY --chown=www:www . .
RUN mkdir /app/src/static && \
chown www:www /app/src/static
RUN pip install --no-cache-dir -r $REQUIREMENTS_FILE
RUN django-admin compilemessages
ENTRYPOINT ["./entrypoint.sh"]

View file

@ -1,12 +1,17 @@
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}
run:
${DOCKER_COMPOSE} up
pre_commit_install:
venv/bin/pre-commit install
pre_commit_run_all:
venv/bin/pre-commit run --all-files
makemigrations:
${MANAGE_COMMAND} makemigrations ${ARGS}
@ -21,3 +26,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.
@ -41,6 +40,19 @@ make migrate
make run
```
#### Building and running other things
```bash
# 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
#### Requirements

View file

@ -1,4 +1,3 @@
---
services:
app:
build:
@ -12,7 +11,8 @@ services:
volumes:
- ./:/app/
depends_on:
- postgres
postgres:
condition: service_healthy
env_file:
- .env
@ -24,6 +24,13 @@ services:
- 5432:5432
env_file:
- .env
# This healthcheck has a large number of retries, this is currently based on the number of
# retries necessary to get the database running in GitHub Actions.
healthcheck:
test: [ "CMD-SHELL", "pg_isready -U postgres -d postgres" ]
interval: 5s
timeout: 5s
retries: 30
volumes:
postgres_data:

View file

@ -1,16 +1,5 @@
#!/bin/sh
echo "Waiting for postgres..."
POSTGRES_PORT=${POSTGRES_PORT:-5432}
POSTGRES_HOST=${POSTGRES_HOST:-localhost}
while ! nc -z "$POSTGRES_HOST" "$POSTGRES_PORT"; do
sleep 0.1
done
echo "PostgreSQL started"
# Only migrate, collectstatic and compilemessages if we are NOT in development
if [ -z "$DEBUG" ]; then
python src/manage.py migrate;

View file

@ -36,3 +36,8 @@ class MemberAdmin(UserAdmin):
"""Member admin is actually an admin for User objects."""
inlines = (MembershipInlineAdmin,)
@admin.register(models.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

@ -153,3 +153,18 @@ class MembershipType(CreatedModifiedAbstract):
user=user,
period=get_current_subscription_period(),
)
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 .*