Changes to payment models #32

Merged
valberg merged 35 commits from benjaoming/membersystem:payment-updates into main 2024-08-03 17:55:33 +00:00
10 changed files with 117 additions and 46 deletions
Showing only changes of commit e27bc7969d - 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

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

View file

@ -1,12 +1,17 @@
DOCKER_COMPOSE = COMPOSE_DOCKER_CLI_BUILD=1 DOCKER_BUILDKIT=1 docker compose DOCKER_COMPOSE = COMPOSE_DOCKER_CLI_BUILD=1 DOCKER_BUILDKIT=1 docker compose
DOCKER_RUN = ${DOCKER_COMPOSE} run -u `id -u` DOCKER_RUN = ${DOCKER_COMPOSE} run -u `id -u`
DOCKER_BUILD = DOCKER_BUILDKIT=1 docker build
MANAGE_EXEC = python /app/src/manage.py MANAGE_EXEC = python /app/src/manage.py
MANAGE_COMMAND = ${DOCKER_RUN} app ${MANAGE_EXEC} MANAGE_COMMAND = ${DOCKER_RUN} app ${MANAGE_EXEC}
run: run:
${DOCKER_COMPOSE} up ${DOCKER_COMPOSE} up
pre_commit_install:
venv/bin/pre-commit install
pre_commit_run_all:
venv/bin/pre-commit run --all-files
makemigrations: makemigrations:
${MANAGE_COMMAND} makemigrations ${ARGS} ${MANAGE_COMMAND} makemigrations ${ARGS}
@ -21,3 +26,6 @@ shell:
manage_command: manage_command:
${MANAGE_COMMAND} ${ARGS} ${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 the Docker Compose setup provided in this repository.
- Using [hatch](https://hatch.pypa.io/) in your host OS. - Using [hatch](https://hatch.pypa.io/) in your host OS.
### Using Docker Compose ### Using Docker Compose
Working with the Docker Compose setup is made easy with the `Makefile` provided in the repository. 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 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 ```bash
cp .env.example .env 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 2. Migrate
```bash ```bash
make migrate make migrate
``` ```
3. Run the development server 3. Run the development server
```bash
make run
```
#### Building and running other things
```bash ```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 ### Using hatch
@ -53,22 +65,22 @@ make run
1. Setup .env file 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 ```bash
cp .env.example .env 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 2. Run migrate
```bash ```bash
hatch run dev:migrate hatch run dev:migrate
``` ```
3. Run the development server 3. Run the development server
```bash ```bash
hatch run dev:server hatch run dev:server
``` ```

View file

@ -1,4 +1,3 @@
---
services: services:
app: app:
build: build:
@ -12,7 +11,8 @@ services:
volumes: volumes:
- ./:/app/ - ./:/app/
depends_on: depends_on:
- postgres postgres:
condition: service_healthy
env_file: env_file:
- .env - .env
@ -24,6 +24,13 @@ services:
- 5432:5432 - 5432:5432
env_file: env_file:
- .env - .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: volumes:
postgres_data: postgres_data:

View file

@ -1,16 +1,5 @@
#!/bin/sh #!/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 # Only migrate, collectstatic and compilemessages if we are NOT in development
if [ -z "$DEBUG" ]; then if [ -z "$DEBUG" ]; then
python src/manage.py migrate; python src/manage.py migrate;

View file

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