From b7742b562989c3c01e0c39e6c149416d672c7222 Mon Sep 17 00:00:00 2001 From: Benni Baermann Date: Mon, 8 Feb 2021 14:46:38 +0100 Subject: [PATCH] added field for laptop vendor --- evapp/forms.py | 2 +- evapp/migrations/0005_employee_vendor.py | 18 ++++++++++++++++++ evapp/models.py | 5 +++++ evapp/views.py | 4 ++-- 4 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 evapp/migrations/0005_employee_vendor.py diff --git a/evapp/forms.py b/evapp/forms.py index 7dc45b3..5a8864d 100644 --- a/evapp/forms.py +++ b/evapp/forms.py @@ -41,7 +41,7 @@ class ITForm(EvaForm): class Meta: model = Employee fields = [ - 'laptop', 'os', 'screen', 'mobile', 'landline', 'comment', + 'laptop', 'vendor', 'os', 'screen', 'mobile', 'landline', 'comment', 'language', 'accounts', 'lists', ] class OfficeForm(EvaForm): diff --git a/evapp/migrations/0005_employee_vendor.py b/evapp/migrations/0005_employee_vendor.py new file mode 100644 index 0000000..1baf85d --- /dev/null +++ b/evapp/migrations/0005_employee_vendor.py @@ -0,0 +1,18 @@ +# Generated by Django 3.1.4 on 2021-02-08 13:45 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('evapp', '0004_employee_intern'), + ] + + operations = [ + migrations.AddField( + model_name='employee', + name='vendor', + field=models.CharField(choices=[('STANDARD', 'Dell Latitude'), ('LENOVO', 'Lenovo Thinkpad'), ('MAC', 'Mac (nur in Ausnahmefällen)')], default='STANDARD', max_length=8), + ), + ] diff --git a/evapp/models.py b/evapp/models.py index 8e1cf14..8837349 100644 --- a/evapp/models.py +++ b/evapp/models.py @@ -13,6 +13,10 @@ DEPARTMENT_CHOICES = {'PROG': 'Programme', LAPTOP_CHOICES = {'14': '14", unser Standardgerät', '12': '12,5", geeignet für Vielreisende',} +VENDOR_CHOICES = {'STANDARD': 'Dell Latitude', + 'LENOVO': 'Lenovo Thinkpad', + 'MAC': 'Mac (nur in Ausnahmefällen)'} + OS_CHOICES = {'UBU': 'Ubuntu (Standard)', 'WIN': 'Windows (bitte Begründung angeben)',} @@ -57,6 +61,7 @@ class Employee(models.Model): # IT related stuff laptop = models.CharField(max_length=2, choices=LAPTOP_CHOICES.items(), default='14') + vendor = models.CharField(max_length=8, choices=VENDOR_CHOICES.items(), default='STANDARD') os = models.CharField(max_length=3, choices=OS_CHOICES.items(), default='UBU') screen = models.BooleanField(default=False, verbose_name='zusätzlicher Monitor? Einer ist standard.') mobile = models.CharField(max_length=6, default='NO') diff --git a/evapp/views.py b/evapp/views.py index ffa9385..8e4dbc6 100644 --- a/evapp/views.py +++ b/evapp/views.py @@ -9,7 +9,7 @@ from django.template.loader import get_template from formtools.wizard.views import CookieWizardView from django.shortcuts import render -from .models import Employee, DEPARTMENT_CHOICES, LAPTOP_CHOICES, OS_CHOICES,\ +from .models import Employee, DEPARTMENT_CHOICES, LAPTOP_CHOICES, OS_CHOICES, VENDOR_CHOICES, \ MOBILE_CHOICES, LANG_CHOICES, ACCOUNT_CHOICES, TRANSPONDER_CHOICES from .forms import PersonalForm, WorkingForm, ITForm, OfficeForm, DummyForm,\ ChangeForm, TYPE_CHOICES @@ -144,7 +144,7 @@ class EvaFormView(CookieWizardView): # update values in data dictionary with keys from *_CHOICES if present there choices = {**DEPARTMENT_CHOICES, **LAPTOP_CHOICES, **TRANSPONDER_CHOICES, - **OS_CHOICES, **MOBILE_CHOICES, **LANG_CHOICES,} + **OS_CHOICES, **MOBILE_CHOICES, **LANG_CHOICES, **VENDOR_CHOICES} data.update({k:choices[v] for k,v in data.items() \ if isinstance(v,collections.abc.Hashable) \ and v in choices})