Example #1
0
    def process_step(self, form):
        """
        Custom process step method witch rewrite choices in DurationForm for
        current type of member type
        """
        subscription_id = self._get_member_type_from_request()
        if subscription_id:
            choices = generate_duration_choice(subscription_id)
            self.form_list['1'].base_fields['duration_type'].choices = choices

        return super(NotMemberFormWizard, self).process_step(form)
Example #2
0
 def test_generate_duration_choice_method(self):
     """
     Test that method generate currect choices
     """
     subscription = model_factory(Subscription, save=True)
     duration = model_factory(Duration, product=subscription, price=12,
                                                                 save=True)
     expected_value = [(duration.id, "{0} days for ${1}.00".format(
                                                 duration.duration.days,
                                                 duration.price))]
     current_value = generate_duration_choice(subscription.id)
     self.assertEqual(expected_value, current_value)