Commit 9562702849ea798983146dead429b32e92205597
1 parent
f35e39d7
Exists in
master
and in
3 other branches
created subject detail view where it shows it topics
Showing
4 changed files
with
57 additions
and
11 deletions
Show diff stats
subjects/templates/subjects/subject_card.html
@@ -49,11 +49,14 @@ | @@ -49,11 +49,14 @@ | ||
49 | </div> | 49 | </div> |
50 | 50 | ||
51 | <p>{{subject.description_brief|safe}}</p> | 51 | <p>{{subject.description_brief|safe}}</p> |
52 | - | ||
53 | - {% if request.user in subject.students.all or request.user in subject.professor.all or request.user.is_staff or request.user in category.coordinators.all %} | ||
54 | - <a href="#" class="access-subject btn btn-primary btn-raised"> {% trans "Access Subject" %}</a> | ||
55 | - {% else %} | ||
56 | - <a href="#" class="subscribe-subject btn btn-primary btn-raised"> {% trans "Subscribe to Subject" %}</a> | 52 | + {% if show_buttons %} |
53 | + | ||
54 | + {% if request.user in subject.students.all or request.user in subject.professor.all or request.user.is_staff or request.user in category.coordinators.all %} | ||
55 | + <a href="{% url 'subjects:view' subject.slug %}" class="access-subject btn btn-primary btn-raised"> {% trans "Access Subject" %}</a> | ||
56 | + {% else %} | ||
57 | + <a href="#" class="subscribe-subject btn btn-primary btn-raised"> {% trans "Subscribe to Subject" %}</a> | ||
58 | + {% endif %} | ||
59 | + | ||
57 | {% endif %} | 60 | {% endif %} |
58 | </div> | 61 | </div> |
59 | </div> | 62 | </div> |
@@ -107,11 +110,14 @@ | @@ -107,11 +110,14 @@ | ||
107 | </div> | 110 | </div> |
108 | 111 | ||
109 | <p>{{subject.description_brief|safe}}</p> | 112 | <p>{{subject.description_brief|safe}}</p> |
110 | - | ||
111 | - {% if request.user in subject.students.all or request.user in subject.professor.all or request.user.is_staff or request.user in category.coordinators.all %} | ||
112 | - <a href="#" class="access-subject btn btn-primary btn-raised"> {% trans "Access Subject" %}</a> | ||
113 | - {% else %} | ||
114 | - <a href="#" class="subscribe-subject btn btn-primary btn-raised"> {% trans "Subscribe to Subject" %}</a> | 113 | + {% if show_buttons %} |
114 | + | ||
115 | + {% if request.user in subject.students.all or request.user in subject.professor.all or request.user.is_staff or request.user in category.coordinators.all %} | ||
116 | + <a href="{% url 'subjects:view' subject.slug %}" class="access-subject btn btn-primary btn-raised"> {% trans "Access Subject" %}</a> | ||
117 | + {% else %} | ||
118 | + <a href="#" class="subscribe-subject btn btn-primary btn-raised"> {% trans "Subscribe to Subject" %}</a> | ||
119 | + {% endif %} | ||
120 | + | ||
115 | {% endif %} | 121 | {% endif %} |
116 | </div> | 122 | </div> |
117 | </div> | 123 | </div> |
@@ -0,0 +1,23 @@ | @@ -0,0 +1,23 @@ | ||
1 | +{% extends 'categories/home.html' %} | ||
2 | + | ||
3 | +{% load static i18n pagination %} | ||
4 | +{% load django_bootstrap_breadcrumbs %} | ||
5 | + | ||
6 | +{% block javascript%} | ||
7 | + {{ block.super }} | ||
8 | + | ||
9 | +{% endblock%} | ||
10 | + | ||
11 | +{% block breadcrumbs %} | ||
12 | + {{ block.super }} | ||
13 | + | ||
14 | +{% endblock %} | ||
15 | + | ||
16 | + | ||
17 | +{% block content %} | ||
18 | + | ||
19 | + {% include "subjects/subject_card.html" %} | ||
20 | + | ||
21 | + | ||
22 | + | ||
23 | +{% endblock content %} | ||
0 | \ No newline at end of file | 24 | \ No newline at end of file |
subjects/urls.py
@@ -9,5 +9,6 @@ urlpatterns = [ | @@ -9,5 +9,6 @@ urlpatterns = [ | ||
9 | url(r'^replicate/(?P<subject_slug>[\w_-]+)/$', views.SubjectCreateView.as_view(), name='replicate'), | 9 | url(r'^replicate/(?P<subject_slug>[\w_-]+)/$', views.SubjectCreateView.as_view(), name='replicate'), |
10 | url(r'^update/(?P<slug>[\w_-]+)/$', views.SubjectUpdateView.as_view(), name='update'), | 10 | url(r'^update/(?P<slug>[\w_-]+)/$', views.SubjectUpdateView.as_view(), name='update'), |
11 | url(r'^delete/(?P<slug>[\w_-]+)/$', views.SubjectDeleteView.as_view(), name='delete'), | 11 | url(r'^delete/(?P<slug>[\w_-]+)/$', views.SubjectDeleteView.as_view(), name='delete'), |
12 | + url(r'^view/(?P<slug>[\w_-]+)/$', views.SubjectDetailView.as_view(), name='view'), | ||
12 | #url(r'^modal/(?P<subject_slug>[\w_-]+)/$', views.subscribe_subject(), name='subscribe'), | 13 | #url(r'^modal/(?P<subject_slug>[\w_-]+)/$', views.subscribe_subject(), name='subscribe'), |
13 | ] | 14 | ] |
14 | \ No newline at end of file | 15 | \ 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 | 3 | +from django.views.generic import ListView, CreateView, DeleteView, UpdateView, TemplateView |
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 |
@@ -51,6 +51,7 @@ class HomeView(LoginRequiredMixin, ListView): | @@ -51,6 +51,7 @@ class HomeView(LoginRequiredMixin, ListView): | ||
51 | def get_context_data(self, **kwargs): | 51 | def get_context_data(self, **kwargs): |
52 | context = super(HomeView, self).get_context_data(**kwargs) | 52 | context = super(HomeView, self).get_context_data(**kwargs) |
53 | context['title'] = _('Home') | 53 | context['title'] = _('Home') |
54 | + context['show_buttons'] = True #So it shows subscribe and access buttons | ||
54 | 55 | ||
55 | #bringing users | 56 | #bringing users |
56 | tags = Tag.objects.all() | 57 | tags = Tag.objects.all() |
@@ -99,6 +100,8 @@ class IndexView(LoginRequiredMixin, ListView): | @@ -99,6 +100,8 @@ class IndexView(LoginRequiredMixin, ListView): | ||
99 | 100 | ||
100 | context['all'] = False | 101 | context['all'] = False |
101 | context['title'] = _('My Subjects') | 102 | context['title'] = _('My Subjects') |
103 | + | ||
104 | + context['show_buttons'] = True #So it shows subscribe and access buttons | ||
102 | 105 | ||
103 | if self.kwargs.get('option'): | 106 | if self.kwargs.get('option'): |
104 | context['all'] = True | 107 | context['all'] = True |
@@ -222,6 +225,19 @@ class SubjectDeleteView(LoginRequiredMixin, LogMixin, DeleteView): | @@ -222,6 +225,19 @@ class SubjectDeleteView(LoginRequiredMixin, LogMixin, DeleteView): | ||
222 | 225 | ||
223 | return reverse_lazy('subjects:index') | 226 | return reverse_lazy('subjects:index') |
224 | 227 | ||
228 | + | ||
229 | +class SubjectDetailView(TemplateView): | ||
230 | + model = Subject | ||
231 | + template_name = 'subjects/view.html' | ||
232 | + | ||
233 | + def get_context_data(self, **kwargs): | ||
234 | + context = super(SubjectDetailView, self).get_context_data(**kwargs) | ||
235 | + context['subject'] = get_object_or_404(Subject, slug = self.kwargs.get('slug')) | ||
236 | + context['show_buttons'] = False #So it doesn't show subscribe and access buttons | ||
237 | + | ||
238 | + | ||
239 | + return context | ||
240 | + | ||
225 | def subscribe_subject(request, subject_slug): | 241 | def subscribe_subject(request, subject_slug): |
226 | subject = get_object_or_404(Subject, slug= subject_slug) | 242 | subject = get_object_or_404(Subject, slug= subject_slug) |
227 | subject.students.add(request.user) | 243 | subject.students.add(request.user) |