From cdb27e6b8929a817fc9d2c4bce34ac8111a00435 Mon Sep 17 00:00:00 2001 From: Benni Baermann Date: Wed, 7 Jul 2021 15:16:39 +0200 Subject: [PATCH] first steps to editable accounts --- TODO | 2 +- input/admin.py | 3 ++- input/migrations/0062_auto_20210707_1314.py | 25 +++++++++++++++++++++ input/models.py | 10 +++++++-- input/settings.py | 1 + 5 files changed, 37 insertions(+), 4 deletions(-) create mode 100644 input/migrations/0062_auto_20210707_1314.py diff --git a/TODO b/TODO index c236669..f202c49 100644 --- a/TODO +++ b/TODO @@ -2,7 +2,7 @@ known bugs: - there is html-code in some plain text mails, because they use models.TYPE_CHOICES, which is in html, because it is mainly used for the - website side of things. + webside side of things. - helptext by /intern email: "Bitte gib deine E-Mail-Adresse ein, damit dich Wikimedia Deutschland bei Rückfragen oder für diff --git a/input/admin.py b/input/admin.py index 82da6f7..334c32e 100644 --- a/input/admin.py +++ b/input/admin.py @@ -3,7 +3,7 @@ import csv from django.contrib import admin from django.http import HttpResponse -from .models import Project, HonoraryCertificate, Library, IFG, Travel,\ +from .models import Accounts, Project, HonoraryCertificate, Library, IFG, Travel,\ Email, BusinessCard, List, Literature @@ -35,6 +35,7 @@ class ProjectAdmin(admin.ModelAdmin): admin.site.register([ + Accounts, HonoraryCertificate, Library, IFG, diff --git a/input/migrations/0062_auto_20210707_1314.py b/input/migrations/0062_auto_20210707_1314.py new file mode 100644 index 0000000..6e5279e --- /dev/null +++ b/input/migrations/0062_auto_20210707_1314.py @@ -0,0 +1,25 @@ +# Generated by Django 3.2.5 on 2021-07-07 13:14 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('input', '0061_concretevolunteer'), + ] + + operations = [ + migrations.CreateModel( + name='Accounts', + fields=[ + ('acc', models.CharField(choices=[('DEF', 'DEFAULT VALUE, you hould not see this!'), ('21111', '21111 Förderung (reaktiv)'), ('21112', '21112 WikiCon'), ('21115', '21115 Lokale Räume, Berlin'), ('21116', '21116 Lokale Räume, Hamburg'), ('21117', '21117 Lokale Räume, Hannover'), ('21118', '21118 Lokale Räume, Köln'), ('21119', '21119 Lokale Räume, München'), ('21120', '21120 Lokale Räume, Fürth'), ('21125', '21125 Lokale Räume, allgemein'), ('21130', '21130 GLAM-Förderung'), ('21131', '21131 Initiative Förderung'), ('21140', '21140 Wikipedia-Kampagne'), ('21141', '21141 Wikipedia-Onboarding'), ('21150', '21150 Fürsorge und Online-Kommunikationskultur')], default='DEF', max_length=5, primary_key=True, serialize=False, verbose_name='Kostenstelle')), + ], + ), + migrations.AlterField( + model_name='project', + name='account', + field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='input.accounts'), + ), + ] diff --git a/input/models.py b/input/models.py index c0d623c..8a5c535 100644 --- a/input/models.py +++ b/input/models.py @@ -50,6 +50,13 @@ class ConcreteExtern(Extern): ''' needed because we can't initiate abstract base classes in the view''' pass +class Accounts(models.Model): + acc = models.CharField('Kostenstelle', max_length=5, default="DEF", + choices=ACCOUNTS.items(), null=False, primary_key = True) + + def __str__(self): + return f"{ACCOUNTS[self.acc]}" + class Project(Volunteer): name = models.CharField(max_length=200, verbose_name='Name des Projekts') description = models.CharField(max_length=500, verbose_name="Kurzbeschreibung", null=True) @@ -67,8 +74,7 @@ class Project(Volunteer): insurance_technic = models.BooleanField(default=False, verbose_name='Technikversicherung Ausland') support = models.CharField(max_length=300, blank=True, null=True, verbose_name='Betreuungsperson und Vertretung') cost = models.IntegerField(blank=True, null=True) - account = models.CharField('Kostenstelle', max_length=5, - choices=ACCOUNTS.items(), null=True,) + account = models.ForeignKey('Accounts', on_delete=models.CASCADE, null=True, to_field='acc') granted_from = models.CharField(max_length=100,null=True,verbose_name='Bewilligt von') notes = models.CharField(max_length=1000,null=True,blank=True,verbose_name='Anmerkungen') diff --git a/input/settings.py b/input/settings.py index cf3a361..eacac3f 100644 --- a/input/settings.py +++ b/input/settings.py @@ -12,6 +12,7 @@ NUTZUNGSBEDINGUNGEN = 'static/input/nutzungsbedingungen.html' ACCOUNTS ={ # "21103": '21103 Willkommen', + "DEF": 'DEFAULT VALUE, you hould not see this!', "21111": '21111 Förderung (reaktiv)', "21112": '21112 WikiCon', # "21113": '21113 Wikimania/Unterstützung Ehrenamtliche',