diff --git a/cookbook/admin.py b/cookbook/admin.py index c39d4e86..f4f70e8f 100644 --- a/cookbook/admin.py +++ b/cookbook/admin.py @@ -4,7 +4,6 @@ from .models import * admin.site.register(Recipe) admin.site.register(Keyword) -admin.site.register(Category) admin.site.register(Sync) admin.site.register(SyncLog) diff --git a/cookbook/filters.py b/cookbook/filters.py index d5d84d87..e7eeb5c9 100644 --- a/cookbook/filters.py +++ b/cookbook/filters.py @@ -19,15 +19,14 @@ class RecipeFilter(django_filters.FilterSet): class Meta: model = Recipe - fields = ['name', 'category', 'keywords'] + fields = ['name', 'keywords'] class QuickRecipeFilter(django_filters.FilterSet): name = django_filters.CharFilter(lookup_expr='contains') - category = django_filters.CharFilter(lookup_expr='contains') keywords = django_filters.ModelMultipleChoiceFilter(queryset=Keyword.objects.all(), widget=MultiSelectWidget, method='filter_keywords') class Meta: model = Recipe - fields = ['name', 'category', 'keywords'] + fields = ['name', 'keywords'] diff --git a/cookbook/forms.py b/cookbook/forms.py index 717f47b1..21b0c9ea 100644 --- a/cookbook/forms.py +++ b/cookbook/forms.py @@ -18,11 +18,10 @@ class EmojiWidget(forms.TextInput): class EditRecipeForm(forms.ModelForm): class Meta: model = Recipe - fields = ('name', 'category', 'keywords', 'file_path', 'storage', 'file_uid') + fields = ('name', 'keywords', 'file_path', 'storage', 'file_uid') labels = { 'name': _('Name'), - 'category': _('Category'), 'keywords': _('Keywords'), 'file_path': _('Path'), 'file_uid': _('Storage UID'), @@ -30,13 +29,6 @@ class EditRecipeForm(forms.ModelForm): widgets = {'keywords': MultiSelectWidget} -class CategoryForm(forms.ModelForm): - class Meta: - model = Category - fields = ('name', 'icon', 'description') - widgets = {'icon': EmojiWidget} - - class KeywordForm(forms.ModelForm): class Meta: model = Keyword @@ -64,7 +56,6 @@ class SyncForm(forms.ModelForm): class BatchEditForm(forms.Form): search = forms.CharField(label=_('Search String')) - category = forms.ModelChoiceField(queryset=Category.objects.all().order_by('id'), required=False) keywords = forms.ModelMultipleChoiceField(queryset=Keyword.objects.all().order_by('id'), required=False, widget=MultiSelectWidget) @@ -72,11 +63,10 @@ class BatchEditForm(forms.Form): class ImportRecipeForm(forms.ModelForm): class Meta: model = Recipe - fields = ('name', 'category', 'keywords', 'file_path', 'file_uid') + fields = ('name', 'keywords', 'file_path', 'file_uid') labels = { 'name': _('Name'), - 'category': _('Category'), 'keywords': _('Keywords'), 'file_path': _('Path'), 'file_uid': _('File ID'), diff --git a/cookbook/models.py b/cookbook/models.py index 1f6fbc62..f6967932 100644 --- a/cookbook/models.py +++ b/cookbook/models.py @@ -46,25 +46,12 @@ class Keyword(models.Model): return "{0} {1}".format(self.icon, self.name) -class Category(models.Model): - name = models.CharField(max_length=64, unique=True) - icon = models.CharField(max_length=1, blank=True, null=True) - description = models.TextField(default="", blank=True) - created_by = models.IntegerField(default=0) - created_at = models.DateTimeField(auto_now_add=True) - updated_at = models.DateTimeField(auto_now=True) - - def __str__(self): - return "{0} {1}".format(self.icon, self.name) - - class Recipe(models.Model): name = models.CharField(max_length=128) storage = models.ForeignKey(Storage, on_delete=models.PROTECT) file_uid = models.CharField(max_length=256, default="") file_path = models.CharField(max_length=512, default="") link = models.CharField(max_length=512, default="") - category = models.ForeignKey(Category, blank=True, on_delete=models.SET_NULL, null=True) keywords = models.ManyToManyField(Keyword, blank=True) created_by = models.IntegerField(default=0) created_at = models.DateTimeField(auto_now_add=True) diff --git a/cookbook/tables.py b/cookbook/tables.py index 483bec1b..aba98fec 100644 --- a/cookbook/tables.py +++ b/cookbook/tables.py @@ -10,24 +10,13 @@ class RecipeTable(tables.Table): id = tables.LinkColumn('edit_recipe', args=[A('id')]) name = tables.TemplateColumn( "{{record.name}}") - category = tables.Column( - attrs={'td': {'class': 'd-none d-lg-table-cell'}, 'th': {'class': 'd-none d-lg-table-cell'}}) all_tags = tables.Column( attrs={'td': {'class': 'd-none d-lg-table-cell'}, 'th': {'class': 'd-none d-lg-table-cell'}}) class Meta: model = Recipe template_name = 'generic/table_template.html' - fields = ('id', 'name', 'category', 'all_tags') - - -class CategoryTable(tables.Table): - id = tables.LinkColumn('edit_category', args=[A('id')]) - - class Meta: - model = Category - template_name = 'generic/table_template.html' - fields = ('id', 'icon', 'name') + fields = ('id', 'name', 'all_tags') class KeywordTable(tables.Table): diff --git a/cookbook/templates/base.html b/cookbook/templates/base.html index be184eb9..595d9090 100644 --- a/cookbook/templates/base.html +++ b/cookbook/templates/base.html @@ -61,8 +61,6 @@