ich wollte nur fragen, ob folgender Code akzeptabel ist, oder ob und was man noch verbessern kann:
Code: Alles auswählen
n = context.REQUEST.get('promocode')
c = context.REQUEST.get('conference_fee')
b = int(c)*0.9 #Die conference_fee abzüglich Gutschein 10%
a = int(c)*0.1 #Der Gutschein 10% Preis
#entscheidet welcher der Radio-Buttons ausgewählt wurde und übergibt die Bezeichnung, anders möglich??
if c == '350':
o = 'Conference registration for NOC'
elif c == '135':
o = 'Conference registration for NOC (Student rate)'
elif c == '190':
o = 'Conference registration for OC&I'
elif c == '390':
o = 'Conference registration for both NOC and OC&I'
else:
None
#Entscheidet ob ein Gutscheincode eingegeben wurde und gibt den Status zurück und die Input Werte
if n !='':
if n == 'noc08krems':
state.setError('promocode', None, new_status='success')
state.setKwargs( {'portal_status_message':'Promotion Code is ok: ' + n + ' || ' + c + ' -10% (Promotion Code) = ' + str(b) + '€ Your Fees'} )
context.REQUEST.set('option', o)
context.REQUEST.set('optionprice', c)
context.REQUEST.set('conference_fee', b)
context.REQUEST.set('promocodefee', a)
else:
state.setError('promocode', 'Invalid Entry', new_status='failure')
state.setKwargs( {'portal_status_message':'Promotion Code is invalid'} )
context.REQUEST.set('option', o)
context.REQUEST.set('optionprice', c)
else:
context.REQUEST.set('option', o)
context.REQUEST.set('optionprice', c)
# No errors. Always make sure to return the ControllerState object
return state

lg
miichi