diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 00000000..a55e7a17 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/cookbook/forms.py b/cookbook/forms.py index f65696e6..16eb1307 100644 --- a/cookbook/forms.py +++ b/cookbook/forms.py @@ -1,3 +1,4 @@ +from dal import autocomplete from django import forms from django.forms import widgets from django.utils.translation import gettext as _ @@ -60,6 +61,13 @@ class InternalRecipeForm(forms.ModelForm): widgets = {'keywords': MultiSelectWidget} +class RecipeForm(forms.Form): + recipe = forms.ModelMultipleChoiceField( + queryset=Recipe.objects.all(), + widget=MultiSelectWidget + ) + + class CommentForm(forms.ModelForm): prefix = 'comment' diff --git a/cookbook/models.py b/cookbook/models.py index 459f1049..180d32e5 100644 --- a/cookbook/models.py +++ b/cookbook/models.py @@ -81,6 +81,9 @@ class RecipeIngredients(models.Model): unit = models.CharField(max_length=128) amount = models.DecimalField(default=0, decimal_places=2, max_digits=16) + def __str__(self): + return str(self.amount) + ' ' + self.unit + ' ' + self.name + class Comment(models.Model): recipe = models.ForeignKey(Recipe, on_delete=models.CASCADE) @@ -89,6 +92,9 @@ class Comment(models.Model): created_at = models.DateTimeField(auto_now_add=True) updated_at = models.DateTimeField(auto_now=True) + def __str__(self): + return self.text + class RecipeImport(models.Model): name = models.CharField(max_length=128) diff --git a/cookbook/templates/base.html b/cookbook/templates/base.html index 776477c3..22f46924 100644 --- a/cookbook/templates/base.html +++ b/cookbook/templates/base.html @@ -73,10 +73,12 @@ class="sr-only">(current)