diff --git a/cookbook/admin.py b/cookbook/admin.py index d2b5c31a..bed49ca8 100644 --- a/cookbook/admin.py +++ b/cookbook/admin.py @@ -60,7 +60,7 @@ admin.site.register(UserSpace, UserSpaceAdmin) class UserPreferenceAdmin(admin.ModelAdmin): - list_display = ('name', 'theme', 'nav_color', 'default_page',) + list_display = ('name', 'theme', 'nav_color', 'default_page') search_fields = ('user__username',) list_filter = ('theme', 'nav_color', 'default_page',) date_hierarchy = 'created_at' @@ -75,7 +75,7 @@ admin.site.register(UserPreference, UserPreferenceAdmin) class SearchPreferenceAdmin(admin.ModelAdmin): - list_display = ('name', 'search', 'trigram_threshold',) + list_display = ('name', 'search', 'trigram_threshold', ) search_fields = ('user__username',) list_filter = ('search',) @@ -108,11 +108,16 @@ class SupermarketCategoryInline(admin.TabularInline): class SupermarketAdmin(admin.ModelAdmin): + list_display = ('name', 'space',) inlines = (SupermarketCategoryInline,) +class SupermarketCategoryAdmin(admin.ModelAdmin): + list_display = ('name', 'space',) + + admin.site.register(Supermarket, SupermarketAdmin) -admin.site.register(SupermarketCategory) +admin.site.register(SupermarketCategory, SupermarketCategoryAdmin) class SyncLogAdmin(admin.ModelAdmin): @@ -163,10 +168,18 @@ def delete_unattached_steps(modeladmin, request, queryset): class StepAdmin(admin.ModelAdmin): - list_display = ('name', 'order',) - search_fields = ('name',) + list_display = ('recipe_and_name', 'order', 'space') + ordering = ('recipe__name', 'name', 'space', ) + search_fields = ('name', 'recipe__name') actions = [delete_unattached_steps] + @staticmethod + @admin.display(description="Name") + def recipe_and_name(obj): + if not obj.recipe_set.exists(): + return f"Orphaned Step{'':s if not obj.name else f': {obj.name}'}" + return f"{obj.recipe_set.first().name}: {obj.name}" if obj.name else obj.recipe_set.first().name + admin.site.register(Step, StepAdmin) @@ -183,8 +196,9 @@ def rebuild_index(modeladmin, request, queryset): class RecipeAdmin(admin.ModelAdmin): - list_display = ('name', 'internal', 'created_by', 'storage') + list_display = ('name', 'internal', 'created_by', 'storage', 'space') search_fields = ('name', 'created_by__username') + ordering = ('name', 'created_by__username', ) list_filter = ('internal',) date_hierarchy = 'created_at' @@ -198,7 +212,14 @@ class RecipeAdmin(admin.ModelAdmin): admin.site.register(Recipe, RecipeAdmin) -admin.site.register(Unit) + +class UnitAdmin(admin.ModelAdmin): + list_display = ('name', 'space') + ordering = ('name', 'space', ) + search_fields = ('name',) + + +admin.site.register(Unit, UnitAdmin) # admin.site.register(FoodInheritField) @@ -229,10 +250,16 @@ def delete_unattached_ingredients(modeladmin, request, queryset): class IngredientAdmin(admin.ModelAdmin): - list_display = ('food', 'amount', 'unit') - search_fields = ('food__name', 'unit__name') + list_display = ('recipe_name', 'amount', 'unit', 'food', 'space') + search_fields = ('food__name', 'unit__name', 'step__recipe__name') actions = [delete_unattached_ingredients] + @staticmethod + @admin.display(description="Recipe") + def recipe_name(obj): + recipes = obj.step_set.first().recipe_set.all() if obj.step_set.exists() else None + return recipes.first().name if recipes else 'Orphaned Ingredient' + admin.site.register(Ingredient, IngredientAdmin) @@ -258,7 +285,7 @@ admin.site.register(RecipeImport, RecipeImportAdmin) class RecipeBookAdmin(admin.ModelAdmin): - list_display = ('name', 'user_name') + list_display = ('name', 'user_name', 'space') search_fields = ('name', 'created_by__username') @staticmethod @@ -334,11 +361,11 @@ class ShoppingListEntryAdmin(admin.ModelAdmin): admin.site.register(ShoppingListEntry, ShoppingListEntryAdmin) -class ShoppingListAdmin(admin.ModelAdmin): - list_display = ('id', 'created_by', 'created_at') +# class ShoppingListAdmin(admin.ModelAdmin): +# list_display = ('id', 'created_by', 'created_at') -admin.site.register(ShoppingList, ShoppingListAdmin) +# admin.site.register(ShoppingList, ShoppingListAdmin) class ShareLinkAdmin(admin.ModelAdmin): diff --git a/cookbook/models.py b/cookbook/models.py index c40bb41f..b7c3e3c8 100644 --- a/cookbook/models.py +++ b/cookbook/models.py @@ -718,6 +718,9 @@ class Ingredient(ExportModelOperationsMixin('ingredient'), models.Model, Permiss space = models.ForeignKey(Space, on_delete=models.CASCADE) objects = ScopedManager(space='space') + def __str__(self): + return f'{self.pk}: {self.amount} {self.food.name} {self.unit.name}' + class Meta: ordering = ['order', 'pk'] indexes = ( @@ -745,7 +748,9 @@ class Step(ExportModelOperationsMixin('step'), models.Model, PermissionModelMixi return render_instructions(self) def __str__(self): - return f'{self.pk} {self.name}' + if not self.recipe_set.exists(): + return f"{self.pk}: {_('Orphaned Step')}" + return f"{self.pk}: {self.name}" if self.name else f"Step: {self.pk}" class Meta: ordering = ['order', 'pk'] diff --git a/docs/install/truenas_portainer.md b/docs/install/truenas_portainer.md index 057125d5..7be57bf2 100644 --- a/docs/install/truenas_portainer.md +++ b/docs/install/truenas_portainer.md @@ -71,7 +71,7 @@ Basic guide to setup Docker and Portainer TrueNAS Core. -Select "Get Started" to use the Enviroment Portainer is running in ![Screenshot of Enviroment Wizard](https://2914113074-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiZWHJxqQsgWYd9sI88sO%2Fuploads%2Fsig45vFliINvOKGKVStk%2F2.15-install-server-setup-wizard.png?alt=media&token=cd21d9e8-0632-40db-af9a-581365f98209) -### 3. Install Tandoor Recipies VIA Portainer Web Editor +### 3. Install Tandoor Recipes VIA Portainer Web Editor -From the menu select Stacks, click Add stack, give the stack a descriptive name then select Web editor. ![Screenshot of Stack List](https://2914113074-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiZWHJxqQsgWYd9sI88sO%2Fuploads%2FnBx62EIPhmUy1L0S1iKI%2F2.15-docker_add_stack_web_editor.gif?alt=media&token=c45c0151-9c15-4d79-b229-1a90a7a86b84) -Use the below code and input it into the Web Editor: @@ -88,8 +88,7 @@ services: - stack.env web_recipes: - #image: vabene1111/recipes:latest - image: vabene1111/recipes:beta + image: vabene1111/recipes:latest env_file: - stack.env volumes: diff --git a/vue/src/apps/RecipeEditView/RecipeEditView.vue b/vue/src/apps/RecipeEditView/RecipeEditView.vue index 2649c037..7fd5dbe7 100644 --- a/vue/src/apps/RecipeEditView/RecipeEditView.vue +++ b/vue/src/apps/RecipeEditView/RecipeEditView.vue @@ -506,7 +506,6 @@