diff --git a/.idea/Recipies.iml b/.idea/Recipies.iml index 3ce50c0ad..9a80dc366 100644 --- a/.idea/Recipies.iml +++ b/.idea/Recipies.iml @@ -22,6 +22,9 @@ + + + diff --git a/.idea/jsLibraryMappings.xml b/.idea/jsLibraryMappings.xml index bac7af21b..2a5d32266 100644 --- a/.idea/jsLibraryMappings.xml +++ b/.idea/jsLibraryMappings.xml @@ -1,6 +1,6 @@ - + \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml index a65464d3b..3d4fa4013 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,8 +2,16 @@ + + + + + + + + @@ -49,8 +57,8 @@ - - + + @@ -58,11 +66,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + @@ -82,16 +122,6 @@ - - - - - - - - - - @@ -122,14 +152,10 @@ - - - - @@ -137,6 +163,11 @@ + + + + + @@ -152,6 +183,25 @@ + + + + + + + + + Django + + + + + DjangoUnresolvedFilterInspection + + + + + @@ -184,6 +234,12 @@ + + + + + + @@ -201,7 +257,7 @@ - + @@ -268,9 +324,10 @@ + - + @@ -278,12 +335,11 @@ - + - @@ -296,12 +352,12 @@ - + + + - - @@ -422,6 +478,7 @@ + @@ -445,13 +502,6 @@ - - - - - - - @@ -496,30 +546,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - @@ -539,6 +565,7 @@ + @@ -546,6 +573,7 @@ + @@ -564,34 +592,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -602,13 +602,89 @@ - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/cookbook/forms.py b/cookbook/forms.py index 642dd4f4d..679484b19 100644 --- a/cookbook/forms.py +++ b/cookbook/forms.py @@ -1,3 +1,6 @@ +from crispy_forms.helper import FormHelper +from crispy_forms.layout import Submit +from django.utils.translation import gettext as _ from django import forms from .models import * @@ -8,13 +11,14 @@ class RecipeForm(forms.ModelForm): fields = ('name', 'category', 'keywords') labels = { - 'name': 'Name', - 'category': 'Kategorie', - 'keywords': 'Tags', + 'name': _('Name'), + 'category': _('Category'), + 'keywords': _('Keywords'), + } help_texts = { - 'keywords': 'Strg+Click für Mehrfachauswahl', + 'keywords': _('Ctrl+Click to select multiple keywords'), } def __init__(self, *args, **kwargs): @@ -30,14 +34,15 @@ class CategoryForm(forms.ModelForm): fields = ('name', 'description') labels = { - 'name': 'Name', - 'description': 'Beschreibung', + 'name': _('Name'), + 'description': _('Description'), } def __init__(self, *args, **kwargs): super(CategoryForm, self).__init__(*args, **kwargs) - self.fields['name'].widget.attrs.update({'class': 'form-control'}) - self.fields['description'].widget.attrs.update({'class': 'form-control'}) + self.helper = FormHelper() + self.helper.form_method = 'post' + self.helper.add_input(Submit('save', _('Save'), css_class='btn-primary')) class KeywordForm(forms.ModelForm): @@ -46,13 +51,23 @@ class KeywordForm(forms.ModelForm): fields = ('name', 'description') labels = { - 'name': 'Name', - 'description': 'Beschreibung', + 'name': _('Name'), + 'description': _('Description'), } def __init__(self, *args, **kwargs): super(KeywordForm, self).__init__(*args, **kwargs) - self.fields['name'].widget.attrs.update({'class': 'form-control'}) - self.fields['description'].widget.attrs.update({'class': 'form-control'}) + self.helper = FormHelper() + self.helper.form_method = 'post' + self.helper.add_input(Submit('save', _('Save'), css_class='btn-primary')) +class EditCategoryForm(forms.ModelForm): + class Meta: + model = Keyword + fields = ('name', 'description') + + labels = { + 'name': _('Name'), + 'description': _('Description'), + } diff --git a/cookbook/migrations/0002_auto_20180201_1457.py b/cookbook/migrations/0002_auto_20180201_1457.py new file mode 100644 index 000000000..3c2ce6b87 --- /dev/null +++ b/cookbook/migrations/0002_auto_20180201_1457.py @@ -0,0 +1,23 @@ +# Generated by Django 2.0.1 on 2018-02-01 13:57 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('cookbook', '0001_initial'), + ] + + operations = [ + migrations.AlterField( + model_name='category', + name='description', + field=models.TextField(blank=True, default=''), + ), + migrations.AlterField( + model_name='keyword', + name='description', + field=models.TextField(blank=True, default=''), + ), + ] diff --git a/cookbook/models.py b/cookbook/models.py index a8643468f..e8c4814e9 100644 --- a/cookbook/models.py +++ b/cookbook/models.py @@ -3,7 +3,7 @@ from django.db import models class Keyword(models.Model): name = models.CharField(max_length=64) - description = models.TextField(default="") + 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) @@ -14,7 +14,7 @@ class Keyword(models.Model): class Category(models.Model): name = models.CharField(max_length=64) - description = models.TextField(default="") + 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) diff --git a/cookbook/templates/base.html b/cookbook/templates/base.html index 11c458aaf..dbd192191 100644 --- a/cookbook/templates/base.html +++ b/cookbook/templates/base.html @@ -1,4 +1,5 @@ {% load staticfiles %} +{% load i18n %} @@ -19,7 +20,7 @@ - Kochbuch + @@ -27,16 +28,16 @@ - Rezepte (current) + {% trans 'Cookbook' %}(current) - Neues Rezept + {% trans 'New Recipe' %} - Neue Kategorie + {% trans 'New Category' %} - Neues Tag + {% trans 'New Keyword' %} diff --git a/cookbook/templates/index.html b/cookbook/templates/index.html index 1dd41718b..325fae391 100644 --- a/cookbook/templates/index.html +++ b/cookbook/templates/index.html @@ -13,15 +13,14 @@ - {% crispy filter.form %} - + {{ filter.form|crispy }} + {% endif %} - {% if recipes %} {% render_table recipes %} {% else %} diff --git a/cookbook/templates/new_category.html b/cookbook/templates/new_category.html index b85335724..e11b36425 100644 --- a/cookbook/templates/new_category.html +++ b/cookbook/templates/new_category.html @@ -1,17 +1,18 @@ {% extends "base.html" %} +{% load crispy_forms_tags %} +{% load i18n %} -{% block title %}Neue Kategorie{% endblock %} +{% block title %}{% trans 'New Category' %}{% endblock %} {% block content %} - Neue Kategorie - Neue Kategorie für ein Rezept + {% trans 'New Category' %} + {% trans 'New recipe Category' %} {% csrf_token %} - {{ form.as_p }} - Save + {% crispy form %} {% endblock %} \ No newline at end of file diff --git a/cookbook/templates/new_keyword.html b/cookbook/templates/new_keyword.html index d491e236b..73a2c1f22 100644 --- a/cookbook/templates/new_keyword.html +++ b/cookbook/templates/new_keyword.html @@ -1,9 +1,18 @@ {% extends "base.html" %} +{% load crispy_forms_tags %} +{% load i18n %} + +{% block title %}{% trans 'New Keyword' %}{% endblock %} {% block content %} + + + {% trans 'New Keyword' %} + {% trans 'New recipe Keyword' %} + + {% csrf_token %} - {{ form.as_p }} - Save - + {% crispy form %} + {% endblock %} \ No newline at end of file diff --git a/db.sqlite3 b/db.sqlite3 index 3b4e759e5..5369eba29 100644 Binary files a/db.sqlite3 and b/db.sqlite3 differ