Browse Source

project-id generation works in principle

master
Benni Baermann 4 years ago
parent
commit
90e2bf5411
5 changed files with 59 additions and 4 deletions
  1. +2
    -2
      input/forms.py
  2. +18
    -0
      input/migrations/0009_project_pid.py
  3. +18
    -0
      input/migrations/0010_auto_20201007_0732.py
  4. +18
    -0
      input/migrations/0011_auto_20201007_0743.py
  5. +3
    -2
      input/models.py

+ 2
- 2
input/forms.py View File

@ -10,8 +10,8 @@ class ProjectForm(ModelForm):
class Meta: class Meta:
model = Project model = Project
fields = '__all__'
# exclude = ('pid',)
# fields = '__all__'
exclude = ('pid',)
class VolunteerForm(ModelForm): class VolunteerForm(ModelForm):

+ 18
- 0
input/migrations/0009_project_pid.py View File

@ -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),
),
]

+ 18
- 0
input/migrations/0010_auto_20201007_0732.py View File

@ -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),
),
]

+ 18
- 0
input/migrations/0011_auto_20201007_0743.py View File

@ -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'),
),
]

+ 3
- 2
input/models.py View File

@ -11,10 +11,10 @@ class Volunteer(models.Model):
class Project(Volunteer): class Project(Volunteer):
name = models.CharField(max_length=200) 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) # 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 # @property
# def pid(self): # def pid(self):
# pid = "hurzel " + self.get_pk # pid = "hurzel " + self.get_pk
@ -22,6 +22,7 @@ class Project(Volunteer):
# return pid # return pid
def save(self,*args,**kwargs): def save(self,*args,**kwargs):
super().save(*args,*kwargs)
self.pid = 10000 + self.pk self.pid = 10000 + self.pk
super().save(*args,*kwargs) super().save(*args,*kwargs)

Loading…
Cancel
Save