Compare commits

..

1 commit

Author SHA1 Message Date
9c7fd408e8 add basic testdata
All checks were successful
/ test (push) Successful in 2m43s
2024-12-21 20:36:51 +01:00
4 changed files with 38 additions and 42 deletions

View file

@ -125,12 +125,19 @@ TEMPLATES = [
}, },
] ]
ASGI_APPLICATION = 'core.asgi.application' WSGI_APPLICATION = 'core.wsgi.application'
# Database # Database
# https://docs.djangoproject.com/en/4.2/ref/settings/#databases # https://docs.djangoproject.com/en/4.2/ref/settings/#databases
if os.getenv('DB_HOST') is not None: if 'test' in sys.argv:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': ':memory:',
}
}
else:
DATABASES = { DATABASES = {
'default': { 'default': {
'ENGINE': 'django.db.backends.mysql', 'ENGINE': 'django.db.backends.mysql',
@ -143,20 +150,6 @@ if os.getenv('DB_HOST') is not None:
'charset': 'utf8mb4', 'charset': 'utf8mb4',
'init_command': "SET sql_mode='STRICT_TRANS_TABLES'" 'init_command': "SET sql_mode='STRICT_TRANS_TABLES'"
} }
},
}
elif os.getenv('DB_FILE') is not None:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.getenv('DB_FILE', 'local.db'),
}
}
else:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': ':memory:',
} }
} }

View file

@ -6,12 +6,18 @@ services:
command: bash -c 'python manage.py migrate && python testdata.py && python manage.py runserver 0.0.0.0:8000' command: bash -c 'python manage.py migrate && python testdata.py && python manage.py runserver 0.0.0.0:8000'
environment: environment:
- HTTP_HOST=core - HTTP_HOST=core
- DB_FILE=dev.db - DB_HOST=db
- DB_PORT=3306
- DB_NAME=system3
- DB_USER=system3
- DB_PASSWORD=system3
volumes: volumes:
- ../../core:/code - ../../core:/code
- ../testdata.py:/code/testdata.py - ../testdata.py:/code/testdata.py
ports: ports:
- "8000:8000" - "8000:8000"
depends_on:
- db
frontend: frontend:
build: build:
@ -26,3 +32,18 @@ services:
- "8080:8080" - "8080:8080"
depends_on: depends_on:
- core - core
db:
image: mariadb
environment:
MARIADB_RANDOM_ROOT_PASSWORD: true
MARIADB_DATABASE: system3
MARIADB_USER: system3
MARIADB_PASSWORD: system3
volumes:
- mariadb_data:/var/lib/mysql
ports:
- "3306:3306"
volumes:
mariadb_data:

View file

@ -29,7 +29,6 @@ services:
- DB_NAME=system3 - DB_NAME=system3
- DB_USER=system3 - DB_USER=system3
- DB_PASSWORD=system3 - DB_PASSWORD=system3
- MAIL_DOMAIN=mail:1025
volumes: volumes:
- ../../core:/code - ../../core:/code
- ../testdata.py:/code/testdata.py - ../testdata.py:/code/testdata.py
@ -38,7 +37,6 @@ services:
depends_on: depends_on:
- db - db
- redis - redis
- mail
frontend: frontend:
build: build:
@ -54,19 +52,5 @@ services:
depends_on: depends_on:
- core - core
mail:
image: docker.io/axllent/mailpit
volumes:
- mailpit_data:/data
ports:
- 8025:8025
- 1025:1025
environment:
MP_MAX_MESSAGES: 5000
MP_DATABASE: /data/mailpit.db
MP_SMTP_AUTH_ACCEPT_ANY: 1
MP_SMTP_AUTH_ALLOW_INSECURE: 1
volumes: volumes:
mariadb_data: mariadb_data:
mailpit_data:

View file

@ -1,7 +1,6 @@
<template> <template>
<AsyncLoader :loaded="events.length > 0"> <AsyncLoader :loaded="events.length > 0">
<ExpandableTable v-if="!!events" :columns="['slug', 'name']" :items="events.map((e,i)=>({idx: i, ...e}))" <ExpandableTable v-if="!!events" :columns="['slug', 'name']" :items="events" :keyName="'slug'">
:keyName="'slug'">
<template v-slot:header_actions> <template v-slot:header_actions>
<button class="btn btn-success" @click.prevent="openAddEventModal"> <button class="btn btn-success" @click.prevent="openAddEventModal">
<font-awesome-icon icon="plus"/> <font-awesome-icon icon="plus"/>
@ -44,7 +43,7 @@
<div class="mt-3"> <div class="mt-3">
<label class="mr-3">Addresses: </label> <label class="mr-3">Addresses: </label>
<div v-for="(address, a_id) in item.addresses" class="btn-group btn-group-sm mr-3" <div v-for="(address, a_id) in item.addresses" class="btn-group btn-group-sm mr-3"
@click.stop="deleteAddress(item.idx, a_id)"> @click.stop="deleteAddress(id, a_id)">
<button class="btn btn-secondary" disabled style="opacity: 1"> <button class="btn btn-secondary" disabled style="opacity: 1">
{{ address }} {{ address }}
</button> </button>
@ -53,9 +52,8 @@
</button> </button>
</div> </div>
<div class="btn-group btn-group-sm"> <div class="btn-group btn-group-sm">
<input type="text" v-model="new_address[item.idx]"> <input type="text" v-model="new_address[id]">
<button class="btn btn-secondary" @click.stop="addAddress(item.idx)" <button class="btn btn-secondary" @click.stop="addAddress(id)" style="white-space: nowrap;">
style="white-space: nowrap;">
<font-awesome-icon icon="envelope"/>&nbsp;add <font-awesome-icon icon="envelope"/>&nbsp;add
</button> </button>
</div> </div>
@ -90,11 +88,11 @@ export default {
if (!this.events[id].addresses.includes(a)) if (!this.events[id].addresses.includes(a))
this.events[id].addresses.push(a) this.events[id].addresses.push(a)
this.new_address[id] = "" this.new_address[id] = ""
this.updateEvent({id: this.events[id].id, partial_event: {addresses: this.events[id].addresses}}); this.updateEvent({id: this.events[id].eid, partial_event: {addresses: this.events[id].addresses}});
}, },
deleteAddress(id, a_id) { deleteAddress(id, a_id) {
this.events[id].addresses = this.events[id].addresses.filter((e, i) => i !== a_id); this.events[id].addresses = this.events[id].addresses.filter((e, i) => i !== a_id);
this.updateEvent({id: this.events[id].id, partial_event: {addresses: this.events[id].addresses}}); this.updateEvent({id: this.events[id].eid, partial_event: {addresses: this.events[id].addresses}});
} }
}, },
}; };