From ce2e84395d61b05d5d72ac1ff0ca0840d12fa192 Mon Sep 17 00:00:00 2001 From: Benni Baermann Date: Wed, 21 Oct 2020 09:22:53 +0200 Subject: [PATCH] added project ForeignKey to HonoraryCertificate --- input/migrations/0015_auto_20201021_0721.py | 23 +++++++++++++++++++++ input/models.py | 4 ++-- input/views.py | 5 +++++ 3 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 input/migrations/0015_auto_20201021_0721.py diff --git a/input/migrations/0015_auto_20201021_0721.py b/input/migrations/0015_auto_20201021_0721.py new file mode 100644 index 0000000..f9efa51 --- /dev/null +++ b/input/migrations/0015_auto_20201021_0721.py @@ -0,0 +1,23 @@ +# Generated by Django 3.1.1 on 2020-10-21 07:21 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('input', '0014_auto_20201020_0714'), + ] + + operations = [ + migrations.RemoveField( + model_name='honorarycertificate', + name='number', + ), + migrations.AddField( + model_name='honorarycertificate', + name='project', + field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='input.project'), + ), + ] diff --git a/input/models.py b/input/models.py index 5e273fb..8f68a33 100644 --- a/input/models.py +++ b/input/models.py @@ -29,11 +29,11 @@ class Project(Volunteer): super().save(*args,*kwargs) def __str__(self): - return self.name + return f"{self.pid} {self.name}" class HonoraryCertificate(Volunteer): request_url = models.CharField(max_length=2000) - number = models.IntegerField(null = True) + project = models.ForeignKey(Project, null = True, on_delete = models.SET_NULL) def __str__(self): return "Certificate for " + self.realname diff --git a/input/views.py b/input/views.py index 7646348..bf3226d 100644 --- a/input/views.py +++ b/input/views.py @@ -14,6 +14,9 @@ from .settings import URLPREFIX, IF_EMAIL def authorize(request, choice, pk): + '''If IF grant a support they click a link in a mail which leads here''' + # TODO: write a timestamp which is needed to determine time of next mail + if choice in ('BIB', 'ELIT', 'SOFT'): Library.set_granted(pk,True) return HttpResponse(f"AUTHORIZED! choice: {choice}, pk: {pk}") @@ -22,6 +25,8 @@ def authorize(request, choice, pk): def deny(request, choice, pk): + '''If IF denies a support they click a link in a mail which leads here''' + if choice in ('BIB', 'ELIT', 'SOFT'): Library.set_granted(pk,False) return HttpResponse(f"DENIED! choice: {choice}, pk: {pk}")