Commit 7a958146d81c927d843a7ff6422c50328b335436
Exists in
master
and in
5 other branches
search bar #189
Showing
8 changed files
with
42 additions
and
39 deletions
Show diff stats
amadeus/settings.py
... | ... | @@ -30,8 +30,6 @@ SECRET_KEY = '$=8)c!5)iha85a&8q4+kv1pyg0yl7_xe_x^z=2cn_1d7r0hny4' |
30 | 30 | # SECURITY WARNING: don't run with debug turned on in production! |
31 | 31 | DEBUG = False |
32 | 32 | |
33 | -ALLOWED_HOSTS = [] | |
34 | - | |
35 | 33 | |
36 | 34 | # Application definition |
37 | 35 | |
... | ... | @@ -165,7 +163,7 @@ SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO','https') |
165 | 163 | ALLOWED_HOSTS = ['*'] |
166 | 164 | |
167 | 165 | # Files |
168 | -MEDIA_ROOT = os.path.join(os.path.dirname(BASE_DIR), 'uploads') | |
166 | +MEDIA_ROOT = os.path.join(PROJECT_ROOT, 'uploads') | |
169 | 167 | MEDIA_URL = '/uploads/' |
170 | 168 | |
171 | 169 | ... | ... |
amadeus/uploads/ciencia-da-computacao/teorica/tipfef/Apresentacao_da_Cadidatura_a_Marketing_-_Matheus_Lins.pptx
0 → 100644
No preview for this file type
amadeus/uploads/ciencia-da-computacao/teorica/tipfef/Cartao_Outubro.pdf
0 → 100644
No preview for this file type
courses/templates/course/index.html
... | ... | @@ -74,10 +74,10 @@ |
74 | 74 | <form id="searchform" action="{% url 'course:manage' %}" method="get" accept-charset="utf-8"> |
75 | 75 | <div class="input-group"> |
76 | 76 | <div class="form-group is-empty"> |
77 | - <input type="search" class="form-control" placeholder="Search Courses" name="q" id="searchbox"></div> | |
77 | + <input type="text" class="form-control" placeholder="Search Courses" name="q"></div> | |
78 | 78 | <span class="input-group-btn input-group-sm"> |
79 | - <button type="button" class="btn btn-fab btn-fab-mini"> | |
80 | - <i class="material-icons">search</i> | |
79 | + <button type="submit" class="btn btn-fab btn-fab-mini"> | |
80 | + <i class="material-icons">{% trans 'Search' %}</i> | |
81 | 81 | </button> |
82 | 82 | </span> |
83 | 83 | </div> |
... | ... | @@ -88,16 +88,14 @@ |
88 | 88 | </fieldset> |
89 | 89 | <div class="col-md-12 cards-content"> |
90 | 90 | {% if courses|length > 0 %} |
91 | - {% if request.GET.category == 'all' or none or request.GET.category == '' %} | |
91 | + {% if request.GET.category == '' or aparece or request.GET.q == '' %} | |
92 | 92 | {% for course in list_courses %} |
93 | 93 | {% include "course/course_card.html" %} |
94 | 94 | {% endfor %} |
95 | - {% else %} | |
96 | - {% for course in courses_category %} | |
97 | - {% if course.category.name == request.GET.category %} | |
98 | - <!-- Put your content here! --> | |
99 | - {% include "course/course_card.html" %} | |
100 | - {% endif %} | |
95 | + {% endif %} | |
96 | + {% if request.GET.category or request.GET.q %} | |
97 | + {% for course in courses %} | |
98 | + {% include "course/course_card.html" %} | |
101 | 99 | {% endfor %} |
102 | 100 | {% endif %} |
103 | 101 | {% else %} | ... | ... |
courses/templates/course/view.html
... | ... | @@ -76,7 +76,6 @@ |
76 | 76 | </div> |
77 | 77 | </div> |
78 | 78 | <div class="panel-body"> |
79 | - <p><b>{% trans 'Course Name' %}: </b>{{ course.name }}</p> | |
80 | 79 | <p><b>{% trans 'Coordinator' %}: </b>{% for professor in course.professors.all %}{% if not forloop.first %},{% endif %} |
81 | 80 | {{professor}}{% if forloop.last %}.{% endif %}{% endfor %}</p> |
82 | 81 | <p> | ... | ... |
courses/templates/subject/form_view_teacher.html
... | ... | @@ -135,8 +135,8 @@ |
135 | 135 | </div> |
136 | 136 | <div class="form-group"> |
137 | 137 | <div class="col-md-10"> |
138 | - <button type="button" class="btn btn-raised btn-default edit_card_end">Cancel</button> | |
139 | - <button type="submit" class="btn btn-raised btn-primary edit_card_end">Submit</button> | |
138 | + <button type="button" class="btn btn-raised btn-default edit_card_end">{% trans 'Cancel' %}</button> | |
139 | + <button type="submit" class="btn btn-raised btn-primary edit_card_end">{% trans 'Submit' %}</button> | |
140 | 140 | </div> |
141 | 141 | </div> |
142 | 142 | </div><!--EndEditation--> |
... | ... | @@ -198,13 +198,13 @@ |
198 | 198 | </div> |
199 | 199 | </div> |
200 | 200 | <div class="form-group is-empty"> |
201 | - <label for="number" class="col-md-2 control-label">Height</label> | |
201 | + <label for="number" class="col-md-2 control-label">{% trans 'Height' %}</label> | |
202 | 202 | <div class="col-md-4"> |
203 | 203 | <input type="number" class="form-control" id="inputNumber" placeholder="Heiht"> |
204 | 204 | </div> |
205 | 205 | </div> |
206 | 206 | <div class="form-group is-empty"> |
207 | - <label for="number" class="col-md-2 control-label">Weight</label> | |
207 | + <label for="number" class="col-md-2 control-label">{% trans 'Weight' %}</label> | |
208 | 208 | <div class="col-md-4"> |
209 | 209 | <input type="number" class="form-control" id="inputNumber" placeholder="Weight"> |
210 | 210 | </div> | ... | ... |
courses/templates/subject/index.html
... | ... | @@ -70,7 +70,8 @@ |
70 | 70 | </div> |
71 | 71 | </div> |
72 | 72 | <div class="panel-body"> |
73 | - <p><b>{% trans "Professor" %}:</b> {{subject.professors}}</p> | |
73 | + <p><b>{% trans "Professor" %}:</b> {% for professor in subject.professors.all %}{% if not forloop.first %},{% endif %} | |
74 | + {{professor}}{% if forloop.last %}.{% endif %}{% endfor %}</p> | |
74 | 75 | <p> |
75 | 76 | <b>{% trans "Description" %}:</b> |
76 | 77 | {{subject.description|linebreaks}} | ... | ... |
courses/views.py
... | ... | @@ -9,6 +9,8 @@ from django.core.urlresolvers import reverse_lazy |
9 | 9 | from django.utils.translation import ugettext_lazy as _ |
10 | 10 | from rolepermissions.verifications import has_role |
11 | 11 | from django.db.models import Q |
12 | +import operator | |
13 | +from functools import reduce | |
12 | 14 | from rolepermissions.verifications import has_object_permission |
13 | 15 | from django.http import HttpResponseRedirect, JsonResponse |
14 | 16 | |
... | ... | @@ -31,6 +33,29 @@ class IndexView(LoginRequiredMixin, NotificationMixin, generic.ListView): |
31 | 33 | template_name = 'course/index.html' |
32 | 34 | context_object_name = 'courses' |
33 | 35 | paginate_by = 5 |
36 | + aparece = True | |
37 | + | |
38 | + | |
39 | + def get_queryset(self): | |
40 | + result = super(IndexView, self).get_queryset() | |
41 | + | |
42 | + course_search = self.request.GET.get('q', None) | |
43 | + category_search = self.request.GET.get('category', None) | |
44 | + if course_search: | |
45 | + self.aparece = False | |
46 | + query_list = course_search.split() | |
47 | + result = result.filter( | |
48 | + reduce(operator.and_, | |
49 | + (Q(name__icontains=q) for q in query_list)) | |
50 | + ) | |
51 | + if category_search: | |
52 | + self.aparece = False | |
53 | + query_list = category_search.split() | |
54 | + result = result.filter( | |
55 | + reduce(operator.and_, | |
56 | + (Q(category__name=category) for category in query_list)) | |
57 | + ) | |
58 | + return result | |
34 | 59 | |
35 | 60 | def get_context_data(self, **kwargs): |
36 | 61 | context = super(IndexView, self).get_context_data(**kwargs) |
... | ... | @@ -46,13 +71,6 @@ class IndexView(LoginRequiredMixin, NotificationMixin, generic.ListView): |
46 | 71 | list_courses = Course.objects.filter(Q(students = True)|Q(students__name = self.request.user.name)).order_by('name') |
47 | 72 | categorys_courses = CourseCategory.objects.filter(course_category__students__name = self.request.user.name).distinct() |
48 | 73 | |
49 | - courses_category = Course.objects.filter(category__name = self.request.GET.get('category')) | |
50 | - none = None | |
51 | - q = self.request.GET.get('category', None) | |
52 | - if q is None: | |
53 | - none = True | |
54 | - context['none'] = none | |
55 | - | |
56 | 74 | paginator = Paginator(list_courses, self.paginate_by) |
57 | 75 | page = self.request.GET.get('page') |
58 | 76 | |
... | ... | @@ -63,23 +81,12 @@ class IndexView(LoginRequiredMixin, NotificationMixin, generic.ListView): |
63 | 81 | except EmptyPage: |
64 | 82 | list_courses = paginator.page(paginator.num_pages) |
65 | 83 | |
66 | - context['courses_category'] = courses_category | |
67 | 84 | context['list_courses'] = list_courses |
68 | 85 | context['categorys_courses'] = categorys_courses |
86 | + context['aparece'] = self.aparece | |
69 | 87 | |
70 | 88 | return context |
71 | - | |
72 | - def get_queryset(self): | |
73 | - try: | |
74 | - name = self.kwargs['q'] | |
75 | - except: | |
76 | - name = '' | |
77 | - if (name != ''): | |
78 | - object_list = Course.objects.filter(name__icontains = name) | |
79 | - else: | |
80 | - object_list = Course.objects.all() | |
81 | - return object_list | |
82 | - | |
89 | + | |
83 | 90 | class CreateCourseView(LoginRequiredMixin, HasRoleMixin, NotificationMixin,generic.edit.CreateView): |
84 | 91 | |
85 | 92 | allowed_roles = ['professor', 'system_admin'] | ... | ... |