more work on LIT and VIS, some restructuring
This commit is contained in:
parent
afa0f6b55a
commit
33387f7648
|
@ -4,7 +4,8 @@ from django.contrib.admin.widgets import AdminDateWidget
|
||||||
from django.utils.html import format_html
|
from django.utils.html import format_html
|
||||||
|
|
||||||
from .models import Project, Volunteer, Extern, IFG, Library, TYPE_CHOICES,\
|
from .models import Project, Volunteer, Extern, IFG, Library, TYPE_CHOICES,\
|
||||||
HonoraryCertificate, Travel, Email
|
HonoraryCertificate, Travel, Email, Literature, List,\
|
||||||
|
BusinessCard
|
||||||
from .settings import DATAPROTECTION, FOERDERRICHTLINIEN, NUTZUNGSBEDINGUNGEN
|
from .settings import DATAPROTECTION, FOERDERRICHTLINIEN, NUTZUNGSBEDINGUNGEN
|
||||||
|
|
||||||
|
|
||||||
|
@ -66,6 +67,11 @@ class HonoraryCertificateForm(ModelForm):
|
||||||
fields = ['request_url', 'project']
|
fields = ['request_url', 'project']
|
||||||
# exclude = ('realname', 'email', 'username', 'granted', 'granted_date', 'survey_mail_send')
|
# exclude = ('realname', 'email', 'username', 'granted', 'granted_date', 'survey_mail_send')
|
||||||
|
|
||||||
|
class LiteratureForm(ModelForm):
|
||||||
|
class Meta:
|
||||||
|
model = Literature
|
||||||
|
fields = ['cost', 'notes', 'info', 'source']
|
||||||
|
|
||||||
class EmailForm(ModelForm):
|
class EmailForm(ModelForm):
|
||||||
# TODO: add some javascript to show/hide other-field
|
# TODO: add some javascript to show/hide other-field
|
||||||
check = BooleanField(required=True,
|
check = BooleanField(required=True,
|
||||||
|
@ -76,3 +82,13 @@ class EmailForm(ModelForm):
|
||||||
model = Email
|
model = Email
|
||||||
fields = ['domain', 'address', 'other']
|
fields = ['domain', 'address', 'other']
|
||||||
# exclude = ('realname', 'email', 'username', 'granted', 'granted_date', 'survey_mail_send')
|
# exclude = ('realname', 'email', 'username', 'granted', 'granted_date', 'survey_mail_send')
|
||||||
|
|
||||||
|
class BusinessCardForm(ModelForm):
|
||||||
|
class Meta:
|
||||||
|
model = BusinessCard
|
||||||
|
fields = ['project', 'data', 'variant', 'sent_to']
|
||||||
|
|
||||||
|
class ListForm(ModelForm):
|
||||||
|
class Meta:
|
||||||
|
model = List
|
||||||
|
fields = ['domain', 'address']
|
||||||
|
|
|
@ -6,7 +6,7 @@ from django.template.loader import get_template
|
||||||
from django.core.mail import send_mail, BadHeaderError
|
from django.core.mail import send_mail, BadHeaderError
|
||||||
|
|
||||||
from input.models import Project, Library, HonoraryCertificate, Travel, Email,\
|
from input.models import Project, Library, HonoraryCertificate, Travel, Email,\
|
||||||
BusinessCard, List, IFG
|
BusinessCard, List, IFG, Literature
|
||||||
from input.settings import URLPREFIX, IF_EMAIL, SURVEYPREFIX
|
from input.settings import URLPREFIX, IF_EMAIL, SURVEYPREFIX
|
||||||
|
|
||||||
class Command(BaseCommand):
|
class Command(BaseCommand):
|
||||||
|
@ -112,6 +112,14 @@ class Command(BaseCommand):
|
||||||
.exclude(survey_mail_send=True)
|
.exclude(survey_mail_send=True)
|
||||||
self.surveymails_to_object(supported, type='IFG', name='url')
|
self.surveymails_to_object(supported, type='IFG', name='url')
|
||||||
|
|
||||||
|
def surveymails_to_lit(self):
|
||||||
|
'''get all Litearure objects which where granted two weeks ago'''
|
||||||
|
|
||||||
|
supported = Literature.objects.filter(granted=True)\
|
||||||
|
.filter(granted_date__lt = date.today() - timedelta(days=14))\
|
||||||
|
.exclude(survey_mail_send=True)
|
||||||
|
self.surveymails_to_object(supported, type='LIT', name='info')
|
||||||
|
|
||||||
def surveymails_to_project(self):
|
def surveymails_to_project(self):
|
||||||
'''send survey link 4 weeks after end of project reached'''
|
'''send survey link 4 weeks after end of project reached'''
|
||||||
supported = Project.objects.filter(granted=True)\
|
supported = Project.objects.filter(granted=True)\
|
||||||
|
@ -149,6 +157,7 @@ class Command(BaseCommand):
|
||||||
self.surveymails_to_lib()
|
self.surveymails_to_lib()
|
||||||
self.surveymails_to_hon()
|
self.surveymails_to_hon()
|
||||||
self.surveymails_to_ifg()
|
self.surveymails_to_ifg()
|
||||||
|
self.surveymails_to_lit()
|
||||||
self.surveymails_to_project()
|
self.surveymails_to_project()
|
||||||
self.surveymails_to_travel()
|
self.surveymails_to_travel()
|
||||||
self.surveymails_to_mail_vis_lis()
|
self.surveymails_to_mail_vis_lis()
|
||||||
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
# Generated by Django 3.1.1 on 2020-10-27 12:47
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('input', '0028_auto_20201027_1131'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='Literature',
|
||||||
|
fields=[
|
||||||
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('realname', models.CharField(max_length=200, null=True)),
|
||||||
|
('email', models.CharField(max_length=200, null=True)),
|
||||||
|
('granted', models.BooleanField(null=True)),
|
||||||
|
('granted_date', models.DateField(null=True)),
|
||||||
|
('survey_mail_send', models.BooleanField(null=True)),
|
||||||
|
('username', models.CharField(max_length=200, null=True)),
|
||||||
|
('cost', models.CharField(max_length=10)),
|
||||||
|
('notes', models.CharField(blank=True, max_length=500)),
|
||||||
|
('info', models.CharField(max_length=500)),
|
||||||
|
('source', models.CharField(max_length=200)),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'abstract': False,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='ifg',
|
||||||
|
name='notes',
|
||||||
|
field=models.CharField(blank=True, max_length=500),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='library',
|
||||||
|
name='notes',
|
||||||
|
field=models.CharField(blank=True, max_length=500),
|
||||||
|
),
|
||||||
|
]
|
|
@ -80,7 +80,7 @@ class Travel(Intern):
|
||||||
#abstract base class for Library and IFG
|
#abstract base class for Library and IFG
|
||||||
class Grant(Extern):
|
class Grant(Extern):
|
||||||
cost = models.CharField(max_length=10)
|
cost = models.CharField(max_length=10)
|
||||||
notes = models.CharField(max_length=500)
|
notes = models.CharField(max_length=500, blank=True)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
abstract = True
|
abstract = True
|
||||||
|
@ -110,6 +110,9 @@ class Library(Grant):
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.library
|
return self.library
|
||||||
|
|
||||||
|
class Literature(Grant):
|
||||||
|
info = models.CharField(max_length=500)
|
||||||
|
source = models.CharField(max_length=200)
|
||||||
|
|
||||||
class IFG(Grant):
|
class IFG(Grant):
|
||||||
url = models.CharField(max_length=2000)
|
url = models.CharField(max_length=2000)
|
||||||
|
|
|
@ -9,33 +9,45 @@ from django.conf import settings
|
||||||
from django.template.loader import get_template
|
from django.template.loader import get_template
|
||||||
from django.template import Context
|
from django.template import Context
|
||||||
|
|
||||||
from .forms import ProjectForm, ExternForm, LibraryForm, IFGForm,\
|
from .forms import ProjectForm, ExternForm, LibraryForm, IFGForm, LiteratureForm,\
|
||||||
HonoraryCertificateForm, InternForm, TravelForm, EmailForm
|
HonoraryCertificateForm, InternForm, TravelForm, EmailForm,\
|
||||||
from .models import Project, TYPE_CHOICES, Library
|
ListForm, BusinessCardForm
|
||||||
|
from .models import Project, TYPE_CHOICES, Library, Literature
|
||||||
from .settings import URLPREFIX, IF_EMAIL
|
from .settings import URLPREFIX, IF_EMAIL
|
||||||
|
|
||||||
|
|
||||||
|
def auth_deny(choice,pk,auth):
|
||||||
|
if choice in ('BIB', 'ELIT', 'SOFT'):
|
||||||
|
Library.set_granted(pk,auth)
|
||||||
|
if choice == 'LIT':
|
||||||
|
Literature.set_granted(pk,auth)
|
||||||
|
if choice == 'IFG':
|
||||||
|
IFG.set_granted(pk,auth)
|
||||||
|
else:
|
||||||
|
return HttpResponse(f'ERROR! UNKNWON CHOICE TYPE! {choice}')
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
def authorize(request, choice, pk):
|
def authorize(request, choice, pk):
|
||||||
'''If IF grant a support they click a link in a mail which leads here.
|
'''If IF grant a support they click a link in a mail which leads here.
|
||||||
We write the granted field in the database here and set a timestamp.'''
|
We write the granted field in the database here and set a timestamp.'''
|
||||||
# TODO: write a timestamp which is needed to determine time of next mail
|
|
||||||
|
|
||||||
if choice in ('BIB', 'ELIT', 'SOFT'):
|
ret = auth_deny(choice, pk, True)
|
||||||
Library.set_granted(pk,True)
|
if ret:
|
||||||
return HttpResponse(f"AUTHORIZED! choice: {choice}, pk: {pk}")
|
return ret
|
||||||
else:
|
else:
|
||||||
return HttpResponse(f'ERROR! UNKNWON CHOICE TYPE! {choice}')
|
return HttpResponse(f"AUTHORIZED! choice: {choice}, pk: {pk}")
|
||||||
|
|
||||||
|
|
||||||
def deny(request, choice, pk):
|
def deny(request, choice, pk):
|
||||||
'''If IF denies a support they click a link in a mail which leads here
|
'''If IF denies a support they click a link in a mail which leads here
|
||||||
We write the granted field in the database here.'''
|
We write the granted field in the database here.'''
|
||||||
|
|
||||||
if choice in ('BIB', 'ELIT', 'SOFT'):
|
ret = auth_deny(choice, pk, False)
|
||||||
Library.set_granted(pk,False)
|
if ret:
|
||||||
return HttpResponse(f"DENIED! choice: {choice}, pk: {pk}")
|
return ret
|
||||||
else:
|
else:
|
||||||
return HttpResponse(f'ERROR! UNKNWON CHOICE TYPE {choice}!')
|
return HttpResponse(f"DENIED! choice: {choice}, pk: {pk}")
|
||||||
|
|
||||||
|
|
||||||
def done(request):
|
def done(request):
|
||||||
|
@ -119,6 +131,12 @@ class ExternView(CookieWizardView):
|
||||||
form.fields['library'].label = TYPE_CHOICES[choice]
|
form.fields['library'].label = TYPE_CHOICES[choice]
|
||||||
elif choice == 'MAIL':
|
elif choice == 'MAIL':
|
||||||
form = EmailForm(data)
|
form = EmailForm(data)
|
||||||
|
elif choice == 'LIT':
|
||||||
|
form = LiteratureForm(data)
|
||||||
|
elif choice == 'VIS':
|
||||||
|
form = BusinessCardForm(data)
|
||||||
|
elif choice == 'LIST':
|
||||||
|
form = ListForm(data)
|
||||||
else:
|
else:
|
||||||
raise RuntimeError(f'ERROR! UNKNOWN FORMTYPE {choice} in ExternView')
|
raise RuntimeError(f'ERROR! UNKNOWN FORMTYPE {choice} in ExternView')
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue