Commit ade5a5e283be72f0eeca12d31ddc3930ed315da9
1 parent
5b858dde
Exists in
master
and in
3 other branches
Adding goals reports initial template
Showing
4 changed files
with
101 additions
and
0 deletions
Show diff stats
@@ -0,0 +1,58 @@ | @@ -0,0 +1,58 @@ | ||
1 | +{% extends 'subjects/view.html' %} | ||
2 | + | ||
3 | +{% load static i18n pagination permissions_tags subject_counter %} | ||
4 | +{% load django_bootstrap_breadcrumbs %} | ||
5 | + | ||
6 | +{% block style %} | ||
7 | + {{block.super}} | ||
8 | +{% endblock %} | ||
9 | + | ||
10 | +{% block javascript%} | ||
11 | + {{ block.super }} | ||
12 | +{% endblock%} | ||
13 | + | ||
14 | +{% block breadcrumbs %} | ||
15 | + {{ block.super }} | ||
16 | + {% breadcrumb topic 'subjects:topic_view' subject.slug topic.slug %} | ||
17 | + {% breadcrumb goal 'goals:submit' goal.slug %} | ||
18 | + | ||
19 | + {% trans 'Reports: Answered' as bread %} | ||
20 | + {% breadcrumb bread 'goals:answered_reports' goal.slug %} | ||
21 | +{% endblock %} | ||
22 | + | ||
23 | +{% block content %} | ||
24 | + {% resource_permissions request.user goal as has_resource_permissions %} | ||
25 | + | ||
26 | + {% if goal.visible %} | ||
27 | + <div class="panel panel-info topic-panel"> | ||
28 | + <div class="panel-heading"> | ||
29 | + {% elif has_resource_permissions %} | ||
30 | + <div class="panel panel-info topic-panel-invisible"> | ||
31 | + <div class="panel-heading panel-invisible"> | ||
32 | + {% endif %} | ||
33 | + <div class="row"> | ||
34 | + <div class="col-md-12 category-header"> | ||
35 | + <h4 class="panel-title" style="margin-top: 10px; margin-bottom: 8px"> | ||
36 | + <span>{{ goal }}</span> | ||
37 | + </h4> | ||
38 | + | ||
39 | + <div class="col-md-5 pull-right category-card-items"> | ||
40 | + <a href="{% url 'mural:resource_view' goal.slug %}" class="pull-right action_icon"> | ||
41 | + <i class="fa fa-list" aria-hidden="true"></i> | ||
42 | + {% resource_mural_number goal request.user %} | ||
43 | + </a> | ||
44 | + </div> | ||
45 | + </div> | ||
46 | + </div> | ||
47 | + </div> | ||
48 | + <div id="{{subject.slug}}" class="panel-collapse in collapse category-panel-content"> | ||
49 | + <div id="core-subjects-options-div"> | ||
50 | + <ul class="core-subjects-options"> | ||
51 | + <a href=""><li class="active">{% trans "Answered" %}</li></a> | ||
52 | + <a href=""><li class="">{% trans "Unanswered" %}</li></a> | ||
53 | + <a href=""><li class="">{% trans "Resource History" %}</li></a> | ||
54 | + </ul> | ||
55 | + </div> | ||
56 | + </div> | ||
57 | + </div> | ||
58 | +{% endblock %} | ||
0 | \ No newline at end of file | 59 | \ No newline at end of file |
goals/urls.py
@@ -11,4 +11,5 @@ urlpatterns = [ | @@ -11,4 +11,5 @@ urlpatterns = [ | ||
11 | url(r'^view/(?P<slug>[\w_-]+)/$', views.InsideView.as_view(), name = 'view'), | 11 | url(r'^view/(?P<slug>[\w_-]+)/$', views.InsideView.as_view(), name = 'view'), |
12 | url(r'^submit/(?P<slug>[\w_-]+)/$', views.SubmitView.as_view(), name = 'submit'), | 12 | url(r'^submit/(?P<slug>[\w_-]+)/$', views.SubmitView.as_view(), name = 'submit'), |
13 | url(r'^update_submit/(?P<slug>[\w_-]+)/$', views.UpdateSubmit.as_view(), name = 'update_submit'), | 13 | url(r'^update_submit/(?P<slug>[\w_-]+)/$', views.UpdateSubmit.as_view(), name = 'update_submit'), |
14 | + url(r'^answered_reports/(?P<slug>[\w_-]+)/$', views.AnsweredReport.as_view(), name = 'answered_reports'), | ||
14 | ] | 15 | ] |
goals/views.py
@@ -13,6 +13,45 @@ from topics.models import Topic | @@ -13,6 +13,45 @@ from topics.models import Topic | ||
13 | from .forms import GoalsForm, MyGoalsForm, InlinePendenciesFormset, InlineGoalItemFormset | 13 | from .forms import GoalsForm, MyGoalsForm, InlinePendenciesFormset, InlineGoalItemFormset |
14 | from .models import Goals, MyGoals | 14 | from .models import Goals, MyGoals |
15 | 15 | ||
16 | +class AnsweredReport(LoginRequiredMixin, generic.ListView): | ||
17 | + login_url = reverse_lazy("users:login") | ||
18 | + redirect_field_name = 'next' | ||
19 | + | ||
20 | + template_name = 'goals/reports.html' | ||
21 | + model = MyGoals | ||
22 | + context_object_name = 'answered' | ||
23 | + | ||
24 | + def get_queryset(self): | ||
25 | + slug = self.kwargs.get('slug', '') | ||
26 | + goal = get_object_or_404(Goals, slug = slug) | ||
27 | + | ||
28 | + goals = MyGoals.objects.filter(item__goal = goal) | ||
29 | + | ||
30 | + return goals | ||
31 | + | ||
32 | + def dispatch(self, request, *args, **kwargs): | ||
33 | + slug = self.kwargs.get('slug', '') | ||
34 | + goals = get_object_or_404(Goals, slug = slug) | ||
35 | + | ||
36 | + if not has_resource_permissions(request.user, goals): | ||
37 | + return redirect(reverse_lazy('subjects:home')) | ||
38 | + | ||
39 | + return super(AnsweredReport, self).dispatch(request, *args, **kwargs) | ||
40 | + | ||
41 | + def get_context_data(self, **kwargs): | ||
42 | + context = super(AnsweredReport, self).get_context_data(**kwargs) | ||
43 | + | ||
44 | + slug = self.kwargs.get('slug', '') | ||
45 | + goals = get_object_or_404(Goals, slug = slug) | ||
46 | + | ||
47 | + context['title'] = _("Reports: Answered") | ||
48 | + | ||
49 | + context['goal'] = goals | ||
50 | + context['topic'] = goals.topic | ||
51 | + context['subject'] = goals.topic.subject | ||
52 | + | ||
53 | + return context | ||
54 | + | ||
16 | class InsideView(LoginRequiredMixin, generic.ListView): | 55 | class InsideView(LoginRequiredMixin, generic.ListView): |
17 | login_url = reverse_lazy("users:login") | 56 | login_url = reverse_lazy("users:login") |
18 | redirect_field_name = 'next' | 57 | redirect_field_name = 'next' |
topics/templates/resources/list.html
@@ -29,6 +29,9 @@ | @@ -29,6 +29,9 @@ | ||
29 | </button> | 29 | </button> |
30 | <ul class="dropdown-menu pull-right" role="menu" aria-labelledby="moreResources"> | 30 | <ul class="dropdown-menu pull-right" role="menu" aria-labelledby="moreResources"> |
31 | <li><a href="{% url resource.update_link topic.slug resource.slug %}" class="edit"><i class="fa fa-pencil fa-fw" aria-hidden="true"></i>{% trans 'Edit' %}</a></li> | 31 | <li><a href="{% url resource.update_link topic.slug resource.slug %}" class="edit"><i class="fa fa-pencil fa-fw" aria-hidden="true"></i>{% trans 'Edit' %}</a></li> |
32 | + {% if resource|class_name == 'goals' %} | ||
33 | + <li><a href="{% url 'goals:answered_reports' resource.slug %}" class="edit"><i class="fa fa-file-pdf-o fa-fw" aria-hidden="true"></i>{% trans 'Reports' %}</a></li> | ||
34 | + {% endif %} | ||
32 | <li><a href="javascript:delete_resource('{% url resource.delete_link resource.slug %}')" class="delete"><i class="fa fa-trash fa-fw" aria-hidden="true"></i>{% trans 'Remove' %}</a></li> | 35 | <li><a href="javascript:delete_resource('{% url resource.delete_link resource.slug %}')" class="delete"><i class="fa fa-trash fa-fw" aria-hidden="true"></i>{% trans 'Remove' %}</a></li> |
33 | </ul> | 36 | </ul> |
34 | </span> | 37 | </span> |