Commit f7db7452c53f30f3276692ce72daf1e9d1033f9a
1 parent
bfb98dad
Exists in
master
and in
3 other branches
fixed some issues
Showing
8 changed files
with
53 additions
and
10 deletions
Show diff stats
amadeus/static/css/base/amadeus.css
@@ -59,12 +59,12 @@ | @@ -59,12 +59,12 @@ | ||
59 | } | 59 | } |
60 | 60 | ||
61 | #create-category{ | 61 | #create-category{ |
62 | - margin-left: 40%; | 62 | + margin-left: 20%; |
63 | margin-bottom: 1%; | 63 | margin-bottom: 1%; |
64 | border: none; | 64 | border: none; |
65 | background-color: #66BB6A; | 65 | background-color: #66BB6A; |
66 | color: #FFFFFF; | 66 | color: #FFFFFF; |
67 | - width: 200px; | 67 | + width: 60%; |
68 | height: 40px; | 68 | height: 40px; |
69 | font-size: 15px; | 69 | font-size: 15px; |
70 | } | 70 | } |
categories/forms.py
@@ -9,4 +9,4 @@ class CategoryForm(forms.ModelForm): | @@ -9,4 +9,4 @@ class CategoryForm(forms.ModelForm): | ||
9 | 'description': forms.Textarea, | 9 | 'description': forms.Textarea, |
10 | 'coordinators' : forms.SelectMultiple, | 10 | 'coordinators' : forms.SelectMultiple, |
11 | } | 11 | } |
12 | - | ||
13 | \ No newline at end of file | 12 | \ No newline at end of file |
13 | + | ||
14 | \ No newline at end of file | 14 | \ No newline at end of file |
categories/templates/categories/create.html
1 | {% extends 'categories/home.html' %} | 1 | {% extends 'categories/home.html' %} |
2 | 2 | ||
3 | -{% load widget_tweaks static i18n permission_tags django_bootstrap_breadcrumbs %} | 3 | +{% load widget_tweaks static i18n permission_tags django_bootstrap_breadcrumbs switchevenodd %} |
4 | 4 | ||
5 | {% block breadcrumbs %} | 5 | {% block breadcrumbs %} |
6 | {{ block.super }} | 6 | {{ block.super }} |
@@ -28,6 +28,24 @@ | @@ -28,6 +28,24 @@ | ||
28 | 28 | ||
29 | {% elif field.auto_id == 'id_description' %} | 29 | {% elif field.auto_id == 'id_description' %} |
30 | {% render_field field class='form-control text_wysiwyg' %} | 30 | {% render_field field class='form-control text_wysiwyg' %} |
31 | + | ||
32 | + | ||
33 | + {% comment %} | ||
34 | + | ||
35 | + {% endcomment %} | ||
36 | + {% elif field.auto_id == 'id_coordinators' %} | ||
37 | + <select id="{{field.auto_id}}" multiple="multiple" class="form-control" | ||
38 | + style="position: absolute; left: -9999px;" name="coordinators"> | ||
39 | + | ||
40 | + {% for value, name in form.fields.coordinators.choices %} | ||
41 | + | ||
42 | + <option value="{{value}}">{{name}}</option> | ||
43 | + | ||
44 | + | ||
45 | + | ||
46 | + {% endfor %} | ||
47 | + </select> | ||
48 | + | ||
31 | {% else %} | 49 | {% else %} |
32 | {% render_field field class='form-control' %} | 50 | {% render_field field class='form-control' %} |
33 | {% endif %} | 51 | {% endif %} |
categories/templates/categories/list.html
@@ -84,11 +84,12 @@ | @@ -84,11 +84,12 @@ | ||
84 | {{coordinator.username}} | 84 | {{coordinator.username}} |
85 | {% endfor %} | 85 | {% endfor %} |
86 | </h4> | 86 | </h4> |
87 | - {{category.description|safe}} | 87 | + |
88 | + </div> | ||
89 | + {{category.description|safe}} | ||
88 | {% if user in category.coordinators.all %} | 90 | {% if user in category.coordinators.all %} |
89 | <button class="create-subject-btn"> {% trans "create new subject" %} </button> | 91 | <button class="create-subject-btn"> {% trans "create new subject" %} </button> |
90 | {% endif %} | 92 | {% endif %} |
91 | - </div> | ||
92 | 93 | ||
93 | 94 | ||
94 | {% comment %} | 95 | {% comment %} |
categories/templates/categories/update.html
@@ -66,8 +66,8 @@ | @@ -66,8 +66,8 @@ | ||
66 | }); | 66 | }); |
67 | 67 | ||
68 | $('#id_coordinators').multiSelect({ | 68 | $('#id_coordinators').multiSelect({ |
69 | - selectableHeader: "<input type='text' class='search-input' autocomplete='off' placeholder='{% trans "try an username" %} '>", | ||
70 | - selectionHeader: "<input type='text' class='search-input' autocomplete='off' placeholder='{% trans "try an username" %} '>", | 69 | + selectableHeader: "<input type='text' class='search-input category-search-users' autocomplete='off' placeholder='{% trans "try an username" %} '>", |
70 | + selectionHeader: "<input type='text' class='search-input category-search-users' autocomplete='off' placeholder='{% trans "try an username" %} '>", | ||
71 | afterInit: function(ms){ | 71 | afterInit: function(ms){ |
72 | var that = this, | 72 | var that = this, |
73 | $selectableSearch = that.$selectableUl.prev(), | 73 | $selectableSearch = that.$selectableUl.prev(), |
@@ -0,0 +1,16 @@ | @@ -0,0 +1,16 @@ | ||
1 | +from django import template | ||
2 | + | ||
3 | +register = template.Library() | ||
4 | + | ||
5 | +class switchevenodd(template.Node): | ||
6 | + """docstring for switchevenodd""" | ||
7 | + def __init__(self, *args): | ||
8 | + if args: | ||
9 | + print(args) | ||
10 | + | ||
11 | + def render(self, context): | ||
12 | + | ||
13 | + context['switch'] = not context['switch'] | ||
14 | + return '' | ||
15 | + | ||
16 | +register.tag('switchevenodd', switchevenodd) | ||
0 | \ No newline at end of file | 17 | \ No newline at end of file |
categories/views.py
@@ -18,6 +18,8 @@ from subjects.models import Subject | @@ -18,6 +18,8 @@ from subjects.models import Subject | ||
18 | 18 | ||
19 | from log.mixins import LogMixin | 19 | from log.mixins import LogMixin |
20 | 20 | ||
21 | +from users.models import User | ||
22 | + | ||
21 | class IndexView(LoginRequiredMixin, ListView): | 23 | class IndexView(LoginRequiredMixin, ListView): |
22 | 24 | ||
23 | login_url = reverse_lazy("users:login") | 25 | login_url = reverse_lazy("users:login") |
@@ -72,6 +74,7 @@ class CreateCategory(views.SuperuserRequiredMixin, HasRoleMixin, LogMixin, Creat | @@ -72,6 +74,7 @@ class CreateCategory(views.SuperuserRequiredMixin, HasRoleMixin, LogMixin, Creat | ||
72 | success_url = reverse_lazy('categories:index') | 74 | success_url = reverse_lazy('categories:index') |
73 | 75 | ||
74 | 76 | ||
77 | + | ||
75 | def get_initial(self): | 78 | def get_initial(self): |
76 | initial = super(CreateCategory, self).get_initial() | 79 | initial = super(CreateCategory, self).get_initial() |
77 | 80 | ||
@@ -82,16 +85,21 @@ class CreateCategory(views.SuperuserRequiredMixin, HasRoleMixin, LogMixin, Creat | @@ -82,16 +85,21 @@ class CreateCategory(views.SuperuserRequiredMixin, HasRoleMixin, LogMixin, Creat | ||
82 | initial['description'] = category.description | 85 | initial['description'] = category.description |
83 | initial['name'] = category.name | 86 | initial['name'] = category.name |
84 | initial['visible'] = category.visible | 87 | initial['visible'] = category.visible |
85 | - #initial['coordinators'] = category.coordinators | 88 | + |
86 | 89 | ||
87 | self.log_action = 'replicate' | 90 | self.log_action = 'replicate' |
88 | 91 | ||
89 | self.log_context['replicated_category_id'] = category.id | 92 | self.log_context['replicated_category_id'] = category.id |
90 | self.log_context['replicated_category_name'] = category.name | 93 | self.log_context['replicated_category_name'] = category.name |
91 | self.log_context['replicated_category_slug'] = category.slug | 94 | self.log_context['replicated_category_slug'] = category.slug |
92 | - | ||
93 | return initial | 95 | return initial |
94 | 96 | ||
97 | + def get_context_data(self, **kwargs): | ||
98 | + context = super(CreateCategory, self).get_context_data(**kwargs) | ||
99 | + context['users_count'] = User.objects.all().count() | ||
100 | + context['switch'] = True | ||
101 | + return context | ||
102 | + | ||
95 | 103 | ||
96 | def get_form(self, form_class=None): | 104 | def get_form(self, form_class=None): |
97 | """ | 105 | """ |