forked from data.coop/membersystem
Merge branch 'waiting-list' into payment-updates
This commit is contained in:
commit
e27bc7969d
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -8,3 +8,7 @@ db.sqlite3
|
|||
.env
|
||||
venv/
|
||||
.venv/
|
||||
|
||||
|
||||
# collectstatic
|
||||
src/static/
|
||||
|
|
16
Dockerfile
16
Dockerfile
|
@ -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"]
|
||||
|
||||
|
|
10
Makefile
10
Makefile
|
@ -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
|
||||
|
|
54
README.md
54
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,22 +65,22 @@ 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
|
||||
```
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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."""
|
||||
|
|
|
@ -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'},
|
||||
),
|
||||
]
|
|
@ -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")
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
[pytest]
|
||||
testpaths = .
|
||||
python_files = tests.py test_*.py *_tests.py
|
||||
DJANGO_SETTINGS_MODULE = project.settings
|
||||
#norecursedirs = dist tmp* .svn .*
|
Loading…
Reference in a new issue