Пример #1
0
 def get_all_options(self):
     """
     Returns all possible combinations of options for this products OptionGroups as a List of Lists.
     Ex:
     For OptionGroups Color and Size with Options (Blue, Green) and (Large, Small) you'll get
     [['Blue', 'Small'], ['Blue', 'Large'], ['Green', 'Small'], ['Green', 'Large']]
     Note: the actual values will be instances of Option instead of strings
     """
     sublist = []
     masterlist = []
     #Create a list of all the options & create all combos of the options
     for opt in self.option_group.all():
         for value in opt.option_set.all():
             sublist.append(value)
         masterlist.append(sublist)
         sublist = []
     return cross_list(masterlist)
Пример #2
0
 def get_all_options(self):
     """
     Returns all possible combinations of options for this products OptionGroups as a List of Lists.
     Ex:
     For OptionGroups Color and Size with Options (Blue, Green) and (Large, Small) you'll get
     [['Blue', 'Small'], ['Blue', 'Large'], ['Green', 'Small'], ['Green', 'Large']]
     Note: the actual values will be instances of Option instead of strings
     """
     sublist = []
     masterlist = []
     #Create a list of all the options & create all combos of the options
     for opt in self.option_group.all():
         for value in opt.option_set.all():
             sublist.append(value)
         masterlist.append(sublist)
         sublist = []
     return cross_list(masterlist)
Пример #3
0
def get_all_options(obj, ids_only=False):
    """
    Returns all possible combinations of options for this products OptionGroups as a List of Lists.
    Ex:
    For OptionGroups Color and Size with Options (Blue, Green) and (Large, Small) you'll get
    [['Blue', 'Small'], ['Blue', 'Large'], ['Green', 'Small'], ['Green', 'Large']]
    Note: the actual values will be instances of Option instead of strings
    """
    sublist = []
    masterlist = []
    #Create a list of all the options & create all combos of the options
    for opt in obj.option_group.select_related().all():
        for value in opt.option_set.all():
            if ids_only:
                sublist.append(value.unique_id)
            else:
                sublist.append(value)
        masterlist.append(sublist)
        sublist = []
    results = cross_list(masterlist)
    return results
Пример #4
0
def get_all_options(obj, ids_only=False):
    """
    Returns all possible combinations of options for this products OptionGroups as a List of Lists.
    Ex:
    For OptionGroups Color and Size with Options (Blue, Green) and (Large, Small) you'll get
    [['Blue', 'Small'], ['Blue', 'Large'], ['Green', 'Small'], ['Green', 'Large']]
    Note: the actual values will be instances of Option instead of strings
    """
    sublist = []
    masterlist = []
    #Create a list of all the options & create all combos of the options
    for opt in obj.option_group.select_related().all():
        for value in opt.option_set.all():
            if ids_only:
                sublist.append(value.unique_id)
            else:
                sublist.append(value)
        masterlist.append(sublist)
        sublist = []
    results = cross_list(masterlist)
    return results