From 6a2dc6f1c9f501618bd841c4fc177112e1bee3c7 Mon Sep 17 00:00:00 2001 From: Benni Baermann Date: Thu, 8 Jul 2021 08:00:28 +0200 Subject: [PATCH] accounts now user editable in own table --- input/admin.py | 4 ++-- input/migrations/0063_auto_20210708_0553.py | 23 +++++++++++++++++++ input/migrations/0064_alter_accounts_code.py | 18 +++++++++++++++ .../0065_rename_accounts_account.py | 17 ++++++++++++++ input/models.py | 11 +++++---- 5 files changed, 66 insertions(+), 7 deletions(-) create mode 100644 input/migrations/0063_auto_20210708_0553.py create mode 100644 input/migrations/0064_alter_accounts_code.py create mode 100644 input/migrations/0065_rename_accounts_account.py diff --git a/input/admin.py b/input/admin.py index 334c32e..48c3af7 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 Accounts, Project, HonoraryCertificate, Library, IFG, Travel,\ +from .models import Account, Project, HonoraryCertificate, Library, IFG, Travel,\ Email, BusinessCard, List, Literature @@ -35,7 +35,7 @@ class ProjectAdmin(admin.ModelAdmin): admin.site.register([ - Accounts, + Account, HonoraryCertificate, Library, IFG, diff --git a/input/migrations/0063_auto_20210708_0553.py b/input/migrations/0063_auto_20210708_0553.py new file mode 100644 index 0000000..cba8e8f --- /dev/null +++ b/input/migrations/0063_auto_20210708_0553.py @@ -0,0 +1,23 @@ +# Generated by Django 3.2.5 on 2021-07-08 05:53 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('input', '0062_auto_20210707_1314'), + ] + + operations = [ + migrations.RenameField( + model_name='accounts', + old_name='acc', + new_name='code', + ), + migrations.AddField( + model_name='accounts', + name='description', + field=models.CharField(default='NO DESCRIPTION', max_length=30, verbose_name='Beschreibung'), + ), + ] diff --git a/input/migrations/0064_alter_accounts_code.py b/input/migrations/0064_alter_accounts_code.py new file mode 100644 index 0000000..3ffaeab --- /dev/null +++ b/input/migrations/0064_alter_accounts_code.py @@ -0,0 +1,18 @@ +# Generated by Django 3.2.5 on 2021-07-08 05:55 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('input', '0063_auto_20210708_0553'), + ] + + operations = [ + migrations.AlterField( + model_name='accounts', + name='code', + field=models.CharField(default='DEF', max_length=5, primary_key=True, serialize=False, verbose_name='Kostenstelle'), + ), + ] diff --git a/input/migrations/0065_rename_accounts_account.py b/input/migrations/0065_rename_accounts_account.py new file mode 100644 index 0000000..84c26c9 --- /dev/null +++ b/input/migrations/0065_rename_accounts_account.py @@ -0,0 +1,17 @@ +# Generated by Django 3.2.5 on 2021-07-08 05:58 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('input', '0064_alter_accounts_code'), + ] + + operations = [ + migrations.RenameModel( + old_name='Accounts', + new_name='Account', + ), + ] diff --git a/input/models.py b/input/models.py index 8a5c535..5203aee 100644 --- a/input/models.py +++ b/input/models.py @@ -50,12 +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) +class Account(models.Model): + code = models.CharField('Kostenstelle', max_length=5, default="DEF", + null=False, primary_key = True) + description = models.CharField('Beschreibung', max_length=30, default='NO DESCRIPTION') def __str__(self): - return f"{ACCOUNTS[self.acc]}" + return f"{self.code} {self.description}" class Project(Volunteer): name = models.CharField(max_length=200, verbose_name='Name des Projekts') @@ -74,7 +75,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.ForeignKey('Accounts', on_delete=models.CASCADE, null=True, to_field='acc') + account = models.ForeignKey('Account', on_delete=models.CASCADE, null=True, to_field='code') 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')