From 5bce8d3391faf4ced140ba7e1e75852d62bc514c Mon Sep 17 00:00:00 2001 From: Zambom Date: Mon, 2 Jan 2017 19:33:14 -0200 Subject: [PATCH] Adjusting category crud --- categories/templates/categories/_form.html | 2 +- categories/templates/categories/update.html | 102 ++++++++++-------------------------------------------------------------------------------------------- categories/views.py | 14 ++------------ 3 files changed, 13 insertions(+), 105 deletions(-) diff --git a/categories/templates/categories/_form.html b/categories/templates/categories/_form.html index fa24560..513ed44 100644 --- a/categories/templates/categories/_form.html +++ b/categories/templates/categories/_form.html @@ -59,7 +59,7 @@ {% endif %} {% endfor %}
- +
diff --git a/categories/templates/categories/update.html b/categories/templates/categories/update.html index 1d6d157..a8b7d28 100644 --- a/categories/templates/categories/update.html +++ b/categories/templates/categories/update.html @@ -1,104 +1,22 @@ -{% extends 'categories/home.html' %} +{% extends 'categories/list.html' %} {% load static i18n %} {% load widget_tweaks django_bootstrap_breadcrumbs %} {% block breadcrumbs %} {{ block.super }} - {% breadcrumb 'Update' 'categories:update' category.slug %} + {% with 'Update '|add:category.slug as bread_slug %} + {% breadcrumb bread_slug 'categories:update' %} + {% endwith %} {% endblock %} {% block content %} -
-
-
-
- {% csrf_token %} - {% for field in form %} -
- {% if field.auto_id != 'id_visible' %} - - {% endif %} - {% if field.auto_id == 'id_init_register_date' or field.auto_id == 'id_end_register_date' or field.auto_id == 'id_init_date' or field.auto_id == 'id_end_date'%} - - {% elif field.auto_id == 'id_visible' %} -
- -
- {% elif field.auto_id == 'id_description' %} - {% render_field field class='form-control text_wysiwyg' %} - {% else %} - {% render_field field class='form-control' %} - {% endif %} - {{ field.help_text }} - {% if field.errors %} -
-
- -
- {% endif %} -
- {% endfor %} -
- -
-
+
+
+ {% include 'categories/_form.html' %} +
-
-
-
-
- {% endblock %} \ No newline at end of file diff --git a/categories/views.py b/categories/views.py index 9f0ffc8..6690ee3 100644 --- a/categories/views.py +++ b/categories/views.py @@ -86,6 +86,8 @@ class CreateCategory(views.SuperuserRequiredMixin, HasRoleMixin, LogMixin, Creat initial['description'] = category.description initial['name'] = category.name initial['visible'] = category.visible + initial['coordinators'] = category.coordinators.all() + print(category.coordinators.all()) self.log_action = 'replicate' @@ -107,18 +109,6 @@ class CreateCategory(views.SuperuserRequiredMixin, HasRoleMixin, LogMixin, Creat return context - - def get_form(self, form_class=None): - """ - Returns an instance of the form to be used in this view. - """ - #print(self.kwargs) - if form_class is None: - form_class = self.get_form_class() - - - return form_class(**self.get_form_kwargs()) - def form_valid(self, form): self.object = form.save() -- libgit2 0.21.2