From 0acecba36769b68ecba1f48826ceb65f00a56f8c Mon Sep 17 00:00:00 2001 From: vabene1111 Date: Tue, 15 May 2018 22:58:29 +0200 Subject: [PATCH] visual improvements --- cookbook/forms.py | 8 ------- cookbook/models.py | 4 ++-- cookbook/tables.py | 12 ++++++++++ cookbook/templates/batch/edit.html | 18 ++++++++++++-- cookbook/templates/batch/monitor.html | 24 ++++++++++++------- cookbook/templates/generic/edit_template.html | 1 + cookbook/templates/generic/new_template.html | 1 + cookbook/urls.py | 2 +- 8 files changed, 49 insertions(+), 21 deletions(-) diff --git a/cookbook/forms.py b/cookbook/forms.py index cd781604..ee7a1c5b 100644 --- a/cookbook/forms.py +++ b/cookbook/forms.py @@ -1,5 +1,3 @@ -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 * @@ -17,12 +15,6 @@ class EditRecipeForm(forms.ModelForm): 'path': _('Path'), } - def __init__(self, *args, **kwargs): - super(EditRecipeForm, self).__init__(*args, **kwargs) - self.helper = FormHelper() - self.helper.form_method = 'post' - self.helper.add_input(Submit('save', _('Save'), css_class='btn-primary')) - class MonitorForm(forms.Form): path = forms.CharField(label=_('Path')) diff --git a/cookbook/models.py b/cookbook/models.py index 05aa42df..26b91489 100644 --- a/cookbook/models.py +++ b/cookbook/models.py @@ -10,7 +10,7 @@ class Keyword(models.Model): updated_at = models.DateTimeField(auto_now=True) def __str__(self): - return self.name + return "{0} {1}".format(self.icon, self.name) class Category(models.Model): @@ -22,7 +22,7 @@ class Category(models.Model): updated_at = models.DateTimeField(auto_now=True) def __str__(self): - return self.name + return "{0} {1}".format(self.icon, self.name) class Recipe(models.Model): diff --git a/cookbook/tables.py b/cookbook/tables.py index e07a1bee..9dface13 100644 --- a/cookbook/tables.py +++ b/cookbook/tables.py @@ -1,4 +1,5 @@ import django_tables2 as tables +from django.utils.html import format_html from django.utils.translation import gettext as _ from django_tables2.utils import A # alias for Accessor @@ -45,6 +46,13 @@ class KeywordTable(tables.Table): class ImportLogTable(tables.Table): monitor_id = tables.LinkColumn('edit_monitor', args=[A('monitor_id')]) + @staticmethod + def render_status(value): + if value == 'SUCCESS': + return format_html('%s' % value) + else: + return format_html('%s' % value) + class Meta: model = SyncLog template_name = 'generic/table_template.html' @@ -55,6 +63,10 @@ class MonitoredPathTable(tables.Table): id = tables.LinkColumn('edit_monitor', args=[A('id')]) delete = tables.TemplateColumn("" + _('Delete') + "") + @staticmethod + def render_path(value): + return format_html('%s' % value) + class Meta: model = Sync template_name = 'generic/table_template.html' diff --git a/cookbook/templates/batch/edit.html b/cookbook/templates/batch/edit.html index 348a4e06..f1a8099a 100644 --- a/cookbook/templates/batch/edit.html +++ b/cookbook/templates/batch/edit.html @@ -9,12 +9,26 @@

{% trans 'Batch edit Recipes' %} - {% trans 'Add the specified category and keywords to all recipes containing a word' %}

-
{% csrf_token %} +
+
+

{% trans 'Add the specified category and keywords to all recipes containing a word' %}

+
+
+ + + {% csrf_token %} {{ form|crispy }}
+ {% endblock %} \ No newline at end of file diff --git a/cookbook/templates/batch/monitor.html b/cookbook/templates/batch/monitor.html index 06cfc8f0..2937906f 100644 --- a/cookbook/templates/batch/monitor.html +++ b/cookbook/templates/batch/monitor.html @@ -8,16 +8,24 @@ {% block content %}

{% trans 'Manage watched Folders' %}

+
+
+

+ {% trans 'On this Page you can manage all DropBox folder locations that should be monitored and synced' %} +
+ {% trans 'The path must be in the following format' %} /Folder/RecipesFolder +

+
{% csrf_token %} + {{ form|crispy }} + +
+ +
+
- {% trans 'On this Page you can manage all DropBox folder locations that should be monitored and synced' %}
- {% trans 'The path must be in the following format' %} /Folder/RecipesFolder
- {% trans 'Sync Now!' %} -
-
{% csrf_token %} - {{ form|crispy }} - -
+ {% trans 'Sync Now!' %} +

{% render_table monitored_paths %} diff --git a/cookbook/templates/generic/edit_template.html b/cookbook/templates/generic/edit_template.html index 0ecdde84..7f84a0b0 100644 --- a/cookbook/templates/generic/edit_template.html +++ b/cookbook/templates/generic/edit_template.html @@ -16,6 +16,7 @@