Commit f7799b4a40f706383b4a39bb953745dd4649b7b8
1 parent
7ed1cef1
Exists in
master
and in
3 other branches
Adjusting subject view page
Showing
4 changed files
with
78 additions
and
14 deletions
Show diff stats
amadeus/static/css/base/amadeus.css
@@ -91,6 +91,11 @@ a:focus { | @@ -91,6 +91,11 @@ a:focus { | ||
91 | margin-bottom: 2px; | 91 | margin-bottom: 2px; |
92 | } | 92 | } |
93 | 93 | ||
94 | +.category-header > h4.panel-title span { | ||
95 | + margin-left: 10px; | ||
96 | + font-weight: normal; | ||
97 | +} | ||
98 | + | ||
94 | .category-header > h4 > a:focus { | 99 | .category-header > h4 > a:focus { |
95 | text-decoration: none; | 100 | text-decoration: none; |
96 | } | 101 | } |
amadeus/static/css/themes/green.css
@@ -189,10 +189,14 @@ a, a:focus, a:hover { | @@ -189,10 +189,14 @@ a, a:focus, a:hover { | ||
189 | color: #BDBDBD; | 189 | color: #BDBDBD; |
190 | } | 190 | } |
191 | 191 | ||
192 | -.panel-title{ /*Because we use an outer a tag*/ | 192 | +.panel-title { /*Because we use an outer a tag*/ |
193 | color: rgba(255,255,255,.84); | 193 | color: rgba(255,255,255,.84); |
194 | } | 194 | } |
195 | 195 | ||
196 | +.category-header > h4.panel-title span { | ||
197 | + color: #FFFFFF; | ||
198 | +} | ||
199 | + | ||
196 | .accordion { | 200 | .accordion { |
197 | background: white; | 201 | background: white; |
198 | } | 202 | } |
subjects/templates/subjects/view.html
@@ -5,20 +5,72 @@ | @@ -5,20 +5,72 @@ | ||
5 | 5 | ||
6 | {% block javascript%} | 6 | {% block javascript%} |
7 | {{ block.super }} | 7 | {{ block.super }} |
8 | - | ||
9 | {% endblock%} | 8 | {% endblock%} |
10 | 9 | ||
11 | {% block breadcrumbs %} | 10 | {% block breadcrumbs %} |
12 | {{ block.super }} | 11 | {{ block.super }} |
13 | - {% breadcrumb 'Home' 'subjects:home' %} | ||
14 | - | 12 | + {% breadcrumb subject.category 'subjects:index' %} |
13 | + {% breadcrumb subject 'subjects:view' subject.slug %} | ||
15 | {% endblock %} | 14 | {% endblock %} |
16 | 15 | ||
17 | - | ||
18 | {% block content %} | 16 | {% block content %} |
17 | + {% if subject.visible %} | ||
18 | + <div class="panel panel-info subject-panel"> | ||
19 | + <div class="panel-heading"> | ||
20 | + {% elif request.user in subject.professor.all or request.user in subject.category.coordinators.all or request.user.is_staff %} | ||
21 | + <div class="panel panel-info subject-panel-invisible"> | ||
22 | + <div class="panel-heading panel-invisible"> | ||
23 | + {% endif %} | ||
24 | + <div class="row"> | ||
25 | + <div class="col-md-12 category-header"> | ||
26 | + <h4 class="panel-title" style="margin-top: 10px; margin-bottom: 8px"> | ||
27 | + <span>{{subject.name}}</span> | ||
28 | + </h4> | ||
19 | 29 | ||
20 | - {% include "subjects/subject_card.html" %} | 30 | + <div class="col-md-5 pull-right category-card-items"> |
31 | + {% if request.user in subject.professor.all or request.user in subject.category.coordinators.all or request.user.is_staff %} | ||
32 | + <a href="" id="moreActions" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> | ||
33 | + <i class="fa fa-ellipsis-v" aria-hidden="true"></i> | ||
34 | + </a> | ||
35 | + <ul class="dropdown-menu pull-right" aria-labelledby="moreActions"> | ||
36 | + <li><a href="{% url 'subjects:replicate' subject.slug %}"><i class="fa fa-files-o fa-fw" aria-hidden="true"></i>{% trans 'Replicate' %}</a></li> | ||
37 | + <li><a href="{% url 'subjects:update' subject.slug %}"><i class="fa fa-pencil fa-fw" aria-hidden="true"></i>{% trans 'Edit' %}</a></li> | ||
38 | + <li><a href="javascript:delete_subject.get('{% url 'subjects:delete' subject.slug %}?view=index','#subject','#modal_subject')"><i class="fa fa-trash fa-fw" aria-hidden="true"></i> {% trans 'Remove' %}</a></li> | ||
39 | + </ul> | ||
40 | + {% endif %} | ||
41 | + <a href="" ><i class="fa fa-list" aria-hidden="true"></i></a> | ||
42 | + <a href=""><i class="fa fa-envelope-o" aria-hidden="true"></i></a> | ||
43 | + <a href=""><i class="fa fa-exclamation-triangle" aria-hidden="true"></i></a> | ||
44 | + <a href=""><i class="fa fa-bar-chart" aria-hidden="true"></i></a> | ||
45 | + </div> | ||
46 | + </div> | ||
47 | + </div> | ||
48 | + </div> | ||
49 | + <div id="{{subject.slug}}" class="panel-collapse in collapse category-panel-content"> | ||
50 | + <div class="row"> | ||
51 | + <div class="col-md-6"> | ||
52 | + {% if subject.professor.all|length > 0 %} | ||
53 | + <h4><b>{% trans "Professor(s) " %}: </b> | ||
54 | + {{ subject.professor.all|join:', ' }} | ||
55 | + </h4> | ||
56 | + {% else %} | ||
57 | + <h4> {% trans "It doesn't possess professors" %} </h4> | ||
58 | + {% endif %} | ||
59 | + </div> | ||
60 | + <div class="col-xs-6 col-md-3"> | ||
61 | + <p><b>{% trans "Beginning" %}:</b> {{subject.init_date}}</p> | ||
62 | + </div> | ||
63 | + <div class="col-xs-6 col-md-3"> | ||
64 | + <p><b>{% trans "End" %}:</b> {{subject.end_date}}</p> | ||
65 | + </div> | ||
66 | + </div> | ||
21 | 67 | ||
68 | + <p>{{subject.description|safe}}</p> | ||
22 | 69 | ||
23 | - | 70 | + {% if request.user in subject.professor.all or request.user in subject.category.coordinators.all or request.user.is_staff %} |
71 | + <a href="{% url 'subjects:create' subject.category.slug %}"><button class="btn btn-sm btn-primary btn-raised btn-block"> {% trans "Create new topic" %} </button></a> | ||
72 | + {% endif %} | ||
73 | + | ||
74 | + </div> | ||
75 | + </div> | ||
24 | {% endblock content %} | 76 | {% endblock content %} |
25 | \ No newline at end of file | 77 | \ No newline at end of file |
subjects/views.py
1 | 1 | ||
2 | from django.shortcuts import render, get_object_or_404 | 2 | from django.shortcuts import render, get_object_or_404 |
3 | -from django.views.generic import ListView, CreateView, DeleteView, UpdateView, TemplateView | 3 | +from django.views.generic import ListView, CreateView, DeleteView, UpdateView, TemplateView, DetailView |
4 | from categories.models import Category | 4 | from categories.models import Category |
5 | from django.core.urlresolvers import reverse_lazy | 5 | from django.core.urlresolvers import reverse_lazy |
6 | from rolepermissions.verifications import has_role | 6 | from rolepermissions.verifications import has_role |
@@ -120,11 +120,12 @@ class IndexView(LoginRequiredMixin, ListView): | @@ -120,11 +120,12 @@ class IndexView(LoginRequiredMixin, ListView): | ||
120 | 120 | ||
121 | return context | 121 | return context |
122 | 122 | ||
123 | -class SubjectCreateView(CreateView): | 123 | +class SubjectCreateView(LoginRequiredMixin, CreateView): |
124 | model = Subject | 124 | model = Subject |
125 | template_name = "subjects/create.html" | 125 | template_name = "subjects/create.html" |
126 | 126 | ||
127 | login_url = reverse_lazy('users:login') | 127 | login_url = reverse_lazy('users:login') |
128 | + redirect_field_name = 'next' | ||
128 | form_class = CreateSubjectForm | 129 | form_class = CreateSubjectForm |
129 | 130 | ||
130 | success_url = reverse_lazy('subject:index') | 131 | success_url = reverse_lazy('subject:index') |
@@ -182,7 +183,7 @@ class SubjectCreateView(CreateView): | @@ -182,7 +183,7 @@ class SubjectCreateView(CreateView): | ||
182 | messages.success(self.request, _('Subject "%s" was registered on "%s" successfully!')%(self.object.name, self.object.category.name )) | 183 | messages.success(self.request, _('Subject "%s" was registered on "%s" successfully!')%(self.object.name, self.object.category.name )) |
183 | return reverse_lazy('subjects:index') | 184 | return reverse_lazy('subjects:index') |
184 | 185 | ||
185 | -class SubjectUpdateView(LogMixin, UpdateView): | 186 | +class SubjectUpdateView(LoginRequiredMixin, LogMixin, UpdateView): |
186 | model = Subject | 187 | model = Subject |
187 | form_class = CreateSubjectForm | 188 | form_class = CreateSubjectForm |
188 | template_name = 'subjects/update.html' | 189 | template_name = 'subjects/update.html' |
@@ -245,15 +246,17 @@ class SubjectDeleteView(LoginRequiredMixin, LogMixin, DeleteView): | @@ -245,15 +246,17 @@ class SubjectDeleteView(LoginRequiredMixin, LogMixin, DeleteView): | ||
245 | return reverse_lazy('subjects:index') | 246 | return reverse_lazy('subjects:index') |
246 | 247 | ||
247 | 248 | ||
248 | -class SubjectDetailView(TemplateView): | 249 | +class SubjectDetailView(LoginRequiredMixin, DetailView): |
250 | + login_url = reverse_lazy("users:login") | ||
251 | + redirect_field_name = 'next' | ||
252 | + | ||
249 | model = Subject | 253 | model = Subject |
250 | template_name = 'subjects/view.html' | 254 | template_name = 'subjects/view.html' |
255 | + context_object_name = 'subject' | ||
251 | 256 | ||
252 | def get_context_data(self, **kwargs): | 257 | def get_context_data(self, **kwargs): |
253 | context = super(SubjectDetailView, self).get_context_data(**kwargs) | 258 | context = super(SubjectDetailView, self).get_context_data(**kwargs) |
254 | - context['subject'] = get_object_or_404(Subject, slug = self.kwargs.get('slug')) | ||
255 | - context['show_buttons'] = False #So it doesn't show subscribe and access buttons | ||
256 | - | 259 | + context['title'] = self.object.name |
257 | 260 | ||
258 | return context | 261 | return context |
259 | 262 |