Compare commits

..

No commits in common. "80577d89de49bb0219e98b9528519a209858dd66" and "982ba5a676af6a6decf977638837696b5503b85d" have entirely different histories.

11 changed files with 34 additions and 102 deletions

1
.gitignore vendored
View File

@ -136,4 +136,3 @@ GitHub.sublime-settings
!.vscode/launch.json !.vscode/launch.json
!.vscode/extensions.json !.vscode/extensions.json
.history .history
.vs/*

View File

@ -12,8 +12,7 @@ https://docs.djangoproject.com/en/5.2/ref/settings/
import pymysql import pymysql
pymysql.install_as_MySQLdb() pymysql.install_as_MySQLdb()
from pathlib import Path from pathlib import Path
from decouple import config, Csv from decouple import config
# Build paths inside the project like this: BASE_DIR / 'subdir'. # Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent BASE_DIR = Path(__file__).resolve().parent.parent
@ -28,7 +27,7 @@ SECRET_KEY = 'django-insecure-tulz*odc=l1x(g^-=ne!y7^@lg1uce)=ha^!0wi5qkifq&#^sg
# SECURITY WARNING: don't run with debug turned on in production! # SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True DEBUG = True
ALLOWED_HOSTS = config("DJANGO_ALLOWED_HOSTS", default="localhost", cast=Csv()) ALLOWED_HOSTS = [ "albani.sternbauer.de" ]
# Application definition # Application definition
@ -126,10 +125,6 @@ USE_TZ = True
STATIC_URL = 'static/' STATIC_URL = 'static/'
STATICFILES_DIRS = [
BASEDIR / "static"
]
# Default primary key field type # Default primary key field type
# https://docs.djangoproject.com/en/5.2/ref/settings/#default-auto-field # https://docs.djangoproject.com/en/5.2/ref/settings/#default-auto-field

View File

@ -13,19 +13,12 @@ class PersonForm(forms.ModelForm):
class AccountForm(forms.ModelForm): class AccountForm(forms.ModelForm):
password=forms.CharField(widget=forms.PasswordInput(), required=False) password=forms.CharField(widget=forms.PasswordInput())
confirm_password=forms.CharField(widget=forms.PasswordInput(), required=False) confirm_password=forms.CharField(widget=forms.PasswordInput())
class Meta: class Meta:
model = UserAccount model = UserAccount
fields = ['username', 'password', 'role'] fields = ['username', 'password']
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
if self.instance.pk is None:
self.fields['password'].required=True
self.fields['confirm_password'].required=True
def clean(self): def clean(self):
cleaned_data = super(AccountForm, self).clean() cleaned_data = super(AccountForm, self).clean()
@ -35,13 +28,3 @@ class AccountForm(forms.ModelForm):
if passwordStr != confirm_passwordStr: if passwordStr != confirm_passwordStr:
raise forms.ValidateError("password and confirm_password does not match") raise forms.ValidateError("password and confirm_password does not match")
def save(self, commit=True):
user = super().save(commit=False)
pw = self.cleaned_data.get("password")
if pw:
user.set_password(pw)
if commit:
user.save()
return user

View File

@ -1,18 +0,0 @@
# Generated by Django 5.2.1 on 2025-07-18 15:12
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('member', '0002_alter_useraccount_options_alter_useraccount_managers_and_more'),
]
operations = [
migrations.AlterField(
model_name='useraccount',
name='role',
field=models.CharField(choices=[('mitglied', 'Mitglied'), ('geraetewart', 'Gerätewart'), ('kommandant', 'Kommandant'), ('admin', 'Administrator'), ('superadmin', 'Superadministrator')], default='mitglied', max_length=50),
),
]

View File

@ -11,9 +11,7 @@ class UserAccount(AbstractUser):
('geraetewart', 'Gerätewart'), ('geraetewart', 'Gerätewart'),
('kommandant', 'Kommandant'), ('kommandant', 'Kommandant'),
('admin', 'Administrator'), ('admin', 'Administrator'),
('superadmin', 'Superadministrator'), ])
], default='mitglied')
def __str__(self): def __str__(self):
return f"{self.benutzername} ({self.rolle})" return f"{self.benutzername} ({self.rolle})"

View File

@ -16,10 +16,6 @@
<label for="{{form.password.id_for_label}}">Password (confirmation)</label> <label for="{{form.password.id_for_label}}">Password (confirmation)</label>
{{form.confirm_password}} {{form.confirm_password}}
</div> </div>
<div class="form-group">
<label for="{{form.role.id_for_label}}">Rolle</label>
{{form.role}}
</div>
<button class="button" type="submit">Speichern</button> <button class="button" type="submit">Speichern</button>
<a href="{% url 'details' id %}" class="button" style="background:#444;">Abbrechen</a> <a href="{% url 'details' id %}" class="button" style="background:#444;">Abbrechen</a>
</form> </form>

View File

@ -1,10 +1,10 @@
{% extends "master.html" %} {% extends "master.html" %}
{% load static %} {% load static %}
{% load svg %}
{% block title %} {% block title %}
Details zu {{ mymember.vorname }} {{ mymember.nachname }} Details zu {{ mymember.firstname }} {{ mymember.lastname }}
{% endblock %} {% endblock %}
{% block content %} {% block content %}
@ -13,10 +13,31 @@
<p>Geburtsdatum: {{ mymember.geburtsdatum }}</p> <p>Geburtsdatum: {{ mymember.geburtsdatum }}</p>
<div class="mb-4"> <table>
<h2 class="h5">Accounts</h2> <thead>
{% include "partials/account_table.html" %} <tr>
</div> <th>Name</th>
<th>Rolle</th>
<th>Aktiv</th>
<th>Aktionen</th>
</tr>
</thead>
<tbody>
{% for x in accounts %}
<tr>
<td>{{ x.username }}</td>
<td>{{ x.rolle }}</td>
<td>{% if x.aktiv %}{% inline_svg 'icons/uxwing/check.svg' 'icon' %}{% endif %}</td>
<td><a href="{% url 'edit_account' x.id %}" title="Bearbeiten"><img src="{% static 'icons/heroicons/pencil.svg'%}" class="icon"></a> <a href="{% url 'delete_account' x.id %}" title="Löschen"><img src="{% static 'icons/heroicons/trash.svg'%}" class="icon"></a></td>
</tr>
{% endfor %}
<tr>
<td colspan="4">
<a href="{% url 'create_account' mymember.id %}" class="button"><img src="{% static 'icons/heroicons/plus.svg'%}" class="icon"> Konto hinzufügen</a>
</td>
</tr>
</tbody>
</table>
<p>Back to <a href="/members">Members</a></p> <p>Back to <a href="/members">Members</a></p>

View File

@ -3,7 +3,6 @@
<html> <html>
<head> <head>
<title>{% block title %}{% endblock %}</title> <title>{% block title %}{% endblock %}</title>
<link rel="stylesheet" href="{% static 'css/bootstrap.min.css' %}">
<link rel="stylesheet" href="{% static 'member/css/styles.css' %}"> <link rel="stylesheet" href="{% static 'member/css/styles.css' %}">
</head> </head>
<body> <body>

View File

@ -1,28 +0,0 @@
{% load static %}
{% load svg %}
<table>
<thead>
<tr>
<th>Name</th>
<th>Rolle</th>
<th>Aktiv</th>
<th>Aktionen</th>
</tr>
</thead>
<tbody>
{% for x in accounts %}
<tr>
<td>{{ x.username }}</td>
<td>{{ x.rolle }}</td>
<td>{% if x.aktiv %}{% inline_svg 'icons/uxwing/check.svg' 'icon' %}{% endif %}</td>
<td><a href="{% url 'edit_account' x.id %}" title="Bearbeiten"><img src="{% static 'icons/heroicons/pencil.svg'%}" class="icon"></a> <a href="{% url 'delete_account' x.id %}" title="Löschen"><img src="{% static 'icons/heroicons/trash.svg'%}" class="icon"></a></td>
</tr>
{% endfor %}
<tr>
<td colspan="4">
<a href="{% url 'create_account' mymember.id %}" class="button"><img src="{% static 'icons/heroicons/plus.svg'%}" class="icon"> Konto hinzufügen</a>
</td>
</tr>
</tbody>
</table>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long