From 94164c3d6af584214424705164156e3c352e21c7 Mon Sep 17 00:00:00 2001 From: Benni Baermann Date: Tue, 6 Jul 2021 13:00:34 +0200 Subject: [PATCH] fixed TypeError for django 3.2 --- TODO | 10 ++++----- input/forms.py | 4 ++-- input/migrations/0060_concreteextern.py | 30 +++++++++++++++++++++++++ input/models.py | 6 ++++- 4 files changed, 41 insertions(+), 9 deletions(-) create mode 100644 input/migrations/0060_concreteextern.py diff --git a/TODO b/TODO index 3ec440f..11c829d 100644 --- a/TODO +++ b/TODO @@ -20,10 +20,8 @@ other known problems: - we should add dates to the outputs, to make it more useful in logfiles -known problems in production: +- maybe change logo in browser dark mode to https://upload.wikimedia.org/wikipedia/commons/2/2a/Wmde_logo_vert_weiss.png -- works only with django == 3.1.x - -- reboot of container should be far more automated - -- puppet should provide the git source, and secrets.json and settings.py link +- warning from django 3.2: +input.BusinessCard: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'. + HINT: Configure the DEFAULT_AUTO_FIELD setting or the InputConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'. diff --git a/input/forms.py b/input/forms.py index 5dc5c3d..4994207 100644 --- a/input/forms.py +++ b/input/forms.py @@ -3,7 +3,7 @@ from django.forms import ModelForm, DateField, ChoiceField, RadioSelect, Boolean from django.contrib.admin.widgets import AdminDateWidget from django.utils.html import format_html -from .models import Project, Volunteer, Extern, IFG, Library, TYPE_CHOICES,\ +from .models import Project, Volunteer, Extern, ConcreteExtern, IFG, Library, TYPE_CHOICES,\ HonoraryCertificate, Travel, Email, Literature, List,\ BusinessCard from .settings import DATAPROTECTION, FOERDERRICHTLINIEN, NUTZUNGSBEDINGUNGEN @@ -36,7 +36,7 @@ class ExternForm(FdbForm): DATAPROTECTION, FOERDERRICHTLINIEN)) class Meta: - model = Extern + model = ConcreteExtern exclude = ('granted', 'granted_date', 'survey_mail_send', 'service_id', 'survey_mail_date') INTERN_CHOICES = {'PRO': 'Projektsteckbrief', diff --git a/input/migrations/0060_concreteextern.py b/input/migrations/0060_concreteextern.py new file mode 100644 index 0000000..14d9809 --- /dev/null +++ b/input/migrations/0060_concreteextern.py @@ -0,0 +1,30 @@ +# Generated by Django 3.2.5 on 2021-07-06 10:51 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('input', '0059_auto_20210412_1142'), + ] + + operations = [ + migrations.CreateModel( + name='ConcreteExtern', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('realname', models.CharField(help_text='Bitte gib deinen Vornamen und deinen Nachnamen ein.', max_length=200, null=True, verbose_name='Realname')), + ('email', models.EmailField(help_text='Bitte gib deine E-Mail-Adresse ein, damit dich
Wikimedia Deutschland bei Rückfragen oder für
die Zusage kontaktieren kann.', max_length=200, null=True, verbose_name='E-Mail-Adresse')), + ('granted', models.BooleanField(null=True)), + ('granted_date', models.DateField(null=True)), + ('survey_mail_send', models.BooleanField(default=False, verbose_name='Keine Umfragemail schicken')), + ('survey_mail_date', models.DateField(blank=True, null=True, verbose_name='Umfragemail wurde verschickt am')), + ('username', models.CharField(help_text='Bitte gib den Namen ein, mit dem du dich
in den Wikimedia-Projekten registriert hast.', max_length=200, null=True, verbose_name='Benutzer_innenname')), + ('service_id', models.CharField(blank=True, max_length=15, null=True)), + ], + options={ + 'abstract': False, + }, + ), + ] diff --git a/input/models.py b/input/models.py index c01db7d..69a845e 100644 --- a/input/models.py +++ b/input/models.py @@ -17,7 +17,7 @@ class Volunteer(models.Model): granted_date = models.DateField(null=True) survey_mail_send = models.BooleanField(default=False, verbose_name='Keine Umfragemail schicken') survey_mail_date = models.DateField(verbose_name='Umfragemail wurde verschickt am', null=True, blank=True) - + @classmethod def set_granted(cl, key, b): obj = cl.objects.get(pk=key) @@ -46,6 +46,10 @@ class Extern(Volunteer): class Meta: abstract = True +class ConcreteExtern(Extern): + ''' needed because we can't initiate abstract base classes in the view''' + pass + 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)