All pastes #1192595 Raw Edit

clueless

public text v1 · immutable
#1192595 ·published 2008-09-03 15:35 UTC
rendered paste body
from django import formsfrom django.shortcuts import render_to_responsefrom django.contrib.formtools.wizard import FormWizardfrom django.http import HttpResponseRedirect, HttpResponsefrom time import gmtime, strftimeclass QuoteWizard(FormWizard):  def render_hash_failure(self, request, step):    return self.render(self.get_form(step), request, step,                       context={'wizard_error':                                 'We apologize, but your form has expired. Please continue filling out the form from this page.'})  def process_step(self, request, form, step):       print "%s: Current Step [%s] " % (strftime("[%d/%b/%Y %H:%M:%S]", gmtime()), step)      print "%s: Current Class [%s] " % (strftime("[%d/%b/%Y %H:%M:%S]", gmtime()), form.__class__.__name__)      if form.__dict__.has_key('cleaned_data'):         for attr in form.cleaned_data: print "%s: Current Variable [%s => %s]" % (strftime("[%d/%b/%Y %H:%M:%S]", gmtime()), attr, form.cleaned_data[attr])      for attr in self.form_list: print "%s: FormWizard Form #%d => %s" %(strftime("[%d/%b/%Y %H:%M:%S]", gmtime()), step, attr)            if form.__class__.__name__ == 'DetailedInformationForm' and form.__dict__.has_key('cleaned_data'):        if form.cleaned_data['preferred_network'] == "premium":          self.form_list[3] = PackageSelectionPremium        else:          self.form_list[3] = PackageSelectionValue      elif form.__class__.__name__ == 'PackageSelectionValue':          self.form_list[4] = EquipmentSelectionValue      elif form.__class__.__name__ == 'PackageSelectionPremium':          self.form_list[4] = EquipmentSelectionPremium      elif form.__class__.__name__ == 'EquipmentSelectionValue':          self.form_list[5] = ConnectionSelectionValue      elif form.__class__.__name__ == 'EquipmentSelectionPremium':          self.form_list[5] = ConnectionSelectionPremium  def get_template(self, step):    return [ 'estimates/forms/wizard_%s.html' % step, 'estimates/forms/wizard.html' ]   def done(self, request, form_list):    return render_to_response('estimates/review.html', { 'form_data': [ form.cleaned_data for form in form_list ], })class DisclaimerForm(forms.Form):  passclass BasicInformationForm(forms.Form):  LOCATION_CHOICES = (        ('calgary', 'Calgary'),        ('edmonton', 'Edmonton'),        ('st_albert', 'St. Albert'),        ('lethbridge', 'Lethbridge'),        ('red_deer', 'Red Deer'),        ('unlisted_location', 'Unlisted Location'))  employee_count = forms.IntegerField(min_value=1,max_value=500)  call_centre_required = forms.BooleanField(required=False)  call_centre_lines_required = forms.IntegerField(min_value=1,max_value=500,required=False)  current_location = forms.ChoiceField(LOCATION_CHOICES)  unlisted_location = forms.CharField(required=False)class DetailedInformationForm(forms.Form):  AVAILABLE_NETWORKS = (    ('value', 'Value Network'),    ('premium', 'Premium Network'))  preferred_network = forms.ChoiceField(AVAILABLE_NETWORKS)class PackageSelectionValue(forms.Form):  AVAILABLE_PACKAGES = (     ('basic', 'Basic Package'),    ('advanced', 'Advanced Package'))  package_selection = forms.ChoiceField(AVAILABLE_PACKAGES)class PackageSelectionPremium(forms.Form):  AVAILABLE_PACKAGES = (     ('lobby', 'Lobby'),    ('office_user', 'Office User'),    ('office_plus', 'Office Plus'),    ('power_plus', 'Power Plus'))  package_selection = forms.ChoiceField(AVAILABLE_PACKAGES)class EquipmentSelectionValue(forms.Form):  AVAILABLE_EQUIPMENT = (    ('mitel_5224', 'Mitel 5224'))  equipment_selection = forms.ChoiceField(AVAILABLE_EQUIPMENT)class EquipmentSelectionPremium(forms.Form):  AVAILABLE_EQUIPMENT = (     ('polycom_301', 'Polycom Soundpoint IP 301'),    ('polycom_501', 'Polycom Soundpoint IP 501'),    ('polycom_601', 'Polycom Soundpoint IP 601'),    ('polycom_4000', 'Polycom Soundstation IP 4000'),    ('byod', 'Bring your own device'))  equipment_selection = forms.ChoiceField(AVAILABLE_EQUIPMENT)class ConnectionSelectionValue(forms.Form):  AVAILABLE_CONNECTIONS = (    ('shift_voicelink', 'Shift Networks Voicelink'))  connection_selection = forms.ChoiceField(AVAILABLE_CONNECTIONS)class ConnectionSelectionPremium(forms.Form):  AVAILABLE_CONNECTIONS = (    ('shift_voicelink', 'Shift Networks Voicelink'),    ('best_efforts', 'Best efforts (Use your own connection)'))  connection_selection = forms.ChoiceField(AVAILABLE_CONNECTIONS)class AdditionalOptionsValue(forms.Form):  AVAILABLE_OPTIONS = (    ('calling_group', 'Hunt Groups'),    ('monitor_group', 'Busy Lamp Field'),    ('auto_attendant', 'Auto-Attendant'))  options_selection_1 = forms.ChoiceField(AVAILABLE_OPTIONS)  options_selection_1_value = forms.CharField(required=False)  options_selection_2 = forms.ChoiceField(AVAILABLE_OPTIONS)  options_selection_2_value = forms.CharField(required=False)  options_selection_3 = forms.ChoiceField(AVAILABLE_OPTIONS)  options_selection_3_value = forms.CharField(required=False)  options_selection_4 = forms.ChoiceField(AVAILABLE_OPTIONS)  options_selection_4_value = forms.CharField(required=False)  options_selection_5 = forms.ChoiceField(AVAILABLE_OPTIONS)  options_selection_5_value = forms.CharField(required=False)  options_selection_6 = forms.ChoiceField(AVAILABLE_OPTIONS)  options_selection_6_value = forms.CharField(required=False)  options_selection_7 = forms.ChoiceField(AVAILABLE_OPTIONS)  options_selection_7_value = forms.CharField(required=False)  options_selection_8 = forms.ChoiceField(AVAILABLE_OPTIONS)  options_selection_8_value = forms.CharField(required=False)class AdditionalOptionsPremium(forms.Form):  AVAILABLE_OPTIONS = (    ('hunt_group', 'Hunt Groups'),    ('busy_lamp_field', 'Busy Lamp Field'),    ('call_centre', 'Call Centre'),    ('auto_attendant', 'Auto-Attendant'))  options_selection_1 = forms.ChoiceField(AVAILABLE_OPTIONS)  options_selection_1_value = forms.CharField(required=False)  options_selection_2 = forms.ChoiceField(AVAILABLE_OPTIONS)  options_selection_2_value = forms.CharField(required=False)  options_selection_3 = forms.ChoiceField(AVAILABLE_OPTIONS)  options_selection_3_value = forms.CharField(required=False)  options_selection_4 = forms.ChoiceField(AVAILABLE_OPTIONS)  options_selection_4_value = forms.CharField(required=False)  options_selection_5 = forms.ChoiceField(AVAILABLE_OPTIONS)  options_selection_5_value = forms.CharField(required=False)  options_selection_6 = forms.ChoiceField(AVAILABLE_OPTIONS)  options_selection_6_value = forms.CharField(required=False)  options_selection_7 = forms.ChoiceField(AVAILABLE_OPTIONS)  options_selection_7_value = forms.CharField(required=False)  options_selection_8 = forms.ChoiceField(AVAILABLE_OPTIONS)  options_selection_8_value = forms.CharField(required=False)