diff --git a/amadeus/static/css/base/amadeus.css b/amadeus/static/css/base/amadeus.css index ee59cc8..4862770 100755 --- a/amadeus/static/css/base/amadeus.css +++ b/amadeus/static/css/base/amadeus.css @@ -126,6 +126,19 @@ margin-bottom: 15px; } +.ms-container { + width: 100% !important; +} + +#coordinators_accordion .panel-heading { + background: #FFFFFF; + border: none; +} + +#coordinators_accordion .panel-collapse { + padding: 10px; +} + /* category app ends */ .clearfix{ diff --git a/amadeus/static/img/switch.png b/amadeus/static/img/switch.png new file mode 100644 index 0000000..784b0c7 Binary files /dev/null and b/amadeus/static/img/switch.png differ diff --git a/categories/templates/categories/_form.html b/categories/templates/categories/_form.html new file mode 100644 index 0000000..fa24560 --- /dev/null +++ b/categories/templates/categories/_form.html @@ -0,0 +1,118 @@ +{% load widget_tweaks static i18n switchevenodd %} + +
+ {% csrf_token %} + {% for field in form %} + {% if field.auto_id == 'id_coordinators' %} +
+
+ +
+

{% trans 'Atribute coordinators role to users' %}:

+ {% render_field field class='form-control' %} +
+
+
+ {% else %} +
+ {% if field.auto_id != 'id_visible' %} + + {% endif %} + {% if 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 %} +
+ {% endif %} + {% endfor %} +
+ +
+
+ + \ No newline at end of file diff --git a/categories/templates/categories/create.html b/categories/templates/categories/create.html index 20e5012..5b7fae3 100644 --- a/categories/templates/categories/create.html +++ b/categories/templates/categories/create.html @@ -1,116 +1,18 @@ -{% extends 'categories/home.html' %} +{% extends 'categories/list.html' %} {% load widget_tweaks static i18n permission_tags django_bootstrap_breadcrumbs switchevenodd %} {% block breadcrumbs %} - {{ block.super }} - {% breadcrumb 'Create Category' 'categories:create' %} + {{ block.super }} + {% breadcrumb 'Create Category' 'categories:create' %} {% 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' %} - - - {% comment %} - - {% endcomment %} - {% elif field.auto_id == 'id_coordinators' %} - - - {% 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 a609453..e89b83e 100644 --- a/categories/views.py +++ b/categories/views.py @@ -32,7 +32,6 @@ class IndexView(views.SuperuserRequiredMixin, LoginRequiredMixin, ListView): template_name = 'categories/list.html' context_object_name = 'categories' - def get_queryset(self): result = super(IndexView, self).get_queryset() @@ -77,8 +76,6 @@ class CreateCategory(views.SuperuserRequiredMixin, HasRoleMixin, LogMixin, Creat template_name = 'categories/create.html' success_url = reverse_lazy('categories:index') - - def get_initial(self): initial = super(CreateCategory, self).get_initial() @@ -89,19 +86,25 @@ class CreateCategory(views.SuperuserRequiredMixin, HasRoleMixin, LogMixin, Creat initial['description'] = category.description initial['name'] = category.name initial['visible'] = category.visible - self.log_action = 'replicate' self.log_context['replicated_category_id'] = category.id self.log_context['replicated_category_name'] = category.name self.log_context['replicated_category_slug'] = category.slug + return initial def get_context_data(self, **kwargs): context = super(CreateCategory, self).get_context_data(**kwargs) context['users_count'] = User.objects.all().count() context['switch'] = True + + if self.kwargs.get('slug'): + context['title'] = _('Replicate Category') + else: + context['title'] = _('Create Category') + return context @@ -145,7 +148,6 @@ class DeleteCategory(LogMixin, DeleteView): model = Category template_name = 'categories/delete.html' - def delete(self, request, *args, **kwargs): category = get_object_or_404(Category, slug = self.kwargs.get('slug')) subjects = Subject.objects.filter(category = category) @@ -181,7 +183,6 @@ class UpdateCategory(LogMixin, UpdateView): login_url = reverse_lazy("users:login") redirect_field_name = 'next' - def get_success_url(self): self.log_context['category_id'] = self.object.id self.log_context['category_name'] = self.object.name @@ -191,8 +192,15 @@ class UpdateCategory(LogMixin, UpdateView): objeto = self.object.name messages.success(self.request, _('Category "%s" updated successfully!')%(objeto)) + return reverse_lazy('categories:index') + def get_context_data(self, **kwargs): + context = super(UpdateCategory, self).get_context_data(**kwargs) + context['title'] = _('Update Category') + + return context + @log_decorator_ajax('category', 'view', 'category') def category_view_log(request, category): action = request.GET.get('action') -- libgit2 0.21.2