forked from beba/foerderbarometer
authorize/deny Links in IF Mail should work now
This commit is contained in:
parent
a07853b129
commit
e0c20c5d64
|
@ -1,6 +1,6 @@
|
|||
# foerderbarometer
|
||||
|
||||
purpose: gather data from intern(WMDE) and extern(volonteers) forms to create a database ('förderdatenbank') and send emails with links for a questionary.
|
||||
purpose: gather data from intern(WMDE) and extern(volunteers) forms to create a database ('förderdatenbank') and send emails with links for a questionary.
|
||||
|
||||
used versions:
|
||||
|
||||
|
|
|
@ -20,13 +20,13 @@ class VolunteerForm(ModelForm):
|
|||
|
||||
class Meta:
|
||||
model = Volunteer
|
||||
fields = '__all__'
|
||||
exclude = ('granted',)
|
||||
|
||||
class LibraryForm(ModelForm):
|
||||
|
||||
class Meta:
|
||||
model = Library
|
||||
exclude = ('realname', 'email', 'username', 'type')
|
||||
exclude = ('realname', 'email', 'username', 'type', 'granted')
|
||||
|
||||
class IFGForm(ModelForm):
|
||||
class Meta:
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
# Generated by Django 3.1.1 on 2020-10-20 07:14
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('input', '0013_library_type'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='honorarycertificate',
|
||||
name='granted',
|
||||
field=models.BooleanField(null=True),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='ifg',
|
||||
name='granted',
|
||||
field=models.BooleanField(null=True),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='library',
|
||||
name='granted',
|
||||
field=models.BooleanField(null=True),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='project',
|
||||
name='granted',
|
||||
field=models.BooleanField(null=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='library',
|
||||
name='type',
|
||||
field=models.CharField(choices=[('BIB', 'Bibliotheksstipendium'), ('ELIT', 'eLiteraturstipendium'), ('SOFT', 'Softwarestipendium'), ('VIS', 'Visitenkarten'), ('LIST', 'Mailingliste'), ('MAIL', 'E-Mail-Adresse'), ('IFG', 'Kostenübernahme IFG-Anfrage'), ('LIT', 'Literaturstipendium')], default='LIB', max_length=4),
|
||||
),
|
||||
]
|
|
@ -5,6 +5,7 @@ class Volunteer(models.Model):
|
|||
realname = models.CharField(max_length=200, null=True)
|
||||
email = models.CharField(max_length=200, null=True)
|
||||
username = models.CharField(max_length=200, null=True)
|
||||
granted = models.BooleanField(null=True)
|
||||
|
||||
class Meta:
|
||||
abstract = True
|
||||
|
@ -39,7 +40,7 @@ class Grant(Volunteer):
|
|||
class Meta:
|
||||
abstract = True
|
||||
|
||||
# same model is used for Library, ELitStip and Software!
|
||||
|
||||
TYPE_CHOICES = [('BIB', 'Bibliotheksstipendium'),
|
||||
('ELIT', 'eLiteraturstipendium'),
|
||||
('SOFT', 'Softwarestipendium'),
|
||||
|
@ -49,6 +50,7 @@ TYPE_CHOICES = [('BIB', 'Bibliotheksstipendium'),
|
|||
('IFG', 'Kostenübernahme IFG-Anfrage'),
|
||||
('LIT', 'Literaturstipendium'),]
|
||||
|
||||
# same model is used for Library, ELitStip and Software!
|
||||
class Library(Grant):
|
||||
|
||||
type = models.CharField(
|
||||
|
|
|
@ -8,13 +8,30 @@ from django.template.loader import get_template
|
|||
from django.template import Context
|
||||
|
||||
from .forms import ProjectForm, VolunteerForm, LibraryForm, IFGForm
|
||||
from .models import Project, TYPE_CHOICES
|
||||
from .models import Project, TYPE_CHOICES, Library
|
||||
|
||||
|
||||
def set_granted_in_lib(key,b):
|
||||
lib = Library.objects.get(pk=key)
|
||||
lib.granted = b
|
||||
lib.save()
|
||||
|
||||
|
||||
def authorize(request, choice, pk):
|
||||
return HttpResponse(f"AUTHORIZE! choice: {choice}, pk: {pk}")
|
||||
if choice in ('BIB', 'ELIT', 'SOFT'):
|
||||
set_granted_in_lib(pk,True)
|
||||
return HttpResponse(f"AUTHORIZED! choice: {choice}, pk: {pk}")
|
||||
else:
|
||||
return HttpResponse('ERROR! UNKNWON CHOICE TYPE!')
|
||||
|
||||
|
||||
def deny(request, choice, pk):
|
||||
return HttpResponse(f"DENY! choice: {choice}, pk: {pk}")
|
||||
if choice in ('BIB', 'ELIT', 'SOFT'):
|
||||
set_granted_in_lib(pk,False)
|
||||
return HttpResponse(f"DENIED! choice: {choice}, pk: {pk}")
|
||||
else:
|
||||
return HttpResponse('ERROR! UNKNWON CHOICE TYPE!')
|
||||
|
||||
|
||||
def project(request):
|
||||
# return HttpResponse("Hello, world. You're at the input form")
|
||||
|
|
Loading…
Reference in New Issue