From 63e6a6bdfdf813d1db891085ed0f4dc495de0eb0 Mon Sep 17 00:00:00 2001 From: Benni Baermann Date: Thu, 11 Mar 2021 14:49:29 +0100 Subject: [PATCH 01/32] added simple auth --- eva/urls.py | 1 + evapp/templates/registration/login.html | 35 +++++++++++++++++++++++++ evapp/views.py | 3 ++- 3 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 evapp/templates/registration/login.html diff --git a/eva/urls.py b/eva/urls.py index 9417d51..d243e82 100644 --- a/eva/urls.py +++ b/eva/urls.py @@ -19,4 +19,5 @@ from django.urls import path, include urlpatterns = [ path('', include("evapp.urls")), path('admin/', admin.site.urls), + path('accounts/', include('django.contrib.auth.urls')), ] diff --git a/evapp/templates/registration/login.html b/evapp/templates/registration/login.html new file mode 100644 index 0000000..cbceed1 --- /dev/null +++ b/evapp/templates/registration/login.html @@ -0,0 +1,35 @@ +{% block content %} + + {% if form.errors %} +

Your username and password didn't match. Please try again.

+ {% endif %} + + {% if next %} + {% if user.is_authenticated %} +

Your account doesn't have access to this page. To proceed, + please login with an account that has access.

+ {% else %} +

Please login to see this page.

