Commit eac05ca887d53be181b042764f66fc4a7afe46bb
1 parent
7631fcc3
Exists in
master
and in
3 other branches
modified subjects view and all of it
Showing
8 changed files
with
194 additions
and
9 deletions
Show diff stats
amadeus/static/css/base/amadeus.css
@@ -4,12 +4,12 @@ | @@ -4,12 +4,12 @@ | ||
4 | #sidebar-menu{ | 4 | #sidebar-menu{ |
5 | margin-left: 30%; | 5 | margin-left: 30%; |
6 | } | 6 | } |
7 | -#sidebar-menu > .item{ | 7 | +#sidebar-menu .item{ |
8 | font-size: 45px; | 8 | font-size: 45px; |
9 | background-color: #26A69A; | 9 | background-color: #26A69A; |
10 | color: white; | 10 | color: white; |
11 | width: 80%; | 11 | width: 80%; |
12 | - margin: 10px; | 12 | + margin: 10px 0px 10px 10px; |
13 | text-align: center; | 13 | text-align: center; |
14 | } | 14 | } |
15 | 15 | ||
@@ -19,6 +19,14 @@ | @@ -19,6 +19,14 @@ | ||
19 | 19 | ||
20 | } | 20 | } |
21 | 21 | ||
22 | +#subjects-link{ | ||
23 | + margin-top: 0px !important; | ||
24 | +} | ||
25 | + | ||
26 | +#sidebar-menu-div{ | ||
27 | + padding-right: 10px; | ||
28 | +} | ||
29 | + | ||
22 | 30 | ||
23 | 31 | ||
24 | /* side bar menu ends*/ | 32 | /* side bar menu ends*/ |
amadeus/templates/base.html
@@ -139,12 +139,12 @@ | @@ -139,12 +139,12 @@ | ||
139 | {% endblock %} | 139 | {% endblock %} |
140 | <div class="container-fluid"> | 140 | <div class="container-fluid"> |
141 | <div class="row"> | 141 | <div class="row"> |
142 | - <div class="col-xs-2 col-sm-2 col-md-2 col-lg-2 col-xl-2"> | 142 | + <div id="sidebar-menu-div" class="col-xs-2 col-sm-2 col-md-2 col-lg-2 col-xl-2"> |
143 | {% block sidebar %} | 143 | {% block sidebar %} |
144 | <ul id="sidebar-menu"> | 144 | <ul id="sidebar-menu"> |
145 | - <li class="item" data-toggle="tooltip" data-placement="right" title="{% trans "Subjects" %}"> | 145 | + <a href="{% url 'subjects:index' %}"><li class="item" id="subjects-link" data-toggle="tooltip" data-placement="right" title="{% trans "Subjects" %}"> |
146 | <i class="fa fa-graduation-cap" aria-hidden="true"></i> | 146 | <i class="fa fa-graduation-cap" aria-hidden="true"></i> |
147 | - </li> | 147 | + </li></a> |
148 | <li class="item" data-toggle="tooltip" data-placement="right" title="{% trans "Timeline" %}"> | 148 | <li class="item" data-toggle="tooltip" data-placement="right" title="{% trans "Timeline" %}"> |
149 | <i class="fa fa-list" aria-hidden="true" ></i> | 149 | <i class="fa fa-list" aria-hidden="true" ></i> |
150 | </li> | 150 | </li> |
amadeus/urls.py
@@ -26,6 +26,7 @@ urlpatterns = [ | @@ -26,6 +26,7 @@ urlpatterns = [ | ||
26 | url(r'^admin/', admin.site.urls), | 26 | url(r'^admin/', admin.site.urls), |
27 | url(r'^$', index, name = 'home'), | 27 | url(r'^$', index, name = 'home'), |
28 | url(r'^categories/', include('categories.urls', namespace = 'categories')), | 28 | url(r'^categories/', include('categories.urls', namespace = 'categories')), |
29 | + url(r'^subjects/', include('subjects.urls', namespace='subjects')), | ||
29 | #API | 30 | #API |
30 | url(r'^o/', include('oauth2_provider.urls', namespace='oauth2_provider')), | 31 | url(r'^o/', include('oauth2_provider.urls', namespace='oauth2_provider')), |
31 | #S3Direct | 32 | #S3Direct |
amadeus/views.py
1 | from django.http import Http404 | 1 | from django.http import Http404 |
2 | from django.shortcuts import redirect | 2 | from django.shortcuts import redirect |
3 | +from django.urls import reverse_lazy | ||
3 | 4 | ||
4 | def index(request): | 5 | def index(request): |
5 | if request.user.is_authenticated: | 6 | if request.user.is_authenticated: |
6 | - return redirect('categories:index') | 7 | + return redirect(reverse_lazy("subjects:index")) |
7 | else: | 8 | else: |
8 | return redirect('users:login') | 9 | return redirect('users:login') |
9 | \ No newline at end of file | 10 | \ No newline at end of file |
categories/views.py
@@ -24,7 +24,7 @@ import time | @@ -24,7 +24,7 @@ import time | ||
24 | 24 | ||
25 | from users.models import User | 25 | from users.models import User |
26 | 26 | ||
27 | -class IndexView(LoginRequiredMixin, ListView): | 27 | +class IndexView(views.SuperuserRequiredMixin, LoginRequiredMixin, ListView): |
28 | 28 | ||
29 | login_url = reverse_lazy("users:login") | 29 | login_url = reverse_lazy("users:login") |
30 | redirect_field_name = 'next' | 30 | redirect_field_name = 'next' |
@@ -0,0 +1,104 @@ | @@ -0,0 +1,104 @@ | ||
1 | +{% extends 'categories/home.html' %} | ||
2 | + | ||
3 | +{% load static i18n permission_tags %} | ||
4 | +{% load django_bootstrap_breadcrumbs %} | ||
5 | + | ||
6 | +{% block javascript%} | ||
7 | + {{ block.super }} | ||
8 | +{% endblock%} | ||
9 | + | ||
10 | +{% block breadcrumbs %} | ||
11 | + {{ block.super }} | ||
12 | + {% breadcrumb "Subjects" 'categories:index' %} | ||
13 | +{% endblock %} | ||
14 | + | ||
15 | +{% block content %} | ||
16 | + {% if messages %} | ||
17 | + {% for message in messages %} | ||
18 | + <script type="text/javascript"> | ||
19 | + alertify.success('{{message}}'); | ||
20 | + </script> | ||
21 | + {% endfor %} | ||
22 | + {% endif %} | ||
23 | + <div id="core-subjects-options-div"> | ||
24 | + <ul class="core-subjects-options"> | ||
25 | + <li class="active">{% trans "My subjects" %}</li> | ||
26 | + <li>{% trans "all subjects" %}</li> | ||
27 | + </ul> | ||
28 | + </div> | ||
29 | + | ||
30 | + <!-- Code for listing categories --> | ||
31 | + <div class="col-md-12 cards-content"> | ||
32 | + <div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true"> | ||
33 | + {% for category in categories %} | ||
34 | + <div class="panel panel-info"> | ||
35 | + <div class="panel-heading"> | ||
36 | + <div class="row"> | ||
37 | + <div class="col-md-12 category-header"> | ||
38 | + <h4 class="panel-title"> | ||
39 | + <a class="category-course-link pull-left" data-parent="#accordion" data-toggle="collapse" href="#{{category.slug}}"> | ||
40 | + <button class="btn btn-default btn-xs text-center cat-selector"><i class="fa fa-angle-right fa-2x" aria-hidden="true"></i></button> {{category.name}} | ||
41 | + </a> | ||
42 | + </h4> | ||
43 | + {% if user.is_staff or user in category.coordinators.all %} | ||
44 | + <div class=" divMoreActions"> | ||
45 | + <div class="btn-group"> | ||
46 | + <button class="btn btn-default btn-sm dropdown-toggle" type="button" id="moreActions" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> | ||
47 | + <i class="fa fa-ellipsis-v fa-2x" aria-hidden="true"></i> | ||
48 | + </button> | ||
49 | + <ul class="dropdown-menu pull-right" aria-labelledby="moreActions"> | ||
50 | + {% if user.is_staff %} | ||
51 | + <li><a href="{% url 'categories:replicate' category.slug %}"><i class="fa fa-files-o fa-fw" aria-hidden="true"></i>{% trans 'Replicate' %}</a></li> | ||
52 | + {% endif %} | ||
53 | + <li><a href="{% url 'categories:update' category.slug %}"><i class="fa fa-pencil fa-fw" aria-hidden="true"></i>{% trans 'Edit' %}</a></li> | ||
54 | + <li><a href="javascript:delete_course.get('{% url 'categories:delete' category.slug %}?view=index','#category','#modal_course')"><i class="fa fa-trash fa-fw" aria-hidden="true"></i> {% trans 'Remove' %}</a></li> | ||
55 | + </ul> | ||
56 | + </div> | ||
57 | + </div> | ||
58 | + {% else %} | ||
59 | + <div class=" divMoreActions"> | ||
60 | + </div> | ||
61 | + {% endif %} | ||
62 | + {% if not user.is_staff %} | ||
63 | + <div class="col-md-5 pull-right category-card-items"> | ||
64 | + <a href="" ><i class="fa fa-list" aria-hidden="true"></i></a> | ||
65 | + <a href=""><i class="fa fa-envelope-o" aria-hidden="true"></i></a> | ||
66 | + <a href=""><i class="fa fa-exclamation-triangle" aria-hidden="true"></i></a> | ||
67 | + <a href=""><i class="fa fa-bar-chart" aria-hidden="true"></i></a> | ||
68 | + </div> | ||
69 | + {% endif %} | ||
70 | + </div> | ||
71 | + </div> | ||
72 | + </div> | ||
73 | + <div id="{{category.slug}}" class="panel-collapse collapse category-panel-content"> | ||
74 | + <input type="hidden" class="log_url" value="{% url 'categories:view_log' category.id %}" /> | ||
75 | + <input type="hidden" class="log_id" value="" /> | ||
76 | + | ||
77 | + <h4> {% trans "Coordinator(s): " %} | ||
78 | + {% for coordinator in category.coordinators.all %} | ||
79 | + {{coordinator.username}} | ||
80 | + {% endfor %} | ||
81 | + </h4> | ||
82 | + {{category.description|safe}} | ||
83 | + {% if user in category.coordinators.all %} | ||
84 | + <button class="create-subject-btn"> {% trans "create new subject" %} </button> | ||
85 | + {% endif %} | ||
86 | + | ||
87 | + </div> | ||
88 | + | ||
89 | + | ||
90 | + {% comment %} | ||
91 | + <div id="{{category.slug}}" class="panel-collapse collapse"> | ||
92 | + {% for subject in subjects %} | ||
93 | + {% include "categories/category_card.html" %} | ||
94 | + {% endfor %} | ||
95 | + </div> | ||
96 | + {% endcomment %} | ||
97 | + </div> | ||
98 | + {% endfor %} | ||
99 | + </div> | ||
100 | + </div> | ||
101 | + <div id="modal_course"> | ||
102 | + </div> | ||
103 | + <script type="text/javascript" src="{% static 'js/course.js' %}"></script> | ||
104 | +{% endblock %} |
subjects/views.py
1 | -from django.shortcuts import render | ||
2 | 1 | ||
3 | -# Create your views here. | 2 | +from django.shortcuts import render, get_object_or_404 |
3 | +from django.views.generic import ListView, CreateView, DeleteView, UpdateView | ||
4 | +from categories.models import Category | ||
5 | +from django.core.urlresolvers import reverse_lazy | ||
6 | +from rolepermissions.verifications import has_role | ||
7 | + | ||
8 | +from django.contrib import messages | ||
9 | +from django.http import HttpResponse, JsonResponse | ||
10 | +from django.utils.translation import ugettext_lazy as _ | ||
11 | + | ||
12 | +from django.contrib.auth.mixins import LoginRequiredMixin | ||
13 | + | ||
14 | +from rolepermissions.mixins import HasRoleMixin | ||
15 | +from categories.forms import CategoryForm | ||
16 | + | ||
17 | +from braces import views | ||
18 | +from subjects.models import Subject | ||
19 | + | ||
20 | +from log.mixins import LogMixin | ||
21 | +from log.decorators import log_decorator_ajax | ||
22 | +from log.models import Log | ||
23 | + | ||
24 | +import time | ||
25 | + | ||
26 | +from users.models import User | ||
27 | + | ||
28 | + | ||
29 | +class IndexView(LoginRequiredMixin, ListView): | ||
30 | + | ||
31 | + login_url = reverse_lazy("users:login") | ||
32 | + redirect_field_name = 'next' | ||
33 | + queryset = Category.objects.all() | ||
34 | + template_name = 'subjects/list.html' | ||
35 | + context_object_name = 'categories' | ||
36 | + | ||
37 | + | ||
38 | + def get_queryset(self): | ||
39 | + result = super(IndexView, self).get_queryset() | ||
40 | + | ||
41 | + | ||
42 | + return result | ||
43 | + | ||
44 | + def render_to_response(self, context, **response_kwargs): | ||
45 | + if self.request.user.is_staff: | ||
46 | + context['page_template'] = "categories/home_admin_content.html" | ||
47 | + else: | ||
48 | + context['page_template'] = "categories/home_teacher_student.html" | ||
49 | + | ||
50 | + context['title'] = _('Categories') | ||
51 | + | ||
52 | + if self.request.is_ajax(): | ||
53 | + if self.request.user.is_staff: | ||
54 | + self.template_name = "categories/home_admin_content.html" | ||
55 | + else: | ||
56 | + self.template_name = "categories/home_teacher_student_content.html" | ||
57 | + | ||
58 | + return self.response_class(request = self.request, template = self.template_name, context = context, using = self.template_engine, **response_kwargs) | ||
59 | + | ||
60 | + def get_context_data(self, **kwargs): | ||
61 | + context = super(IndexView, self).get_context_data(**kwargs) | ||
62 | + list_categories = None | ||
63 | + categories = self.get_queryset().order_by('name') | ||
64 | + | ||
65 | + | ||
66 | + context['categories'] = categories | ||
67 | + | ||
68 | + return context |