Beispiel #1
0
        def __get_variants(variant_group, licence_type, current_params):
            variants = []

            for variant in variant_group.variants.all():
                variant_dict = {'text': variant.name}

                params = current_params + [variant]

                if variant_group.child is not None:
                    variant_dict['nodes'] = __get_variants(
                        variant_group.child, licence_type, params)
                else:
                    encoded_params = urlencode(
                        {'variants': [v.id for v in params]}, doseq=True)

                    variant_dict['href'] = '{}?{}'.format(
                        reverse('wl_applications:select_licence_type',
                                args=(licence_type.id, )), encoded_params)

                    prod_code = '{} {}'.format(
                        licence_type.product_title,
                        ' '.join([v.product_title for v in params]))
                    variant_dict['price'] = get_licence_price(prod_code)

                variant_dict['help_text'] = variant.help_text

                variants.append(variant_dict)

            return variants
Beispiel #2
0
        def __populate_category_dict(category_dict, licence_type_queryset, categories):
            for licence_type in licence_type_queryset:
                licence_type_dict = {'text': licence_type.name}

                if licence_type.variant_group is not None:
                    licence_type_dict['nodes'] = __get_variants(licence_type.variant_group, licence_type, [])
                else:
                    licence_type_dict['href'] = reverse('wl_applications:select_licence_type',
                                                        args=(licence_type.id,))

                    licence_type_dict['price'] = get_licence_price(licence_type.product_code)

                category_dict['licence_types'].append(licence_type_dict)

                licence_type_dict['help_text'] = licence_type.help_text

            categories.append(category_dict)
Beispiel #3
0
        def __populate_category_dict(category_dict, licence_type_queryset,
                                     categories):
            for licence_type in licence_type_queryset:
                licence_type_dict = {'text': licence_type.name}

                if licence_type.variant_group is not None:
                    licence_type_dict['nodes'] = __get_variants(
                        licence_type.variant_group, licence_type, [])
                else:
                    licence_type_dict['href'] = reverse(
                        'wl_applications:select_licence_type',
                        args=(licence_type.id, ))

                    licence_type_dict['price'] = get_licence_price(
                        licence_type.product_title)

                category_dict['licence_types'].append(licence_type_dict)

                licence_type_dict['help_text'] = licence_type.help_text

            categories.append(category_dict)
Beispiel #4
0
        def __get_variants(variant_group, licence_type, current_params):
            variants = []

            for variant in variant_group.variants.all():
                variant_dict = {'text': variant.name}

                params = current_params + [variant]

                if variant_group.child is not None:
                    variant_dict['nodes'] = __get_variants(variant_group.child, licence_type, params)
                else:
                    encoded_params = urlencode({'variants': [v.id for v in params]}, doseq=True)

                    variant_dict['href'] = '{}?{}'.format(reverse('wl_applications:select_licence_type',
                                                                  args=(licence_type.id,)), encoded_params)

                    prod_code = '{} {}'.format(licence_type.product_code, ' '.join([v.product_code for v in params]))
                    variant_dict['price'] = get_licence_price(prod_code)

                variant_dict['help_text'] = variant.help_text

                variants.append(variant_dict)

            return variants