+ {% endif %} + {% endif %} + +
+ {% csrf_token %} + + + + + + + + + +
{{ form.username.label_tag }}{{ form.username }}
{{ form.password.label_tag }}{{ form.password }}
+ + +
+ + {# Assumes you setup the password_reset view in your URLconf #} +

Lost password?

+ +{% endblock %} diff --git a/evapp/views.py b/evapp/views.py index 1227fc6..9e4fd76 100644 --- a/evapp/views.py +++ b/evapp/views.py @@ -9,6 +9,7 @@ from django.template.loader import get_template from formtools.wizard.views import CookieWizardView from django.shortcuts import render from django.conf import settings +from django.contrib.auth.mixins import LoginRequiredMixin from .models import Employee, DEPARTMENT_CHOICES, LAPTOP_CHOICES, OS_CHOICES, VENDOR_CHOICES, \ MOBILE_CHOICES, LANG_CHOICES, ACCOUNT_CHOICES, TRANSPONDER_CHOICES @@ -43,7 +44,7 @@ def change_process(wizard): return not long_process(wizard) -class EvaFormView(CookieWizardView): +class EvaFormView(LoginRequiredMixin, CookieWizardView): template_name = 'evapp/employee_form.html' form_list = [PersonalForm, WorkingForm, ITForm, OfficeForm, ChangeForm, DummyForm] instance = None From f99a3e0fdff59220067070863b0894ac75870a38 Mon Sep 17 00:00:00 2001 From: Benni Baermann Date: Mon, 15 Mar 2021 15:27:08 +0100 Subject: [PATCH 02/32] added email adress of user to model and form --- evapp/forms.py | 2 +- evapp/migrations/0009_auto_20210315_1408.py | 28 +++++++++++++++++++++ evapp/models.py | 6 ++++- 3 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 evapp/migrations/0009_auto_20210315_1408.py diff --git a/evapp/forms.py b/evapp/forms.py index 2e277db..862542b 100644 --- a/evapp/forms.py +++ b/evapp/forms.py @@ -29,7 +29,7 @@ class PersonalForm(EvaForm): class Meta: model = Employee - fields = ['firstname', 'lastname', 'intern', 'email', 'department', 'team', ] + fields = ['usermail', 'firstname', 'lastname', 'intern', 'email', 'department', 'team', ] class WorkingForm(EvaForm): diff --git a/evapp/migrations/0009_auto_20210315_1408.py b/evapp/migrations/0009_auto_20210315_1408.py new file mode 100644 index 0000000..d1c8c32 --- /dev/null +++ b/evapp/migrations/0009_auto_20210315_1408.py @@ -0,0 +1,28 @@ +# Generated by Django 3.1.4 on 2021-03-15 14:08 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('evapp', '0008_auto_20210301_1053'), + ] + + operations = [ + migrations.AddField( + model_name='employee', + name='usermail', + field=models.EmailField(default='bestechefin@wikimedia.de', max_length=50, verbose_name='Deine Mailadresse'), + ), + migrations.AlterField( + model_name='employee', + name='email', + field=models.EmailField(max_length=50, verbose_name='E-Mail-Adresse ders Mitarbeitenden'), + ), + migrations.AlterField( + model_name='employee', + name='laptop', + field=models.CharField(choices=[('14', '14", Unser Standardgerät'), ('12', '12,5", Geeignet für Vielreisende')], default='14', max_length=2), + ), + ] diff --git a/evapp/models.py b/evapp/models.py index 04a6f97..3984b84 100644 --- a/evapp/models.py +++ b/evapp/models.py @@ -43,11 +43,15 @@ TRANSPONDER_CHOICES = {'NORM': 'Allgemeiner Transponder', 'NOTRANS': 'Kein Transponder',} class Employee(models.Model): + + # email adress of user. should not be necessary if we use openauth one day + usermail = models.EmailField(max_length=50, verbose_name="Deine Mailadresse", default='bestechefin@wikimedia.de') + # personal data firstname = models.CharField(max_length=50, verbose_name="Vorname") lastname = models.CharField(max_length=50, verbose_name="Nachname") intern = models.BooleanField(verbose_name='Interne_r Mitarbeiter_in?', default=True) - email = models.EmailField(max_length=50, verbose_name="E-Mail-Adresse") + email = models.EmailField(max_length=50, verbose_name="E-Mail-Adresse ders Mitarbeitenden") department = models.CharField(max_length=5, choices=DEPARTMENT_CHOICES.items()) team = models.CharField(max_length=20, null=True, blank=True) # TODO? besser als choices? From d57100c8f5cdbeb66e1edd2615f3ef226a4b2194 Mon Sep 17 00:00:00 2001 From: Benni Baermann Date: Wed, 17 Mar 2021 10:43:26 +0100 Subject: [PATCH 03/32] mails will be send to usermail, too. --- evapp/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/evapp/views.py b/evapp/views.py index 9e4fd76..e1ec93c 100644 --- a/evapp/views.py +++ b/evapp/views.py @@ -134,7 +134,7 @@ class EvaFormView(LoginRequiredMixin, CookieWizardView): 'EVA: Neuzugang', mail_template.render(context), EVA_MAIL, - [MAILS[department]['MAIL']], + [MAILS[department]['MAIL'], self.instance.usermail], fail_silently=False) except BadHeaderError: self.instance.delete() From 9669d10e309b9e155a9ee364afabe7769668c252 Mon Sep 17 00:00:00 2001 From: Benni Baermann Date: Thu, 18 Mar 2021 13:49:14 +0100 Subject: [PATCH 04/32] reorganisation of settings/git for production --- .gitignore | 7 + eva/{settings.py => settings_development.py} | 0 eva/settings_production.py | 127 +++++++++++++++++++ 3 files changed, 134 insertions(+) rename eva/{settings.py => settings_development.py} (100%) create mode 100644 eva/settings_production.py diff --git a/.gitignore b/.gitignore index f59d43f..791ffdd 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,10 @@ +# secret passwords and so +/secrets.json +/staticfiles +/eva/settings.py +/nohup.out +/logfile + *~ # ---> Python diff --git a/eva/settings.py b/eva/settings_development.py similarity index 100% rename from eva/settings.py rename to eva/settings_development.py diff --git a/eva/settings_production.py b/eva/settings_production.py new file mode 100644 index 0000000..c2de6d1 --- /dev/null +++ b/eva/settings_production.py @@ -0,0 +1,127 @@ +""" +Django settings for eva project. + +Generated by 'django-admin startproject' using Django 3.1.4. + +For more information on this file, see +https://docs.djangoproject.com/en/3.1/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/3.1/ref/settings/ +""" + +from pathlib import Path + +# Build paths inside the project like this: BASE_DIR / 'subdir'. +BASE_DIR = Path(__file__).resolve().parent.parent + +# mails in development go to stdout +EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' + +# Quick-start development settings - unsuitable for production +# See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = 'g%+i6+gkwt3zz@+k-5x1dtstuw4)&qd$lxd^bt2oswy5e1#dul' + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = True + +STATIC_ROOT = BASE_DIR / 'staticfiles' + +ALLOWED_HOSTS = ['*'] + + +# Application definition + +INSTALLED_APPS = [ + 'evapp.apps.EvappConfig', + 'django.contrib.admin', + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.messages', + 'django.contrib.staticfiles', + 'multiselectfield', + 'formtools', +] + +MIDDLEWARE = [ + 'django.middleware.security.SecurityMiddleware', + 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.middleware.common.CommonMiddleware', + 'django.middleware.csrf.CsrfViewMiddleware', + 'django.contrib.auth.middleware.AuthenticationMiddleware', + 'django.contrib.messages.middleware.MessageMiddleware', + 'django.middleware.clickjacking.XFrameOptionsMiddleware', +] + +ROOT_URLCONF = 'eva.urls' + +TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [], + 'APP_DIRS': True, + 'OPTIONS': { + 'context_processors': [ + 'django.template.context_processors.debug', + 'django.template.context_processors.request', + 'django.contrib.auth.context_processors.auth', + 'django.contrib.messages.context_processors.messages', + ], + }, + }, +] + +WSGI_APPLICATION = 'eva.wsgi.application' + + +# Database +# https://docs.djangoproject.com/en/3.1/ref/settings/#databases + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': BASE_DIR / 'db.sqlite3', + } +} + + +# Password validation +# https://docs.djangoproject.com/en/3.1/ref/settings/#auth-password-validators + +AUTH_PASSWORD_VALIDATORS = [ + { + 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', + }, +] + + +# Internationalization +# https://docs.djangoproject.com/en/3.1/topics/i18n/ + +LANGUAGE_CODE = 'en-us' + +TIME_ZONE = 'UTC' + +USE_I18N = True + +USE_L10N = True + +USE_TZ = True + + +# Static files (CSS, JavaScript, Images) +# https://docs.djangoproject.com/en/3.1/howto/static-files/ + +STATIC_URL = '/static/' From abd7885abf5b0f73c77a8b13c92c1da35e8c93ef Mon Sep 17 00:00:00 2001 From: Benni Baermann Date: Thu, 18 Mar 2021 14:12:46 +0100 Subject: [PATCH 05/32] secrets and mail config in production --- eva/settings_production.py | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/eva/settings_production.py b/eva/settings_production.py index c2de6d1..4c649ab 100644 --- a/eva/settings_production.py +++ b/eva/settings_production.py @@ -15,17 +15,44 @@ from pathlib import Path # Build paths inside the project like this: BASE_DIR / 'subdir'. BASE_DIR = Path(__file__).resolve().parent.parent -# mails in development go to stdout -EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' +# mails in production goes to mailserver +EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' + +EMAIL_HOST = '10.0.6.25' +EMAIL_PORT = '25' + +# Build paths inside the project like this: BASE_DIR / 'subdir'. +BASE_DIR = Path(__file__).resolve().parent.parent + +# get secrets +with open(os.path.join(BASE_DIR, 'secrets.json')) as secrets_file: + secrets = json.load(secrets_file) + +def get_secret(setting, secrets=secrets): + """Get secret setting or fail with ImproperlyConfigured""" + try: + return secrets[setting] + except KeyError: + raise ImproperlyConfigured("Set the {} setting".format(setting)) + # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! -SECRET_KEY = 'g%+i6+gkwt3zz@+k-5x1dtstuw4)&qd$lxd^bt2oswy5e1#dul' +SECRET_KEY = get_secret('SECRET_KEY') # SECURITY WARNING: don't run with debug turned on in production! -DEBUG = True +DEBUG = False + +# Quick-start development settings - unsuitable for production +# See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +# SECRET_KEY = 'g%+i6+gkwt3zz@+k-5x1dtstuw4)&qd$lxd^bt2oswy5e1#dul' + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = False STATIC_ROOT = BASE_DIR / 'staticfiles' From a2f910476e76ba7c7c60237c33bde04c2078687f Mon Sep 17 00:00:00 2001 From: Benni Baermann Date: Thu, 18 Mar 2021 14:16:49 +0100 Subject: [PATCH 06/32] missing imports in production setting added --- eva/settings_production.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/eva/settings_production.py b/eva/settings_production.py index 4c649ab..0e61c92 100644 --- a/eva/settings_production.py +++ b/eva/settings_production.py @@ -10,8 +10,12 @@ For the full list of settings and their values, see https://docs.djangoproject.com/en/3.1/ref/settings/ """ +import json +import os from pathlib import Path +from django.core.exceptions import ImproperlyConfigured + # Build paths inside the project like this: BASE_DIR / 'subdir'. BASE_DIR = Path(__file__).resolve().parent.parent From f45621ad5cc682941fd02b1b0dfc5a76d631821f Mon Sep 17 00:00:00 2001 From: Benni Baermann Date: Thu, 18 Mar 2021 14:57:20 +0100 Subject: [PATCH 07/32] TODO entrys --- TODO | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/TODO b/TODO index 57b7fb1..110e3f7 100644 --- a/TODO +++ b/TODO @@ -1,3 +1,11 @@ known bugs: html problem in mails: 14" -> 14" + +stellenbeschreibung -> stellenbezeichnung + +evapp/settings auf die richtigen adressen setzen + +Accounts klären + +mail in production testen From 6d87e1a7667bc55331d9765b15868b85afba0b8a Mon Sep 17 00:00:00 2001 From: Benni Baermann Date: Thu, 25 Mar 2021 09:13:22 +0100 Subject: [PATCH 08/32] just label changed stellenbeschreibung -> stellenbezeichnung --- evapp/migrations/0010_auto_20210325_0813.py | 18 ++++++++++++++++++ evapp/models.py | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 evapp/migrations/0010_auto_20210325_0813.py diff --git a/evapp/migrations/0010_auto_20210325_0813.py b/evapp/migrations/0010_auto_20210325_0813.py new file mode 100644 index 0000000..c0f7580 --- /dev/null +++ b/evapp/migrations/0010_auto_20210325_0813.py @@ -0,0 +1,18 @@ +# Generated by Django 3.1.4 on 2021-03-25 08:13 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('evapp', '0009_auto_20210315_1408'), + ] + + operations = [ + migrations.AlterField( + model_name='employee', + name='jobdescription_german', + field=models.CharField(max_length=100, null=True, verbose_name='Stellenbezeichnung(deutsch)'), + ), + ] diff --git a/evapp/models.py b/evapp/models.py index 3984b84..0befa71 100644 --- a/evapp/models.py +++ b/evapp/models.py @@ -58,7 +58,7 @@ class Employee(models.Model): # general work related stuff firstdate_employment = models.DateField(null=True, verbose_name="Erster Arbeitstag") firstdate_presence = models.DateField(null=True, verbose_name="Erster Tag der Anwesenheit in der Geschäftsstelle") - jobdescription_german = models.CharField(null=True, max_length=100, verbose_name="Stellenbeschreibung(deutsch)") + jobdescription_german = models.CharField(null=True, max_length=100, verbose_name="Stellenbezeichnung(deutsch)") jobdescription_english = models.CharField(null=True, max_length=100, verbose_name="Job description(english)") remote = models.BooleanField(verbose_name='Braucht keinen Arbeitsplatz weil Home-Office', default=False) desk = models.CharField(max_length=100, null=True, blank=True, verbose_name="Wo soll der Arbeitsplatz sein?") From f131d4d0c94840b9e3eae1b7368e0eb312aa28b4 Mon Sep 17 00:00:00 2001 From: Benni Baermann Date: Thu, 25 Mar 2021 10:09:27 +0100 Subject: [PATCH 09/32] new setting MAILTEST which sends mail only to EVA_MAIL not to departments --- TODO | 4 ++-- eva/settings_development.py | 3 +++ eva/settings_production.py | 6 +++--- evapp/settings.py | 2 +- evapp/views.py | 10 +++++++++- 5 files changed, 18 insertions(+), 7 deletions(-) diff --git a/TODO b/TODO index 110e3f7..f9a5579 100644 --- a/TODO +++ b/TODO @@ -2,10 +2,10 @@ known bugs: html problem in mails: 14" -> 14" -stellenbeschreibung -> stellenbezeichnung - evapp/settings auf die richtigen adressen setzen Accounts klären mail in production testen + +Bemerkung like "E - VA soon" auf die webseite diff --git a/eva/settings_development.py b/eva/settings_development.py index c2de6d1..10775f7 100644 --- a/eva/settings_development.py +++ b/eva/settings_development.py @@ -27,6 +27,9 @@ SECRET_KEY = 'g%+i6+gkwt3zz@+k-5x1dtstuw4)&qd$lxd^bt2oswy5e1#dul' # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True +# send mails only to debug mode adress even if in production +MAILTEST = True + STATIC_ROOT = BASE_DIR / 'staticfiles' ALLOWED_HOSTS = ['*'] diff --git a/eva/settings_production.py b/eva/settings_production.py index 0e61c92..768460f 100644 --- a/eva/settings_production.py +++ b/eva/settings_production.py @@ -49,15 +49,15 @@ SECRET_KEY = get_secret('SECRET_KEY') # SECURITY WARNING: don't run with debug turned on in production! DEBUG = False +# send mails only to debug mode adress even if in production +MAILTEST = True + # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! # SECRET_KEY = 'g%+i6+gkwt3zz@+k-5x1dtstuw4)&qd$lxd^bt2oswy5e1#dul' -# SECURITY WARNING: don't run with debug turned on in production! -DEBUG = False - STATIC_ROOT = BASE_DIR / 'staticfiles' ALLOWED_HOSTS = ['*'] diff --git a/evapp/settings.py b/evapp/settings.py index ff4ac6a..514b771 100644 --- a/evapp/settings.py +++ b/evapp/settings.py @@ -1,7 +1,7 @@ # temporary setting while change and exit is not yet fully implemented ONLY_ONBOARDING = True -# sender mail adress +# sender mail adress also used for MAILTEST mode EVA_MAIL = 'benni.baermann@wikimedia.de' # these Fields should be included in every mail diff --git a/evapp/views.py b/evapp/views.py index e1ec93c..9d93e33 100644 --- a/evapp/views.py +++ b/evapp/views.py @@ -130,7 +130,15 @@ class EvaFormView(LoginRequiredMixin, CookieWizardView): try: mail_template = get_template(f'evapp/department_mail.txt') - send_mail( + if settings.MAILTEST: + send_mail( + 'EVA: Neuzugang', + mail_template.render(context), + EVA_MAIL, + [EVA_MAIL, self.instance.usermail], + fail_silently=False) + else: + send_mail( 'EVA: Neuzugang', mail_template.render(context), EVA_MAIL, From 860a954ea081111c273a9ceaf6b30bc12c3693ad Mon Sep 17 00:00:00 2001 From: Benni Baermann Date: Thu, 25 Mar 2021 12:45:58 +0100 Subject: [PATCH 10/32] minor design change --- TODO | 6 ++++-- evapp/templates/evapp/employee_form.html | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/TODO b/TODO index f9a5579..c405c87 100644 --- a/TODO +++ b/TODO @@ -6,6 +6,8 @@ evapp/settings auf die richtigen adressen setzen Accounts klären -mail in production testen - Bemerkung like "E - VA soon" auf die webseite + +link ins mailtemplate (seite im wiki erstellen -> alexander) + +whitenoise/gunicorn in production diff --git a/evapp/templates/evapp/employee_form.html b/evapp/templates/evapp/employee_form.html index bbb5796..9b02e6a 100644 --- a/evapp/templates/evapp/employee_form.html +++ b/evapp/templates/evapp/employee_form.html @@ -28,7 +28,7 @@

- E V A - Eintritt, Veränderung, Austritt + E (V A) - Eintritt, (Veränderung, Austritt)

Schritt {{ wizard.steps.step1 }} von {{ wizard.steps.count }}

From 531ffa95fe1b981952ebe58d0970ae12541a1a23 Mon Sep 17 00:00:00 2001 From: Benni Baermann Date: Mon, 29 Mar 2021 14:56:06 +0200 Subject: [PATCH 11/32] added sim & sim2, configured mails in settings --- TODO | 3 +- evapp/forms.py | 2 +- evapp/migrations/0011_auto_20210329_1254.py | 23 +++++++++ evapp/models.py | 2 + evapp/settings.py | 52 ++++++++++++++++----- 5 files changed, 67 insertions(+), 15 deletions(-) create mode 100644 evapp/migrations/0011_auto_20210329_1254.py diff --git a/TODO b/TODO index c405c87..af4c42d 100644 --- a/TODO +++ b/TODO @@ -6,8 +6,7 @@ evapp/settings auf die richtigen adressen setzen Accounts klären -Bemerkung like "E - VA soon" auf die webseite - link ins mailtemplate (seite im wiki erstellen -> alexander) +welche mails gehen an wen. liste an alexander whitenoise/gunicorn in production diff --git a/evapp/forms.py b/evapp/forms.py index 862542b..6fc3a0f 100644 --- a/evapp/forms.py +++ b/evapp/forms.py @@ -50,7 +50,7 @@ class ITForm(EvaForm): class Meta: model = Employee fields = [ - 'laptop', 'vendor', 'os', 'screen', 'mobile', 'landline', 'comment', + 'laptop', 'vendor', 'os', 'screen', 'mobile', 'sim', 'sim2', 'landline', 'comment', 'language', 'accounts', 'lists', 'rebu2go' ] class OfficeForm(EvaForm): diff --git a/evapp/migrations/0011_auto_20210329_1254.py b/evapp/migrations/0011_auto_20210329_1254.py new file mode 100644 index 0000000..d41d516 --- /dev/null +++ b/evapp/migrations/0011_auto_20210329_1254.py @@ -0,0 +1,23 @@ +# Generated by Django 3.1.4 on 2021-03-29 12:54 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('evapp', '0010_auto_20210325_0813'), + ] + + operations = [ + migrations.AddField( + model_name='employee', + name='sim', + field=models.BooleanField(default=False, verbose_name='Mobilfunkvertrag'), + ), + migrations.AddField( + model_name='employee', + name='sim2', + field=models.BooleanField(default=False, verbose_name='Zweite Sim (für Laptop zB)'), + ), + ] diff --git a/evapp/models.py b/evapp/models.py index 0befa71..afec9b6 100644 --- a/evapp/models.py +++ b/evapp/models.py @@ -69,6 +69,8 @@ class Employee(models.Model): 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') + sim = models.BooleanField(default=False, verbose_name="Mobilfunkvertrag") + sim2 = models.BooleanField(default=False, verbose_name="Zweite Sim (für Laptop zB)") landline = models.BooleanField(default=True, verbose_name="Festnetztelefon") comment = models.TextField(max_length=500, null=True, blank=True, verbose_name="zusätzliche IT-Anforderungen") language = models.CharField(max_length=3, choices=LANG_CHOICES.items(), default="GER") diff --git a/evapp/settings.py b/evapp/settings.py index 514b771..4e40c25 100644 --- a/evapp/settings.py +++ b/evapp/settings.py @@ -1,22 +1,50 @@ # temporary setting while change and exit is not yet fully implemented ONLY_ONBOARDING = True -# sender mail adress also used for MAILTEST mode +# sender mail adress also used for MAILTEST mode EVA_MAIL = 'benni.baermann@wikimedia.de' # these Fields should be included in every mail -BASIC_DATA = ['firstname', 'lastname'] +BASIC_DATA = ['usermail', 'firstname', 'lastname', 'firstdate_employment', 'firstdate_presence',] # for every department: 'MAIL' => mail adress, 'DATA': additional fields to include -MAILS = {'IT': { +MAILS = { + 'IT': { 'MAIL': 'it@wikimedia.de', - 'DATA': ['laptop', 'os', 'email'], - }, - 'OFFICE': { - 'MAIL': 'office@wikimedia.de', - 'DATA': ['transponder',], - }, - 'ACCOUNTING': {'MAIL': 'accounting@wikimedia.de', - 'DATA': ['rebu2go',], - } + 'DATA': [ + 'laptop', 'os', 'comment', 'email', 'landline', 'lists', 'mobile', + 'department', 'accounts', 'language', 'screen', 'remote', 'desk', + ], + }, + 'OFFICE': { + 'MAIL': 'office@wikimedia.de', + 'DATA': [ + 'transponder', 'special', 'post_office_box', 'sim', 'sim2', + 'remote', 'desk', + ], + }, + 'ACCOUNTING': { + 'MAIL': 'accounting@wikimedia.de', + 'DATA': ['rebu2go',], + }, + 'KOMM': { + 'MAIL': 'kom@wikimedia.de', + 'DATA': [ + 'department', 'team', + 'jobdescription_german', 'jobdescription_english', + ], + }, + 'HR': { + 'MAIL': 'hr@wikimedia.de', + 'DATA': [ + 'department', 'team', 'language', + ] + }, + 'DIRECTORAT': { + 'MAIL': 'vorstand@wikmedia.de', + 'DATA': [ + 'team', 'department', 'language', + ] + } + } From 5c252c81f002c25a2d41c0d3084e48ce353a3664 Mon Sep 17 00:00:00 2001 From: Benni Baermann Date: Tue, 30 Mar 2021 10:27:22 +0200 Subject: [PATCH 12/32] BVG form field added --- evapp/forms.py | 2 +- evapp/migrations/0012_employee_bvg.py | 18 ++++++++++++++++++ evapp/models.py | 3 ++- 3 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 evapp/migrations/0012_employee_bvg.py diff --git a/evapp/forms.py b/evapp/forms.py index 6fc3a0f..039ea83 100644 --- a/evapp/forms.py +++ b/evapp/forms.py @@ -42,7 +42,7 @@ class WorkingForm(EvaForm): class Meta: model = Employee fields = ['firstdate_employment', 'firstdate_presence', 'jobdescription_german', - 'jobdescription_english', 'remote', 'desk',] + 'jobdescription_english', 'remote', 'desk', 'bvg'] widgets = {'firstdate_employment': DateInput(attrs={'type': 'date'}), 'firstdate_presence': DateInput(attrs={'type': 'date'}),} diff --git a/evapp/migrations/0012_employee_bvg.py b/evapp/migrations/0012_employee_bvg.py new file mode 100644 index 0000000..320a45e --- /dev/null +++ b/evapp/migrations/0012_employee_bvg.py @@ -0,0 +1,18 @@ +# Generated by Django 3.1.4 on 2021-03-30 08:25 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('evapp', '0011_auto_20210329_1254'), + ] + + operations = [ + migrations.AddField( + model_name='employee', + name='bvg', + field=models.BooleanField(default=True, verbose_name='Bekommt eine BVG-Karte, weil in Berlin tätig'), + ), + ] diff --git a/evapp/models.py b/evapp/models.py index afec9b6..af72e89 100644 --- a/evapp/models.py +++ b/evapp/models.py @@ -62,7 +62,8 @@ class Employee(models.Model): jobdescription_english = models.CharField(null=True, max_length=100, verbose_name="Job description(english)") remote = models.BooleanField(verbose_name='Braucht keinen Arbeitsplatz weil Home-Office', default=False) desk = models.CharField(max_length=100, null=True, blank=True, verbose_name="Wo soll der Arbeitsplatz sein?") - + bvg = models.BooleanField(verbose_name='Bekommt eine BVG-Karte, weil in Berlin tätig', default=True) + # 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') From 34cbf0f550de84cf806a0efef62985b5ab3896be Mon Sep 17 00:00:00 2001 From: Benni Baermann Date: Tue, 30 Mar 2021 10:29:04 +0200 Subject: [PATCH 13/32] added bvg field to HR mail --- evapp/settings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/evapp/settings.py b/evapp/settings.py index 4e40c25..478b253 100644 --- a/evapp/settings.py +++ b/evapp/settings.py @@ -37,7 +37,7 @@ MAILS = { 'HR': { 'MAIL': 'hr@wikimedia.de', 'DATA': [ - 'department', 'team', 'language', + 'department', 'team', 'language', 'eva', ] }, 'DIRECTORAT': { From 324d3d5161ef2e318e2c20df8adf9da8364a8dda Mon Sep 17 00:00:00 2001 From: Benni Baermann Date: Thu, 1 Apr 2021 10:30:40 +0200 Subject: [PATCH 14/32] removed bvg field --- evapp/forms.py | 2 +- evapp/migrations/0013_remove_employee_bvg.py | 17 +++++++++++++++++ evapp/models.py | 1 - evapp/settings.py | 2 +- 4 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 evapp/migrations/0013_remove_employee_bvg.py diff --git a/evapp/forms.py b/evapp/forms.py index 039ea83..6fc3a0f 100644 --- a/evapp/forms.py +++ b/evapp/forms.py @@ -42,7 +42,7 @@ class WorkingForm(EvaForm): class Meta: model = Employee fields = ['firstdate_employment', 'firstdate_presence', 'jobdescription_german', - 'jobdescription_english', 'remote', 'desk', 'bvg'] + 'jobdescription_english', 'remote', 'desk',] widgets = {'firstdate_employment': DateInput(attrs={'type': 'date'}), 'firstdate_presence': DateInput(attrs={'type': 'date'}),} diff --git a/evapp/migrations/0013_remove_employee_bvg.py b/evapp/migrations/0013_remove_employee_bvg.py new file mode 100644 index 0000000..afa3126 --- /dev/null +++ b/evapp/migrations/0013_remove_employee_bvg.py @@ -0,0 +1,17 @@ +# Generated by Django 3.1.4 on 2021-04-01 08:30 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('evapp', '0012_employee_bvg'), + ] + + operations = [ + migrations.RemoveField( + model_name='employee', + name='bvg', + ), + ] diff --git a/evapp/models.py b/evapp/models.py index af72e89..cdaaaf3 100644 --- a/evapp/models.py +++ b/evapp/models.py @@ -62,7 +62,6 @@ class Employee(models.Model): jobdescription_english = models.CharField(null=True, max_length=100, verbose_name="Job description(english)") remote = models.BooleanField(verbose_name='Braucht keinen Arbeitsplatz weil Home-Office', default=False) desk = models.CharField(max_length=100, null=True, blank=True, verbose_name="Wo soll der Arbeitsplatz sein?") - bvg = models.BooleanField(verbose_name='Bekommt eine BVG-Karte, weil in Berlin tätig', default=True) # IT related stuff laptop = models.CharField(max_length=2, choices=LAPTOP_CHOICES.items(), default='14') diff --git a/evapp/settings.py b/evapp/settings.py index 478b253..4e40c25 100644 --- a/evapp/settings.py +++ b/evapp/settings.py @@ -37,7 +37,7 @@ MAILS = { 'HR': { 'MAIL': 'hr@wikimedia.de', 'DATA': [ - 'department', 'team', 'language', 'eva', + 'department', 'team', 'language', ] }, 'DIRECTORAT': { From d6e0f933127383a023059f84ccb394a7edacf454 Mon Sep 17 00:00:00 2001 From: Benni Baermann Date: Tue, 6 Apr 2021 11:53:59 +0200 Subject: [PATCH 15/32] added link to onboarding page in mail template --- TODO | 5 +---- evapp/templates/evapp/department_mail.txt | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/TODO b/TODO index af4c42d..e256d5d 100644 --- a/TODO +++ b/TODO @@ -4,9 +4,6 @@ html problem in mails: 14" -> 14" evapp/settings auf die richtigen adressen setzen -Accounts klären - -link ins mailtemplate (seite im wiki erstellen -> alexander) -welche mails gehen an wen. liste an alexander + Accounts klären (OTRS und co. was genau muss in die liste) whitenoise/gunicorn in production diff --git a/evapp/templates/evapp/department_mail.txt b/evapp/templates/evapp/department_mail.txt index 000aea5..e2a2213 100644 --- a/evapp/templates/evapp/department_mail.txt +++ b/evapp/templates/evapp/department_mail.txt @@ -1,6 +1,6 @@ Hallo! -Es gibt einen Neuzugang bei Wikimedia! Hier () kannst Du nachsehen, +Es gibt einen Neuzugang bei Wikimedia! Hier ( https://wiki.wikimedia.de/wiki/Onboarding ) kannst Du nachsehen, welche Schritte jetzt für Deine Abteilung nötig werden. Im Folgenden alle Daten, die Du dafür brauchst: From 6cbfc034110b1e661e28943af777bdb164f29653 Mon Sep 17 00:00:00 2001 From: Benni Baermann Date: Wed, 7 Apr 2021 13:56:45 +0200 Subject: [PATCH 16/32] added some adresses, settings and documentation --- README.md | 27 +++++++++++++++++++++++++++ TODO | 6 ++---- eva/settings_development.py | 3 ++- eva/settings_production.py | 1 + evapp/settings.py | 14 ++++++++++---- 5 files changed, 42 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 777a8f0..e05d3e4 100644 --- a/README.md +++ b/README.md @@ -23,3 +23,30 @@ environment managing tool - start your development server with python manage.py runserver + +# production + +- you can use gunicorn as server for example instead of the django development server. + +- we use whitenoise for serving static files + +- we still use the development SQLITE database from django + +do the following in the project main directory: + + ln -sr eva/settings_production.py eva/settings.py + +edit /secrets.json to contain something similar to + + { + "SECRET_KEY": "THIS IS ANOTHER SECRET!" + } + +run the following commands: + + python3 manage.py migrate + python3 manage.py collectstatic + +server starts with + + nohup gunicorn --forwarded-allow-ips="*" -b '0:8000' eva.wsgi 2&> logfile & diff --git a/TODO b/TODO index e256d5d..4a87dcd 100644 --- a/TODO +++ b/TODO @@ -2,8 +2,6 @@ known bugs: html problem in mails: 14" -> 14" -evapp/settings auf die richtigen adressen setzen +adresse fürs finanzteam fehlt noch - Accounts klären (OTRS und co. was genau muss in die liste) - -whitenoise/gunicorn in production +staticfiles wollen nicht in production diff --git a/eva/settings_development.py b/eva/settings_development.py index 10775f7..fd2ba07 100644 --- a/eva/settings_development.py +++ b/eva/settings_development.py @@ -25,7 +25,7 @@ EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' SECRET_KEY = 'g%+i6+gkwt3zz@+k-5x1dtstuw4)&qd$lxd^bt2oswy5e1#dul' # SECURITY WARNING: don't run with debug turned on in production! -DEBUG = True +DEBUG = False # send mails only to debug mode adress even if in production MAILTEST = True @@ -51,6 +51,7 @@ INSTALLED_APPS = [ MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', + 'whitenoise.middleware.WhiteNoiseMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', diff --git a/eva/settings_production.py b/eva/settings_production.py index 768460f..c81f04e 100644 --- a/eva/settings_production.py +++ b/eva/settings_production.py @@ -79,6 +79,7 @@ INSTALLED_APPS = [ MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', + 'whitenoise.middleware.WhiteNoiseMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', diff --git a/evapp/settings.py b/evapp/settings.py index 4e40c25..d26a37e 100644 --- a/evapp/settings.py +++ b/evapp/settings.py @@ -10,7 +10,7 @@ BASIC_DATA = ['usermail', 'firstname', 'lastname', 'firstdate_employment', 'firs # for every department: 'MAIL' => mail adress, 'DATA': additional fields to include MAILS = { 'IT': { - 'MAIL': 'it@wikimedia.de', + 'MAIL': 'wmde-it@wikimedia.de', 'DATA': [ 'laptop', 'os', 'comment', 'email', 'landline', 'lists', 'mobile', 'department', 'accounts', 'language', 'screen', 'remote', 'desk', @@ -28,20 +28,26 @@ MAILS = { 'DATA': ['rebu2go',], }, 'KOMM': { - 'MAIL': 'kom@wikimedia.de', + 'MAIL': 'presse@wikimedia.de', 'DATA': [ 'department', 'team', 'jobdescription_german', 'jobdescription_english', ], }, + 'SPECIAL': { + 'MAIL': 'eileen.miedtank@wikimedia.de', + 'DATA': [ + 'department', 'team', 'language', 'sim', 'sim2', + ], + }, 'HR': { - 'MAIL': 'hr@wikimedia.de', + 'MAIL': 'personal@wikimedia.de, eileen.miedtank@wikimedia.de', 'DATA': [ 'department', 'team', 'language', ] }, 'DIRECTORAT': { - 'MAIL': 'vorstand@wikmedia.de', + 'MAIL': 'ricarda.busse@wikimedia.de', 'DATA': [ 'team', 'department', 'language', ] From 70ba741ed491d8fc5161ed1df7e93b4d50ac37b1 Mon Sep 17 00:00:00 2001 From: Benni Baermann Date: Wed, 7 Apr 2021 14:11:10 +0200 Subject: [PATCH 17/32] central added, finance removed --- TODO | 2 -- evapp/settings.py | 8 ++------ 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/TODO b/TODO index 4a87dcd..8e3cfb2 100644 --- a/TODO +++ b/TODO @@ -2,6 +2,4 @@ known bugs: html problem in mails: 14" -> 14" -adresse fürs finanzteam fehlt noch - staticfiles wollen nicht in production diff --git a/evapp/settings.py b/evapp/settings.py index d26a37e..9156433 100644 --- a/evapp/settings.py +++ b/evapp/settings.py @@ -23,10 +23,6 @@ MAILS = { 'remote', 'desk', ], }, - 'ACCOUNTING': { - 'MAIL': 'accounting@wikimedia.de', - 'DATA': ['rebu2go',], - }, 'KOMM': { 'MAIL': 'presse@wikimedia.de', 'DATA': [ @@ -34,10 +30,10 @@ MAILS = { 'jobdescription_german', 'jobdescription_english', ], }, - 'SPECIAL': { + 'CENTRAL': { 'MAIL': 'eileen.miedtank@wikimedia.de', 'DATA': [ - 'department', 'team', 'language', 'sim', 'sim2', + 'department', 'team', 'language', 'sim', 'sim2', 'rebu2go' ], }, 'HR': { From 1e665fcc8b201fc5ed6595dfeb216bcd397b849a Mon Sep 17 00:00:00 2001 From: Benni Baermann Date: Wed, 7 Apr 2021 15:42:13 +0200 Subject: [PATCH 18/32] small changes in TODO --- TODO | 2 -- 1 file changed, 2 deletions(-) diff --git a/TODO b/TODO index 8e3cfb2..57b7fb1 100644 --- a/TODO +++ b/TODO @@ -1,5 +1,3 @@ known bugs: html problem in mails: 14" -> 14" - -staticfiles wollen nicht in production From d16c58610e93d7b00f864bf3e6b3f72ec62558eb Mon Sep 17 00:00:00 2001 From: Benni Baermann Date: Thu, 8 Apr 2021 10:06:01 +0200 Subject: [PATCH 19/32] bugfix: " -> " in mails for laptop field --- TODO | 3 --- evapp/templates/evapp/dataloop.txt | 4 ++++ 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/TODO b/TODO index 57b7fb1..e69de29 100644 --- a/TODO +++ b/TODO @@ -1,3 +0,0 @@ -known bugs: - -html problem in mails: 14" -> 14" diff --git a/evapp/templates/evapp/dataloop.txt b/evapp/templates/evapp/dataloop.txt index c1593b3..a0b1b94 100644 --- a/evapp/templates/evapp/dataloop.txt +++ b/evapp/templates/evapp/dataloop.txt @@ -1,5 +1,9 @@ {% autoescape off %} {% for key, value in data.items %} + {% if key == 'laptop' %} + {{ key }}: {{ value | safe}} + {% else %} {{ key }}: {{ value }} + {% endif %} {% endfor %} {% endautoescape %} From 07a90dae8c767a18cfef9d7e7968f049e27b79bd Mon Sep 17 00:00:00 2001 From: Benni Baermann Date: Mon, 3 May 2021 12:32:20 +0200 Subject: [PATCH 20/32] bugfix _ext is now added bevor @ in email --- evapp/views.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/evapp/views.py b/evapp/views.py index 9d93e33..c17031c 100644 --- a/evapp/views.py +++ b/evapp/views.py @@ -63,9 +63,10 @@ class EvaFormView(LoginRequiredMixin, CookieWizardView): data = super().get_all_cleaned_data() if not data['intern']: print("intern employee detected") - if not data['email'].endswith('_ext'): - print('added "_ext" to mail adress') - data['email'] += '_ext' + (user, domain) = data['email'].split('@') + if not user.endswith('_ext'): + print('add "_ext" to mail adress...') + data['email'] = f'{user}_ext@{domain}' print("delete CHOICE FROM DATA") if 'choice' in data: From 2de76d44d5851191c784c56720a506820df6cfef Mon Sep 17 00:00:00 2001 From: Benni Baermann Date: Mon, 3 May 2021 15:49:05 +0200 Subject: [PATCH 21/32] Mobile is BooleanField now. --- TODO | 5 +++++ evapp/models.py | 17 +++++++++-------- evapp/views.py | 4 ++-- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/TODO b/TODO index e69de29..d3e74b2 100644 --- a/TODO +++ b/TODO @@ -0,0 +1,5 @@ +- remove empty lines in mail + +- in mail ändern "Deine mailadresse" in "ansprechpartner_in" + +- true/false übersetzen in dataloop diff --git a/evapp/models.py b/evapp/models.py index cdaaaf3..bed2f1e 100644 --- a/evapp/models.py +++ b/evapp/models.py @@ -21,10 +21,10 @@ VENDOR_CHOICES = {'STANDARD': 'Dell Latitude', OS_CHOICES = {'UBU': 'Ubuntu (Standard)', 'WIN': 'Windows (bitte Begründung angeben)',} -MOBILE_CHOICES = {'NO': 'Kein Mobiltelefon', - 'SIMPLE': 'Einfaches Gerät für Erreichbarkeit', - 'SINGLE': 'Smartphone, Single SIM', - 'DUAL': 'Smartphone, Dual SIM',} +# MOBILE_CHOICES = {'NO': 'Kein Mobiltelefon', +# 'SIMPLE': 'Einfaches Gerät für Erreichbarkeit', +# 'SINGLE': 'Smartphone, Single SIM', +# 'DUAL': 'Smartphone, Dual SIM',} LANG_CHOICES = {'GER': 'Deutsch', 'ENG': 'English',} @@ -62,16 +62,17 @@ class Employee(models.Model): jobdescription_english = models.CharField(null=True, max_length=100, verbose_name="Job description(english)") remote = models.BooleanField(verbose_name='Braucht keinen Arbeitsplatz weil Home-Office', default=False) desk = models.CharField(max_length=100, null=True, blank=True, verbose_name="Wo soll der Arbeitsplatz sein?") - + # 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') + mobile = models.BooleanField(max_length=6, default=False) sim = models.BooleanField(default=False, verbose_name="Mobilfunkvertrag") - sim2 = models.BooleanField(default=False, verbose_name="Zweite Sim (für Laptop zB)") - landline = models.BooleanField(default=True, verbose_name="Festnetztelefon") + sim2 = models.BooleanField(default=False, verbose_name="Zweite Sim (für Laptop zB)") # do we still need this? + landline = models.BooleanField(default=True, verbose_name="Festnetztelefon") # do we still need this? + # TODO: tastaturlayout DE/US comment = models.TextField(max_length=500, null=True, blank=True, verbose_name="zusätzliche IT-Anforderungen") language = models.CharField(max_length=3, choices=LANG_CHOICES.items(), default="GER") accounts = MultiSelectField(choices=ACCOUNT_CHOICES.items(), null=True) diff --git a/evapp/views.py b/evapp/views.py index c17031c..5202f6c 100644 --- a/evapp/views.py +++ b/evapp/views.py @@ -12,7 +12,7 @@ from django.conf import settings from django.contrib.auth.mixins import LoginRequiredMixin from .models import Employee, DEPARTMENT_CHOICES, LAPTOP_CHOICES, OS_CHOICES, VENDOR_CHOICES, \ - MOBILE_CHOICES, LANG_CHOICES, ACCOUNT_CHOICES, TRANSPONDER_CHOICES + LANG_CHOICES, ACCOUNT_CHOICES, TRANSPONDER_CHOICES from .forms import PersonalForm, WorkingForm, ITForm, OfficeForm, DummyForm,\ ChangeForm, TYPE_CHOICES from .settings import MAILS, EVA_MAIL, BASIC_DATA, ONLY_ONBOARDING @@ -164,7 +164,7 @@ class EvaFormView(LoginRequiredMixin, 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, **VENDOR_CHOICES} + **OS_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}) From 26a28c357b53cc8cbd62aa906a132d76bfb0e908 Mon Sep 17 00:00:00 2001 From: Benni Baermann Date: Mon, 3 May 2021 16:31:24 +0200 Subject: [PATCH 22/32] changed verbose name fpr mailinglists --- evapp/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/evapp/models.py b/evapp/models.py index bed2f1e..abe37dd 100644 --- a/evapp/models.py +++ b/evapp/models.py @@ -76,7 +76,7 @@ class Employee(models.Model): comment = models.TextField(max_length=500, null=True, blank=True, verbose_name="zusätzliche IT-Anforderungen") language = models.CharField(max_length=3, choices=LANG_CHOICES.items(), default="GER") accounts = MultiSelectField(choices=ACCOUNT_CHOICES.items(), null=True) - lists = models.CharField(max_length=100, null=True) + lists = models.CharField(max_length=100, null=True, blank=True, verbose_name="Nicht-Standard-Mailinglisten") rebu2go = models.BooleanField(verbose_name="Rebu2Go-Zugang benötigt?", default=False) # office related stuff From 2de30fdd1b09a37d3367a712a724187a646bc1f3 Mon Sep 17 00:00:00 2001 From: Benni Baermann Date: Mon, 3 May 2021 16:33:44 +0200 Subject: [PATCH 23/32] Zedat removed and accounts no longer required field --- evapp/models.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/evapp/models.py b/evapp/models.py index abe37dd..a86c75e 100644 --- a/evapp/models.py +++ b/evapp/models.py @@ -32,7 +32,6 @@ LANG_CHOICES = {'GER': 'Deutsch', ACCOUNT_CHOICES = {'OTRSWMDE': 'OTRS Ticketsystem', 'CIVIC1': 'Civic CRM (allgemein)', 'CIVIC2': "Civic CRM (Mailings, impliziert allgemein)", - 'ZEDA': "Zeda Nextcloud", 'WEB': 'www.wikimedia.de (edit)', 'BLOG': 'blog.wikimedia.de (edit)', 'FORUM': 'forum.wikimedia.de', @@ -75,8 +74,8 @@ class Employee(models.Model): # TODO: tastaturlayout DE/US comment = models.TextField(max_length=500, null=True, blank=True, verbose_name="zusätzliche IT-Anforderungen") language = models.CharField(max_length=3, choices=LANG_CHOICES.items(), default="GER") - accounts = MultiSelectField(choices=ACCOUNT_CHOICES.items(), null=True) - lists = models.CharField(max_length=100, null=True, blank=True, verbose_name="Nicht-Standard-Mailinglisten") + accounts = MultiSelectField(choices=ACCOUNT_CHOICES.items(), null=True, blank=True, verbose_name="Zusätzliche Accounts") + lists = models.CharField(max_length=100, null=True, blank=True, verbose_name="Zusätzliche Mailinglisten") rebu2go = models.BooleanField(verbose_name="Rebu2Go-Zugang benötigt?", default=False) # office related stuff From b6c7df541f64464ac51847ca9c14953f63aa7c73 Mon Sep 17 00:00:00 2001 From: Benni Baermann Date: Tue, 4 May 2021 10:44:00 +0200 Subject: [PATCH 24/32] some fields changed/removed, "Weiter" is "Abschicken" in last step now --- TODO | 2 ++ eva/settings_development.py | 2 +- evapp/forms.py | 2 +- evapp/migrations/0014_auto_20210504_0842.py | 38 +++++++++++++++++++++ evapp/models.py | 6 ++-- evapp/templates/evapp/employee_form.html | 6 +++- 6 files changed, 50 insertions(+), 6 deletions(-) create mode 100644 evapp/migrations/0014_auto_20210504_0842.py diff --git a/TODO b/TODO index d3e74b2..fd2a992 100644 --- a/TODO +++ b/TODO @@ -3,3 +3,5 @@ - in mail ändern "Deine mailadresse" in "ansprechpartner_in" - true/false übersetzen in dataloop + +- automatic generation of MA mail diff --git a/eva/settings_development.py b/eva/settings_development.py index fd2ba07..a18436b 100644 --- a/eva/settings_development.py +++ b/eva/settings_development.py @@ -25,7 +25,7 @@ EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' SECRET_KEY = 'g%+i6+gkwt3zz@+k-5x1dtstuw4)&qd$lxd^bt2oswy5e1#dul' # SECURITY WARNING: don't run with debug turned on in production! -DEBUG = False +DEBUG = True # send mails only to debug mode adress even if in production MAILTEST = True diff --git a/evapp/forms.py b/evapp/forms.py index 6fc3a0f..46aae25 100644 --- a/evapp/forms.py +++ b/evapp/forms.py @@ -50,7 +50,7 @@ class ITForm(EvaForm): class Meta: model = Employee fields = [ - 'laptop', 'vendor', 'os', 'screen', 'mobile', 'sim', 'sim2', 'landline', 'comment', + 'laptop', 'vendor', 'os', 'screen', 'mobile', 'sim', 'landline', 'comment', 'language', 'accounts', 'lists', 'rebu2go' ] class OfficeForm(EvaForm): diff --git a/evapp/migrations/0014_auto_20210504_0842.py b/evapp/migrations/0014_auto_20210504_0842.py new file mode 100644 index 0000000..b582d2b --- /dev/null +++ b/evapp/migrations/0014_auto_20210504_0842.py @@ -0,0 +1,38 @@ +# Generated by Django 3.1.4 on 2021-05-04 08:42 + +from django.db import migrations, models +import multiselectfield.db.fields + + +class Migration(migrations.Migration): + + dependencies = [ + ('evapp', '0013_remove_employee_bvg'), + ] + + operations = [ + migrations.RemoveField( + model_name='employee', + name='sim2', + ), + migrations.AlterField( + model_name='employee', + name='accounts', + field=multiselectfield.db.fields.MultiSelectField(blank=True, choices=[('OTRSWMDE', 'OTRS Ticketsystem'), ('CIVIC1', 'Civic CRM (allgemein)'), ('CIVIC2', 'Civic CRM (Mailings, impliziert allgemein)'), ('WEB', 'www.wikimedia.de (edit)'), ('BLOG', 'blog.wikimedia.de (edit)'), ('FORUM', 'forum.wikimedia.de')], max_length=37, null=True, verbose_name='Zusätzliche Accounts'), + ), + migrations.AlterField( + model_name='employee', + name='lists', + field=models.CharField(blank=True, max_length=100, null=True, verbose_name='Zusätzliche Mailinglisten'), + ), + migrations.AlterField( + model_name='employee', + name='mobile', + field=models.BooleanField(default=False, max_length=6, verbose_name='Handy benötigt?'), + ), + migrations.AlterField( + 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, verbose_name='Hersteller'), + ), + ] diff --git a/evapp/models.py b/evapp/models.py index a86c75e..553eec1 100644 --- a/evapp/models.py +++ b/evapp/models.py @@ -64,12 +64,12 @@ 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') + vendor = models.CharField(max_length=8, choices=VENDOR_CHOICES.items(), default='STANDARD', verbose_name='Hersteller') 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.BooleanField(max_length=6, default=False) + mobile = models.BooleanField(max_length=6, default=False, verbose_name='Handy benötigt?') sim = models.BooleanField(default=False, verbose_name="Mobilfunkvertrag") - sim2 = models.BooleanField(default=False, verbose_name="Zweite Sim (für Laptop zB)") # do we still need this? + # sim2 = models.BooleanField(default=False, verbose_name="Zweite Sim (für Laptop zB)") # do we still need this? landline = models.BooleanField(default=True, verbose_name="Festnetztelefon") # do we still need this? # TODO: tastaturlayout DE/US comment = models.TextField(max_length=500, null=True, blank=True, verbose_name="zusätzliche IT-Anforderungen") diff --git a/evapp/templates/evapp/employee_form.html b/evapp/templates/evapp/employee_form.html index 9b02e6a..1970fe8 100644 --- a/evapp/templates/evapp/employee_form.html +++ b/evapp/templates/evapp/employee_form.html @@ -82,7 +82,11 @@ {% if wizard.steps.prev %} {% endif %} - + {% if datatable == True %} + + {% else %} + + {% endif %}

From 334bffdad0b92f5a43a2fbe893bb78bd0198ffc1 Mon Sep 17 00:00:00 2001 From: Benni Baermann Date: Tue, 4 May 2021 11:54:27 +0200 Subject: [PATCH 25/32] automatic generation of mail adress added --- TODO | 2 -- evapp/forms.py | 2 +- .../migrations/0015_remove_employee_email.py | 17 +++++++++++++++++ evapp/models.py | 2 +- evapp/views.py | 19 ++++++++++++------- 5 files changed, 31 insertions(+), 11 deletions(-) create mode 100644 evapp/migrations/0015_remove_employee_email.py diff --git a/TODO b/TODO index fd2a992..d3e74b2 100644 --- a/TODO +++ b/TODO @@ -3,5 +3,3 @@ - in mail ändern "Deine mailadresse" in "ansprechpartner_in" - true/false übersetzen in dataloop - -- automatic generation of MA mail diff --git a/evapp/forms.py b/evapp/forms.py index 46aae25..a7a9a4e 100644 --- a/evapp/forms.py +++ b/evapp/forms.py @@ -29,7 +29,7 @@ class PersonalForm(EvaForm): class Meta: model = Employee - fields = ['usermail', 'firstname', 'lastname', 'intern', 'email', 'department', 'team', ] + fields = ['usermail', 'firstname', 'lastname', 'intern', 'department', 'team', ] class WorkingForm(EvaForm): diff --git a/evapp/migrations/0015_remove_employee_email.py b/evapp/migrations/0015_remove_employee_email.py new file mode 100644 index 0000000..8fcf23f --- /dev/null +++ b/evapp/migrations/0015_remove_employee_email.py @@ -0,0 +1,17 @@ +# Generated by Django 3.1.4 on 2021-05-04 09:43 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('evapp', '0014_auto_20210504_0842'), + ] + + operations = [ + migrations.RemoveField( + model_name='employee', + name='email', + ), + ] diff --git a/evapp/models.py b/evapp/models.py index 553eec1..79e775d 100644 --- a/evapp/models.py +++ b/evapp/models.py @@ -50,7 +50,7 @@ class Employee(models.Model): firstname = models.CharField(max_length=50, verbose_name="Vorname") lastname = models.CharField(max_length=50, verbose_name="Nachname") intern = models.BooleanField(verbose_name='Interne_r Mitarbeiter_in?', default=True) - email = models.EmailField(max_length=50, verbose_name="E-Mail-Adresse ders Mitarbeitenden") + # email = models.EmailField(max_length=50, verbose_name="E-Mail-Adresse ders Mitarbeitenden") department = models.CharField(max_length=5, choices=DEPARTMENT_CHOICES.items()) team = models.CharField(max_length=20, null=True, blank=True) # TODO? besser als choices? diff --git a/evapp/views.py b/evapp/views.py index 5202f6c..82bd80e 100644 --- a/evapp/views.py +++ b/evapp/views.py @@ -55,18 +55,22 @@ class EvaFormView(LoginRequiredMixin, CookieWizardView): def set_choice(self, c): self.choice = c + def generate_email(self, data): + (first, junk) = data['firstname'].split(maxsplit=1) + (last, junk) = data['lastname'].split(maxsplit=1) + name = first + '.' + last + if not data['intern']: + mail = name + '_ext@wikimedia.de' + else: + mail = name + '@wikimedia.de' + data['email'] = mail def get_all_cleaned_data(self): '''this method deletes data which is only used temporary and is not in the modell, it also changes the mail adress of the employee in some circumstances''' data = super().get_all_cleaned_data() - if not data['intern']: - print("intern employee detected") - (user, domain) = data['email'].split('@') - if not user.endswith('_ext'): - print('add "_ext" to mail adress...') - data['email'] = f'{user}_ext@{domain}' + self.generate_email(data) print("delete CHOICE FROM DATA") if 'choice' in data: @@ -174,6 +178,7 @@ class EvaFormView(LoginRequiredMixin, CookieWizardView): data['accounts'] = [ACCOUNT_CHOICES[c] for c in data['accounts']] # replace keys in data dictionary with verbose_name + mail = data.pop('email') newdata = {self.instance._meta.get_field(k).verbose_name.title() : v for k,v in data.items()} - + newdata['email'] = mail return newdata From 910c24f70366d3de514c214d754926f608da6ca5 Mon Sep 17 00:00:00 2001 From: Benni Baermann Date: Tue, 4 May 2021 12:16:01 +0200 Subject: [PATCH 26/32] removed empty lines in mails. bugfix regarding mail generation --- TODO | 2 -- evapp/templates/evapp/dataloop.txt | 9 ++------- evapp/views.py | 7 +++++-- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/TODO b/TODO index d3e74b2..2b913ba 100644 --- a/TODO +++ b/TODO @@ -1,5 +1,3 @@ -- remove empty lines in mail - - in mail ändern "Deine mailadresse" in "ansprechpartner_in" - true/false übersetzen in dataloop diff --git a/evapp/templates/evapp/dataloop.txt b/evapp/templates/evapp/dataloop.txt index a0b1b94..b4c89a5 100644 --- a/evapp/templates/evapp/dataloop.txt +++ b/evapp/templates/evapp/dataloop.txt @@ -1,9 +1,4 @@ {% autoescape off %} -{% for key, value in data.items %} - {% if key == 'laptop' %} - {{ key }}: {{ value | safe}} - {% else %} - {{ key }}: {{ value }} - {% endif %} -{% endfor %} +{% for key, value in data.items %}{% if key == 'laptop' %} {{ key }}: {{ value | safe}}{% else %} +{{ key }}: {{ value }}{% endif %}{% endfor %} {% endautoescape %} diff --git a/evapp/views.py b/evapp/views.py index 82bd80e..4c857cb 100644 --- a/evapp/views.py +++ b/evapp/views.py @@ -178,7 +178,10 @@ class EvaFormView(LoginRequiredMixin, CookieWizardView): data['accounts'] = [ACCOUNT_CHOICES[c] for c in data['accounts']] # replace keys in data dictionary with verbose_name - mail = data.pop('email') + mail = '' + if 'email' in data: + mail = data.pop('email') newdata = {self.instance._meta.get_field(k).verbose_name.title() : v for k,v in data.items()} - newdata['email'] = mail + if mail: + newdata['email'] = mail return newdata From b2493e01b066ab6e2ce01dc29bfdccb4162284e2 Mon Sep 17 00:00:00 2001 From: Benni Baermann Date: Tue, 4 May 2021 12:45:41 +0200 Subject: [PATCH 27/32] new field keyboard layout, removed field landline --- evapp/forms.py | 2 +- evapp/migrations/0016_auto_20210504_1040.py | 27 +++++++++++++++++++++ evapp/models.py | 11 ++++++--- evapp/views.py | 10 +++----- 4 files changed, 39 insertions(+), 11 deletions(-) create mode 100644 evapp/migrations/0016_auto_20210504_1040.py diff --git a/evapp/forms.py b/evapp/forms.py index a7a9a4e..3a543a1 100644 --- a/evapp/forms.py +++ b/evapp/forms.py @@ -50,7 +50,7 @@ class ITForm(EvaForm): class Meta: model = Employee fields = [ - 'laptop', 'vendor', 'os', 'screen', 'mobile', 'sim', 'landline', 'comment', + 'laptop', 'vendor', 'os', 'keyboard', 'screen', 'mobile', 'sim', 'comment', 'language', 'accounts', 'lists', 'rebu2go' ] class OfficeForm(EvaForm): diff --git a/evapp/migrations/0016_auto_20210504_1040.py b/evapp/migrations/0016_auto_20210504_1040.py new file mode 100644 index 0000000..5005c9d --- /dev/null +++ b/evapp/migrations/0016_auto_20210504_1040.py @@ -0,0 +1,27 @@ +# Generated by Django 3.1.4 on 2021-05-04 10:40 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('evapp', '0015_remove_employee_email'), + ] + + operations = [ + migrations.RemoveField( + model_name='employee', + name='landline', + ), + migrations.AddField( + model_name='employee', + name='keyboard', + field=models.CharField(choices=[('DE', 'Deutsch'), ('US', 'USA'), ('OT', 'Anderes (Bitte unten angeben)')], default='DE', max_length=2, verbose_name='Tastaturlayout'), + ), + migrations.AlterField( + model_name='employee', + name='department', + field=models.CharField(choices=[('PROG', 'Programme'), ('SOFT', 'Softwareentwicklung'), ('CENT', 'Central'), ('VOR', 'Vorstand')], max_length=5, verbose_name='Bereich'), + ), + ] diff --git a/evapp/models.py b/evapp/models.py index 79e775d..7df00db 100644 --- a/evapp/models.py +++ b/evapp/models.py @@ -29,6 +29,10 @@ OS_CHOICES = {'UBU': 'Ubuntu (Standard)', LANG_CHOICES = {'GER': 'Deutsch', 'ENG': 'English',} +KEYBOARD_CHOICES = {'DE': 'Deutsch', + 'US': 'USA', + 'OT': 'Anderes (Bitte unten angeben)'} + ACCOUNT_CHOICES = {'OTRSWMDE': 'OTRS Ticketsystem', 'CIVIC1': 'Civic CRM (allgemein)', 'CIVIC2': "Civic CRM (Mailings, impliziert allgemein)", @@ -51,7 +55,7 @@ class Employee(models.Model): lastname = models.CharField(max_length=50, verbose_name="Nachname") intern = models.BooleanField(verbose_name='Interne_r Mitarbeiter_in?', default=True) # email = models.EmailField(max_length=50, verbose_name="E-Mail-Adresse ders Mitarbeitenden") - department = models.CharField(max_length=5, choices=DEPARTMENT_CHOICES.items()) + department = models.CharField(max_length=5, choices=DEPARTMENT_CHOICES.items(), verbose_name='Bereich') team = models.CharField(max_length=20, null=True, blank=True) # TODO? besser als choices? # general work related stuff @@ -69,9 +73,8 @@ class Employee(models.Model): screen = models.BooleanField(default=False, verbose_name='Zusätzlicher Monitor? Einer ist standard.') mobile = models.BooleanField(max_length=6, default=False, verbose_name='Handy benötigt?') sim = models.BooleanField(default=False, verbose_name="Mobilfunkvertrag") - # sim2 = models.BooleanField(default=False, verbose_name="Zweite Sim (für Laptop zB)") # do we still need this? - landline = models.BooleanField(default=True, verbose_name="Festnetztelefon") # do we still need this? - # TODO: tastaturlayout DE/US + # landline = models.BooleanField(default=True, verbose_name="Festnetztelefon") # do we still need this? + keyboard = models.CharField(max_length=2, choices=KEYBOARD_CHOICES.items(), default='DE', verbose_name="Tastaturlayout") comment = models.TextField(max_length=500, null=True, blank=True, verbose_name="zusätzliche IT-Anforderungen") language = models.CharField(max_length=3, choices=LANG_CHOICES.items(), default="GER") accounts = MultiSelectField(choices=ACCOUNT_CHOICES.items(), null=True, blank=True, verbose_name="Zusätzliche Accounts") diff --git a/evapp/views.py b/evapp/views.py index 4c857cb..f973b27 100644 --- a/evapp/views.py +++ b/evapp/views.py @@ -12,7 +12,7 @@ from django.conf import settings from django.contrib.auth.mixins import LoginRequiredMixin from .models import Employee, DEPARTMENT_CHOICES, LAPTOP_CHOICES, OS_CHOICES, VENDOR_CHOICES, \ - LANG_CHOICES, ACCOUNT_CHOICES, TRANSPONDER_CHOICES + LANG_CHOICES, ACCOUNT_CHOICES, TRANSPONDER_CHOICES, KEYBOARD_CHOICES from .forms import PersonalForm, WorkingForm, ITForm, OfficeForm, DummyForm,\ ChangeForm, TYPE_CHOICES from .settings import MAILS, EVA_MAIL, BASIC_DATA, ONLY_ONBOARDING @@ -56,8 +56,8 @@ class EvaFormView(LoginRequiredMixin, CookieWizardView): self.choice = c def generate_email(self, data): - (first, junk) = data['firstname'].split(maxsplit=1) - (last, junk) = data['lastname'].split(maxsplit=1) + (first, *_) = data['firstname'].split(maxsplit=1) + (last, *_) = data['lastname'].split(maxsplit=1) name = first + '.' + last if not data['intern']: mail = name + '_ext@wikimedia.de' @@ -164,11 +164,9 @@ class EvaFormView(LoginRequiredMixin, CookieWizardView): # ''' - # print("BEAUTIFY") - # update values in data dictionary with keys from *_CHOICES if present there choices = {**DEPARTMENT_CHOICES, **LAPTOP_CHOICES, **TRANSPONDER_CHOICES, - **OS_CHOICES, **LANG_CHOICES, **VENDOR_CHOICES} + **OS_CHOICES, **LANG_CHOICES, **VENDOR_CHOICES, **KEYBOARD_CHOICES} data.update({k:choices[v] for k,v in data.items() \ if isinstance(v,collections.abc.Hashable) \ and v in choices}) From 3073322290490675215918dbba786e6b915aefff Mon Sep 17 00:00:00 2001 From: Benni Baermann Date: Tue, 4 May 2021 14:24:25 +0200 Subject: [PATCH 28/32] nicer looking table at the end, os now with verbose_name --- evapp/migrations/0017_auto_20210504_1224.py | 18 ++++++++++++++++++ evapp/models.py | 6 ++---- evapp/templates/evapp/employee_form.html | 4 +++- 3 files changed, 23 insertions(+), 5 deletions(-) create mode 100644 evapp/migrations/0017_auto_20210504_1224.py diff --git a/evapp/migrations/0017_auto_20210504_1224.py b/evapp/migrations/0017_auto_20210504_1224.py new file mode 100644 index 0000000..d5d96f9 --- /dev/null +++ b/evapp/migrations/0017_auto_20210504_1224.py @@ -0,0 +1,18 @@ +# Generated by Django 3.1.4 on 2021-05-04 12:24 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('evapp', '0016_auto_20210504_1040'), + ] + + operations = [ + migrations.AlterField( + model_name='employee', + name='os', + field=models.CharField(choices=[('UBU', 'Ubuntu (Standard)'), ('WIN', 'Windows (bitte Begründung angeben)')], default='UBU', max_length=3, verbose_name='Betriebssystem'), + ), + ] diff --git a/evapp/models.py b/evapp/models.py index 7df00db..77b4490 100644 --- a/evapp/models.py +++ b/evapp/models.py @@ -54,9 +54,8 @@ class Employee(models.Model): firstname = models.CharField(max_length=50, verbose_name="Vorname") lastname = models.CharField(max_length=50, verbose_name="Nachname") intern = models.BooleanField(verbose_name='Interne_r Mitarbeiter_in?', default=True) - # email = models.EmailField(max_length=50, verbose_name="E-Mail-Adresse ders Mitarbeitenden") department = models.CharField(max_length=5, choices=DEPARTMENT_CHOICES.items(), verbose_name='Bereich') - team = models.CharField(max_length=20, null=True, blank=True) # TODO? besser als choices? + team = models.CharField(max_length=20, null=True, blank=True) # TODO? better with choices? # general work related stuff firstdate_employment = models.DateField(null=True, verbose_name="Erster Arbeitstag") @@ -69,11 +68,10 @@ 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', verbose_name='Hersteller') - os = models.CharField(max_length=3, choices=OS_CHOICES.items(), default='UBU') + os = models.CharField(max_length=3, choices=OS_CHOICES.items(), default='UBU', verbose_name='Betriebssystem') screen = models.BooleanField(default=False, verbose_name='Zusätzlicher Monitor? Einer ist standard.') mobile = models.BooleanField(max_length=6, default=False, verbose_name='Handy benötigt?') sim = models.BooleanField(default=False, verbose_name="Mobilfunkvertrag") - # landline = models.BooleanField(default=True, verbose_name="Festnetztelefon") # do we still need this? keyboard = models.CharField(max_length=2, choices=KEYBOARD_CHOICES.items(), default='DE', verbose_name="Tastaturlayout") comment = models.TextField(max_length=500, null=True, blank=True, verbose_name="zusätzliche IT-Anforderungen") language = models.CharField(max_length=3, choices=LANG_CHOICES.items(), default="GER") diff --git a/evapp/templates/evapp/employee_form.html b/evapp/templates/evapp/employee_form.html index 1970fe8..f84b49b 100644 --- a/evapp/templates/evapp/employee_form.html +++ b/evapp/templates/evapp/employee_form.html @@ -53,9 +53,11 @@

{% if datatable == True %} + {% for key, value in data.items %} - {{ key }}: {{ value }}

+

{% endfor %} +
{{ key }}{{ value }}
{% endif %}
{% csrf_token %} From db36e1cdc920bff4c826446c610356ba92b309bf Mon Sep 17 00:00:00 2001 From: Benni Baermann Date: Tue, 4 May 2021 14:51:21 +0200 Subject: [PATCH 29/32] True/False => Ja/Nein in data, slightly changed verbose_name for usermail --- TODO | 2 -- evapp/migrations/0018_auto_20210504_1251.py | 18 ++++++++++++++++++ evapp/models.py | 2 +- evapp/views.py | 7 ++++++- 4 files changed, 25 insertions(+), 4 deletions(-) create mode 100644 evapp/migrations/0018_auto_20210504_1251.py diff --git a/TODO b/TODO index 2b913ba..8b13789 100644 --- a/TODO +++ b/TODO @@ -1,3 +1 @@ -- in mail ändern "Deine mailadresse" in "ansprechpartner_in" -- true/false übersetzen in dataloop diff --git a/evapp/migrations/0018_auto_20210504_1251.py b/evapp/migrations/0018_auto_20210504_1251.py new file mode 100644 index 0000000..649fc17 --- /dev/null +++ b/evapp/migrations/0018_auto_20210504_1251.py @@ -0,0 +1,18 @@ +# Generated by Django 3.1.4 on 2021-05-04 12:51 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('evapp', '0017_auto_20210504_1224'), + ] + + operations = [ + migrations.AlterField( + model_name='employee', + name='usermail', + field=models.EmailField(default='bestechefin@wikimedia.de', max_length=50, verbose_name='Deine Mailadresse (Ansprechpartner_in)'), + ), + ] diff --git a/evapp/models.py b/evapp/models.py index 77b4490..9fc13dc 100644 --- a/evapp/models.py +++ b/evapp/models.py @@ -48,7 +48,7 @@ TRANSPONDER_CHOICES = {'NORM': 'Allgemeiner Transponder', class Employee(models.Model): # email adress of user. should not be necessary if we use openauth one day - usermail = models.EmailField(max_length=50, verbose_name="Deine Mailadresse", default='bestechefin@wikimedia.de') + usermail = models.EmailField(max_length=50, verbose_name="Deine Mailadresse (Ansprechpartner_in)", default='bestechefin@wikimedia.de') # personal data firstname = models.CharField(max_length=50, verbose_name="Vorname") diff --git a/evapp/views.py b/evapp/views.py index f973b27..0bfef77 100644 --- a/evapp/views.py +++ b/evapp/views.py @@ -181,5 +181,10 @@ class EvaFormView(LoginRequiredMixin, CookieWizardView): mail = data.pop('email') newdata = {self.instance._meta.get_field(k).verbose_name.title() : v for k,v in data.items()} if mail: - newdata['email'] = mail + newdata['Email'] = mail + + #translate booleans + newdata.update({k:'Ja' for k,v in newdata.items() if isinstance(v,bool) and v == True}) + newdata.update({k:'Nein' for k,v in newdata.items() if isinstance(v,bool) and v == False}) + return newdata From 707ce532b6cc75d537d0844522925d77b5fa8921 Mon Sep 17 00:00:00 2001 From: Benni Baermann Date: Tue, 4 May 2021 15:35:27 +0200 Subject: [PATCH 30/32] laptop removed --- evapp/forms.py | 2 +- evapp/migrations/0019_auto_20210504_1333.py | 22 +++++++++++++++++++++ evapp/models.py | 10 +--------- evapp/views.py | 4 ++-- 4 files changed, 26 insertions(+), 12 deletions(-) create mode 100644 evapp/migrations/0019_auto_20210504_1333.py diff --git a/evapp/forms.py b/evapp/forms.py index 3a543a1..5e18c0b 100644 --- a/evapp/forms.py +++ b/evapp/forms.py @@ -50,7 +50,7 @@ class ITForm(EvaForm): class Meta: model = Employee fields = [ - 'laptop', 'vendor', 'os', 'keyboard', 'screen', 'mobile', 'sim', 'comment', + 'vendor', 'os', 'keyboard', 'screen', 'mobile', 'sim', 'comment', 'language', 'accounts', 'lists', 'rebu2go' ] class OfficeForm(EvaForm): diff --git a/evapp/migrations/0019_auto_20210504_1333.py b/evapp/migrations/0019_auto_20210504_1333.py new file mode 100644 index 0000000..ad316d2 --- /dev/null +++ b/evapp/migrations/0019_auto_20210504_1333.py @@ -0,0 +1,22 @@ +# Generated by Django 3.1.4 on 2021-05-04 13:33 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('evapp', '0018_auto_20210504_1251'), + ] + + operations = [ + migrations.RemoveField( + model_name='employee', + name='laptop', + ), + migrations.AlterField( + model_name='employee', + name='vendor', + field=models.CharField(choices=[('STANDARD', 'Dell Latitude'), ('LENOVO', 'Lenovo Thinkpad'), ('MAC', 'Mac (nur für Grafiker_innen)')], default='STANDARD', max_length=8, verbose_name='Hersteller'), + ), + ] diff --git a/evapp/models.py b/evapp/models.py index 9fc13dc..a7913ff 100644 --- a/evapp/models.py +++ b/evapp/models.py @@ -11,20 +11,13 @@ DEPARTMENT_CHOICES = {'PROG': 'Programme', 'CENT': 'Central', 'VOR': 'Vorstand',} -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)'} + 'MAC': 'Mac (nur für Grafiker_innen)'} OS_CHOICES = {'UBU': 'Ubuntu (Standard)', 'WIN': 'Windows (bitte Begründung angeben)',} -# MOBILE_CHOICES = {'NO': 'Kein Mobiltelefon', -# 'SIMPLE': 'Einfaches Gerät für Erreichbarkeit', -# 'SINGLE': 'Smartphone, Single SIM', -# 'DUAL': 'Smartphone, Dual SIM',} LANG_CHOICES = {'GER': 'Deutsch', 'ENG': 'English',} @@ -66,7 +59,6 @@ class Employee(models.Model): desk = models.CharField(max_length=100, null=True, blank=True, verbose_name="Wo soll der Arbeitsplatz sein?") # 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', verbose_name='Hersteller') os = models.CharField(max_length=3, choices=OS_CHOICES.items(), default='UBU', verbose_name='Betriebssystem') screen = models.BooleanField(default=False, verbose_name='Zusätzlicher Monitor? Einer ist standard.') diff --git a/evapp/views.py b/evapp/views.py index 0bfef77..e606561 100644 --- a/evapp/views.py +++ b/evapp/views.py @@ -11,7 +11,7 @@ from django.shortcuts import render from django.conf import settings from django.contrib.auth.mixins import LoginRequiredMixin -from .models import Employee, DEPARTMENT_CHOICES, LAPTOP_CHOICES, OS_CHOICES, VENDOR_CHOICES, \ +from .models import Employee, DEPARTMENT_CHOICES, OS_CHOICES, VENDOR_CHOICES, \ LANG_CHOICES, ACCOUNT_CHOICES, TRANSPONDER_CHOICES, KEYBOARD_CHOICES from .forms import PersonalForm, WorkingForm, ITForm, OfficeForm, DummyForm,\ ChangeForm, TYPE_CHOICES @@ -165,7 +165,7 @@ class EvaFormView(LoginRequiredMixin, CookieWizardView): ''' # update values in data dictionary with keys from *_CHOICES if present there - choices = {**DEPARTMENT_CHOICES, **LAPTOP_CHOICES, **TRANSPONDER_CHOICES, + choices = {**DEPARTMENT_CHOICES, **TRANSPONDER_CHOICES, **OS_CHOICES, **LANG_CHOICES, **VENDOR_CHOICES, **KEYBOARD_CHOICES} data.update({k:choices[v] for k,v in data.items() \ if isinstance(v,collections.abc.Hashable) \ From 4251fcbc2c5c4d099221b2f69ee02429aaf4d3d0 Mon Sep 17 00:00:00 2001 From: Benni Baermann Date: Wed, 5 May 2021 11:11:34 +0200 Subject: [PATCH 31/32] removed "None" and "[]" from last step and mails --- TODO | 2 +- evapp/views.py | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/TODO b/TODO index 8b13789..f3410d1 100644 --- a/TODO +++ b/TODO @@ -1 +1 @@ - +- remove None and [] in the overwiew in last step and in mails diff --git a/evapp/views.py b/evapp/views.py index e606561..4f687b6 100644 --- a/evapp/views.py +++ b/evapp/views.py @@ -176,6 +176,7 @@ class EvaFormView(LoginRequiredMixin, CookieWizardView): data['accounts'] = [ACCOUNT_CHOICES[c] for c in data['accounts']] # replace keys in data dictionary with verbose_name + # a bit ugly workaround here: we need to store 'email' away, because it es not in the modell mail = '' if 'email' in data: mail = data.pop('email') @@ -183,8 +184,11 @@ class EvaFormView(LoginRequiredMixin, CookieWizardView): if mail: newdata['Email'] = mail - #translate booleans + # translate booleans newdata.update({k:'Ja' for k,v in newdata.items() if isinstance(v,bool) and v == True}) newdata.update({k:'Nein' for k,v in newdata.items() if isinstance(v,bool) and v == False}) + # handle some special data types + newdata.update({k:'' for k,v in newdata.items() if v == None}) + newdata.update({k:'' for k,v in newdata.items() if v == []}) return newdata From 8bd6f9b34f6dd725edc6825de05b98eff2408ff1 Mon Sep 17 00:00:00 2001 From: Benni Baermann Date: Wed, 5 May 2021 11:12:31 +0200 Subject: [PATCH 32/32] just a minor doc fix --- TODO | 1 - 1 file changed, 1 deletion(-) diff --git a/TODO b/TODO index f3410d1..e69de29 100644 --- a/TODO +++ b/TODO @@ -1 +0,0 @@ -- remove None and [] in the overwiew in last step and in mails