visual improvements

This commit is contained in:
vabene1111 2018-05-15 22:58:29 +02:00
parent b92c6dd88f
commit 0acecba367
8 changed files with 49 additions and 21 deletions

View File

@ -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'))

View File

@ -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):

View File

@ -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('<span class="badge badge-success">%s</span>' % value)
else:
return format_html('<span class="badge badge-error">%s</span>' % 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("<a href='{% url 'delete_monitor' record.id %}' >" + _('Delete') + "</a>")
@staticmethod
def render_path(value):
return format_html('<code>%s</code>' % value)
class Meta:
model = Sync
template_name = 'generic/table_template.html'

View File

@ -9,12 +9,26 @@
<h3>
{% trans 'Batch edit Recipes' %}
<small class="text-muted">{% trans 'Add the specified category and keywords to all recipes containing a word' %}</small>
</h3>
<form method="POST" class="post-form">{% csrf_token %}
<div class="card border-info" >
<div class="card-body text-info">
<p class="card-text">{% trans 'Add the specified category and keywords to all recipes containing a word' %}</p>
</div>
</div>
<form method="POST" class="post-form">
{% csrf_token %}
{{ form|crispy }}
<input type="submit" value="Submit" class="btn btn-success">
</form>
<script>
//TODO clean this up
//converts multiselct in recipe edit to searchable multiselect
//shitty solution that needs to be redone at some point
$(document).ready(function () {
$('#id_keyword').select2();
});
</script>
{% endblock %}

View File

@ -8,16 +8,24 @@
{% block content %}
<h3>{% trans 'Manage watched Folders' %}</h3>
<div class="card border-info">
<div class="card-body text-info">
<p class="card-text">
{% trans 'On this Page you can manage all DropBox folder locations that should be monitored and synced' %}
<br/>
{% trans 'The path must be in the following format' %} <code>/Folder/RecipesFolder</code>
</p>
<form method="POST" class="post-form">{% csrf_token %}
{{ form|crispy }}
<input type="submit" value="Submit" class="btn btn-success">
</form>
</div>
</div>
{% trans 'On this Page you can manage all DropBox folder locations that should be monitored and synced' %} <br/>
{% trans 'The path must be in the following format' %} <code>/Folder/RecipesFolder</code>
<br/>
<a href="{% url 'api_dropbox_sync' %}" class="btn btn-success">{% trans 'Sync Now!' %}</a>
<br/>
<form method="POST" class="post-form">{% csrf_token %}
{{ form|crispy }}
<input type="submit" value="Submit" class="btn btn-success">
</form>
<a href="{% url 'api_dropbox_sync' %}" class="btn btn-warning">{% trans 'Sync Now!' %}</a>
<br/><br/>
{% render_table monitored_paths %}

View File

@ -16,6 +16,7 @@
<script>
//TODO clean this up
//converts multiselct in recipe edit to searchable multiselect
//shitty solution that needs to be redone at some point
$(document).ready(function () {

View File

@ -17,6 +17,7 @@
<script>
//TODO clean this up
//converts multiselct in recipe edit to searchable multiselect
//shitty solution that needs to be redone at some point
$(document).ready(function () {

View File

@ -31,7 +31,7 @@ urlpatterns = [
path('delete/import/<int:pk>/', edit.ImportDelete.as_view(), name='delete_import'),
path('batch/monitor', batch.batch_monitor, name='batch_monitor'),
path('batch/category', batch.batch_edit, name='batch_edit'),
path('batch/edit', batch.batch_edit, name='batch_edit'),
path('batch/import/all', batch.batch_import_all, name='batch_import_all'),
path('api/get_file_link/<int:recipe_id>/', api.get_file_link, name='api_get_file_link'),