Commit 1b4f8e9ce8dd948574f49c163754b4e78c70db67
1 parent
5d731a29
Exists in
master
and in
3 other branches
Adjusting category deletion
Showing
5 changed files
with
22 additions
and
10 deletions
Show diff stats
amadeus/static/css/base/amadeus.css
categories/templates/categories/list.html
... | ... | @@ -16,7 +16,11 @@ |
16 | 16 | {% if messages %} |
17 | 17 | {% for message in messages %} |
18 | 18 | <script type="text/javascript"> |
19 | - alertify.success('{{message}}'); | |
19 | + {% if message.tags == "danger" %} | |
20 | + alertify.error('{{message}}'); | |
21 | + {% else %} | |
22 | + alertify.success('{{message}}'); | |
23 | + {% endif %} | |
20 | 24 | </script> |
21 | 25 | {% endfor %} |
22 | 26 | {% endif %} | ... | ... |
categories/views.py
1 | -from django.shortcuts import render, get_object_or_404 | |
1 | +from django.shortcuts import render, get_object_or_404, redirect | |
2 | 2 | from django.views.generic import ListView, CreateView, DeleteView, UpdateView |
3 | 3 | from .models import Category |
4 | 4 | from django.core.urlresolvers import reverse_lazy |
... | ... | @@ -139,17 +139,20 @@ class DeleteCategory(LogMixin, DeleteView): |
139 | 139 | |
140 | 140 | login_url = reverse_lazy("users:login") |
141 | 141 | redirect_field_name = 'next' |
142 | + | |
142 | 143 | model = Category |
143 | 144 | template_name = 'categories/delete.html' |
144 | 145 | |
145 | 146 | def delete(self, request, *args, **kwargs): |
146 | 147 | category = get_object_or_404(Category, slug = self.kwargs.get('slug')) |
147 | 148 | subjects = Subject.objects.filter(category = category) |
149 | + | |
150 | + print(self.request.META.get('HTTP_REFERER')) | |
148 | 151 | |
149 | 152 | if subjects.count() > 0: |
150 | - #objeto = category | |
151 | - #messages.success(self.request, _('cannot delete Category "%s" ')%(objeto)) | |
152 | - return reverse_lazy('categories:index') | |
153 | + messages.error(self.request, _('The category cannot be removed, it contains one or more virtual enviroments attach.')) | |
154 | + | |
155 | + return redirect(self.request.META.get('HTTP_REFERER')) | |
153 | 156 | |
154 | 157 | return super(DeleteCategory, self).delete(self, request, *args, **kwargs) |
155 | 158 | |
... | ... | @@ -161,8 +164,8 @@ class DeleteCategory(LogMixin, DeleteView): |
161 | 164 | super(DeleteCategory, self).createLog(self.request.user, self.log_component, self.log_action, self.log_resource, self.log_context) |
162 | 165 | |
163 | 166 | messages.success(self.request, _('Category removed successfully!')) |
164 | - return reverse_lazy('categories:index') | |
165 | 167 | |
168 | + return self.request.META.get('HTTP_REFERER') | |
166 | 169 | |
167 | 170 | class UpdateCategory(LogMixin, UpdateView): |
168 | 171 | log_component = 'category' | ... | ... |
subjects/templates/subjects/list.html
... | ... | @@ -20,10 +20,15 @@ |
20 | 20 | {% if messages %} |
21 | 21 | {% for message in messages %} |
22 | 22 | <script type="text/javascript"> |
23 | - alertify.success('{{message}}'); | |
23 | + {% if message.tags == "danger" %} | |
24 | + alertify.error('{{message}}'); | |
25 | + {% else %} | |
26 | + alertify.success('{{message}}'); | |
27 | + {% endif %} | |
24 | 28 | </script> |
25 | 29 | {% endfor %} |
26 | - {% endif %} | |
30 | + {% endif %} | |
31 | + | |
27 | 32 | <div id="core-subjects-options-div"> |
28 | 33 | <ul class="core-subjects-options"> |
29 | 34 | {% if all %} | ... | ... |
users/views.py