From 90e2bf5411def521013e7db8b106c3054319ab83 Mon Sep 17 00:00:00 2001 From: Benni Baermann Date: Wed, 7 Oct 2020 09:45:36 +0200 Subject: [PATCH] project-id generation works in principle --- input/forms.py | 4 ++-- input/migrations/0009_project_pid.py | 18 ++++++++++++++++++ input/migrations/0010_auto_20201007_0732.py | 18 ++++++++++++++++++ input/migrations/0011_auto_20201007_0743.py | 18 ++++++++++++++++++ input/models.py | 5 +++-- 5 files changed, 59 insertions(+), 4 deletions(-) create mode 100644 input/migrations/0009_project_pid.py create mode 100644 input/migrations/0010_auto_20201007_0732.py create mode 100644 input/migrations/0011_auto_20201007_0743.py diff --git a/input/forms.py b/input/forms.py index c96e1c2..6bf82a9 100644 --- a/input/forms.py +++ b/input/forms.py @@ -10,8 +10,8 @@ class ProjectForm(ModelForm): class Meta: model = Project - fields = '__all__' - # exclude = ('pid',) + # fields = '__all__' + exclude = ('pid',) class VolunteerForm(ModelForm): diff --git a/input/migrations/0009_project_pid.py b/input/migrations/0009_project_pid.py new file mode 100644 index 0000000..e37fbac --- /dev/null +++ b/input/migrations/0009_project_pid.py @@ -0,0 +1,18 @@ +# Generated by Django 3.1.1 on 2020-10-07 07:31 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('input', '0008_ifg'), + ] + + operations = [ + migrations.AddField( + model_name='project', + name='pid', + field=models.IntegerField(null=True), + ), + ] diff --git a/input/migrations/0010_auto_20201007_0732.py b/input/migrations/0010_auto_20201007_0732.py new file mode 100644 index 0000000..beba249 --- /dev/null +++ b/input/migrations/0010_auto_20201007_0732.py @@ -0,0 +1,18 @@ +# Generated by Django 3.1.1 on 2020-10-07 07:32 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('input', '0009_project_pid'), + ] + + operations = [ + migrations.AlterField( + model_name='project', + name='pid', + field=models.IntegerField(blank=True, null=True), + ), + ] diff --git a/input/migrations/0011_auto_20201007_0743.py b/input/migrations/0011_auto_20201007_0743.py new file mode 100644 index 0000000..5dcf6bf --- /dev/null +++ b/input/migrations/0011_auto_20201007_0743.py @@ -0,0 +1,18 @@ +# Generated by Django 3.1.1 on 2020-10-07 07:43 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('input', '0010_auto_20201007_0732'), + ] + + operations = [ + migrations.AlterField( + model_name='project', + name='start', + field=models.DateField(verbose_name='start date'), + ), + ] diff --git a/input/models.py b/input/models.py index bcfccdc..66501c2 100644 --- a/input/models.py +++ b/input/models.py @@ -11,10 +11,10 @@ class Volunteer(models.Model): class Project(Volunteer): name = models.CharField(max_length=200) - start = models.DateTimeField('start date') + start = models.DateField('start date') # contact = models.ForeignKey(Volonteer, on_delete = models.CASCADE, null = True) - pid = models.IntegerField(null=True) # automaticly generated + pid = models.IntegerField(null=True, blank=True) # automaticly generated # @property # def pid(self): # pid = "hurzel " + self.get_pk @@ -22,6 +22,7 @@ class Project(Volunteer): # return pid def save(self,*args,**kwargs): + super().save(*args,*kwargs) self.pid = 10000 + self.pk super().save(*args,*kwargs)