Created
June 6, 2013 01:35
-
-
Save kevinseelbach/5718706 to your computer and use it in GitHub Desktop.
Trying to process step data and get friendly name in the process_step
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ContractWizard(SessionWizardView): | |
def get_template_names(self): | |
return [TEMPLATES[self.steps.current]] | |
def get_form_kwargs(self, step): | |
kwargs = super(ContractWizard, self).get_form_kwargs(step) | |
if step == 0: | |
kwargs['setting'] = get_object_or_404(Setting, pk=self.kwargs['setting']) | |
kwargs['rid'] = self.kwargs['rid'] | |
return kwargs | |
def get_form_initial(self, step): | |
initial = self.initial_dict.get(step, {}) | |
if step == 'contract': | |
initial.update(get_client_record(self.kwargs['rid'])) | |
return initial | |
def process_step(self, form): | |
step = self.steps.index | |
if step == 0 and hasattr(form, 'cleaned_data'): | |
cleaned_data = form.cleaned_data | |
roofing_brand = form.cleaned_data['roofing_brand'] | |
vent_type = form.cleaned_data['vent_type'] | |
roofing_brand_processed = get_name('models', ['1'], roofing_brand) | |
self.get_context_data(form=form).update({ 'roofing_brand_processed': roofing_brand_processed }) | |
cleaned_data['processed_roof_brand'] = roofing_brand_processed | |
self.get_form_step_data(form) | |
def get_context_data(self, form, **kwargs): | |
context = super(ContractWizard, self).get_context_data(form=form, **kwargs) | |
s = get_object_or_404(Setting, pk=self.kwargs['setting']) | |
rid = self.kwargs['rid'] | |
step = self.steps.index | |
if step == 0: | |
rs = redis.Redis('localhost') | |
s = Setting.objects.get(pk=1) | |
cache_context = get_cached_data(rid) | |
#qb_response = get_quickbase_record(s, rid) | |
for k, v in cache_context.iteritems(): | |
context.update({ k: v }) | |
elif step == 1: | |
contract_data = self.get_cleaned_data_for_step('contract') | |
print contract_data | |
elif step == 2: | |
insurance_data = self.get_cleaned_data_for_step('insurance') | |
print insurance_data | |
context.update({ 'insurance_data': insurance_data }) | |
elif step == 3: | |
mortgage_data = self.get_cleaned_data_for_step('mortgage') | |
context.update({ 'mortgage_data': mortgage_data }) | |
return context | |
def done(self, form_list, **kwargs): | |
form_data = [form.cleaned_data for form in form_list] | |
processed_data = [self.get_context_data(form=form) for form in form_list] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment