Commit f7db7452c53f30f3276692ce72daf1e9d1033f9a

Authored by Felipe Henrique de Almeida Bormann
1 parent bfb98dad

fixed some issues

amadeus/static/css/base/amadeus.css
... ... @@ -59,12 +59,12 @@
59 59 }
60 60  
61 61 #create-category{
62   - margin-left: 40%;
  62 + margin-left: 20%;
63 63 margin-bottom: 1%;
64 64 border: none;
65 65 background-color: #66BB6A;
66 66 color: #FFFFFF;
67   - width: 200px;
  67 + width: 60%;
68 68 height: 40px;
69 69 font-size: 15px;
70 70 }
... ...
categories/forms.py
... ... @@ -9,4 +9,4 @@ class CategoryForm(forms.ModelForm):
9 9 'description': forms.Textarea,
10 10 'coordinators' : forms.SelectMultiple,
11 11 }
12   -
13 12 \ No newline at end of file
  13 +
14 14 \ No newline at end of file
... ...
categories/templates/categories/create.html
1 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 5 {% block breadcrumbs %}
6 6 {{ block.super }}
... ... @@ -28,6 +28,24 @@
28 28  
29 29 {% elif field.auto_id == 'id_description' %}
30 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 49 {% else %}
32 50 {% render_field field class='form-control' %}
33 51 {% endif %}
... ...
categories/templates/categories/list.html
... ... @@ -84,11 +84,12 @@
84 84 {{coordinator.username}}
85 85 {% endfor %}
86 86 </h4>
87   - {{category.description|safe}}
  87 +
  88 + </div>
  89 + {{category.description|safe}}
88 90 {% if user in category.coordinators.all %}
89 91 <button class="create-subject-btn"> {% trans "create new subject" %} </button>
90 92 {% endif %}
91   - </div>
92 93  
93 94  
94 95 {% comment %}
... ...
categories/templates/categories/update.html
... ... @@ -66,8 +66,8 @@
66 66 });
67 67  
68 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 71 afterInit: function(ms){
72 72 var that = this,
73 73 $selectableSearch = that.$selectableUl.prev(),
... ...
categories/templatetags/__init__.py 0 → 100644
categories/templatetags/switchevenodd.py 0 → 100644
... ... @@ -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 17 \ No newline at end of file
... ...
categories/views.py
... ... @@ -18,6 +18,8 @@ from subjects.models import Subject
18 18  
19 19 from log.mixins import LogMixin
20 20  
  21 +from users.models import User
  22 +
21 23 class IndexView(LoginRequiredMixin, ListView):
22 24  
23 25 login_url = reverse_lazy("users:login")
... ... @@ -72,6 +74,7 @@ class CreateCategory(views.SuperuserRequiredMixin, HasRoleMixin, LogMixin, Creat
72 74 success_url = reverse_lazy('categories:index')
73 75  
74 76  
  77 +
75 78 def get_initial(self):
76 79 initial = super(CreateCategory, self).get_initial()
77 80  
... ... @@ -82,16 +85,21 @@ class CreateCategory(views.SuperuserRequiredMixin, HasRoleMixin, LogMixin, Creat
82 85 initial['description'] = category.description
83 86 initial['name'] = category.name
84 87 initial['visible'] = category.visible
85   - #initial['coordinators'] = category.coordinators
  88 +
86 89  
87 90 self.log_action = 'replicate'
88 91  
89 92 self.log_context['replicated_category_id'] = category.id
90 93 self.log_context['replicated_category_name'] = category.name
91 94 self.log_context['replicated_category_slug'] = category.slug
92   -
93 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 104 def get_form(self, form_class=None):
97 105 """
... ...