@ -1,4 +1,5 @@
from datetime import date
from datetime import date
from smtplib import SMTPException
from django.shortcuts import render
from django.shortcuts import render
from django.forms import modelformset_factory
from django.forms import modelformset_factory
@ -154,19 +155,19 @@ class ExternView(CookieWizardView):
print ( data )
print ( data )
# write data to database
# write data to database
for m = form . save ( commit = False )
modell = form . save ( commit = False )
# we have to copy the data from the first form here
# we have to copy the data from the first form here
# this is a bit ugly code. how can we copy this without explicit writing?
for m. realname = data [ ' realname ' ]
# this is a bit ugly code. can we copy this without explicit writing?
modell . realname = data [ ' realname ' ]
# form.username = data['username']
# form.username = data['username']
for m. email = data [ ' email ' ]
modell . email = data [ ' email ' ]
# write type of form in some cases
# write type of form in some cases
if data [ ' choice ' ] in ( ' BIB ' , ' ELIT ' , ' SOFT ' ) :
if data [ ' choice ' ] in ( ' BIB ' , ' ELIT ' , ' SOFT ' ) :
for m. type = data [ ' choice ' ]
modell . type = data [ ' choice ' ]
form . save ( )
form . save ( )
# add some data to context for mail templates
# add some data to context for mail templates
data [ ' pk ' ] = for m. pk
data [ ' pk ' ] = modell . pk
data [ ' urlprefix ' ] = settings . URLPREFIX
data [ ' urlprefix ' ] = settings . URLPREFIX
data [ ' grant ' ] = ( ' LIT ' , ' SOFT ' , ' ELIT ' , ' BIB ' , ' IFG ' )
data [ ' grant ' ] = ( ' LIT ' , ' SOFT ' , ' ELIT ' , ' BIB ' , ' IFG ' )
data [ ' DOMAIN ' ] = ( ' MAIL ' , ' LIST ' )
data [ ' DOMAIN ' ] = ( ' MAIL ' , ' LIST ' )
@ -181,7 +182,7 @@ class ExternView(CookieWizardView):
' Formular ausgefüllt ' ,
' Formular ausgefüllt ' ,
mail_template . render ( context ) ,
mail_template . render ( context ) ,
IF_EMAIL ,
IF_EMAIL ,
[ form . email ] ,
[ data [ ' email ' ] ] ,
fail_silently = False )
fail_silently = False )
# - mail to IF with link to accept/decline
# - mail to IF with link to accept/decline
mail_template = get_template ( ' input/if_mail.txt ' )
mail_template = get_template ( ' input/if_mail.txt ' )
@ -193,6 +194,9 @@ class ExternView(CookieWizardView):
fail_silently = False )
fail_silently = False )
except BadHeaderError :
except BadHeaderError :
return HttpResponse ( ' Invalid header found. ' )
return HttpResponse ( ' Invalid header found. Data not saved! ' )
except SMTPException :
return HttpResponse ( ' Error in sending mails (propably wrong adress?). Data not saved! ' )
return done ( self . request )
return done ( self . request )