コード例 #1
0
 def __init__(self, *args, **kwargs):
     super().__init__(*args, **kwargs)
     full_activity_list = Activity.list_of_activity_objects()
     self.ingredients.choices = [
         (str(single['id']), single['name'])
         for single in Activity.find_activities_by_x_category(
             'białka mleka', 'cukier', 'laktoza', 'inne')
     ]
     # Meal.json_meal()
     self.meat_ingredients.choices = choices_by_category('wysoko białkowe')
     self.carbs_ingredients.choices = choices_by_category(
         'wysoko weglowodanowe', 'bezglutenowe', 'gluten')
     self.warzywa_ingredients.choices = choices_by_category(
         'warzywa', 'owoce')
コード例 #2
0
def choices_by_category(*category):
    full_activity_list = Activity.list_of_activity_objects()
    return [(str(single.id), single.name) for single in full_activity_list
            if Category.find_by_id(single.category_id).category in [*category]]