From 74425b056050b6d0f3b7dddb78ef5854be915d40 Mon Sep 17 00:00:00 2001 From: Todd Dembrey <todd.dembrey@torchbox.com> Date: Thu, 1 Mar 2018 16:25:12 +0000 Subject: [PATCH] Add activity list to the detail page --- .../activity/templates/activity/include/activity_list.html | 7 +++++++ opentech/apply/activity/views.py | 5 +++-- .../templates/funds/applicationsubmission_detail.html | 1 + opentech/apply/funds/views.py | 4 ++-- 4 files changed, 13 insertions(+), 4 deletions(-) create mode 100644 opentech/apply/activity/templates/activity/include/activity_list.html diff --git a/opentech/apply/activity/templates/activity/include/activity_list.html b/opentech/apply/activity/templates/activity/include/activity_list.html new file mode 100644 index 000000000..07494662f --- /dev/null +++ b/opentech/apply/activity/templates/activity/include/activity_list.html @@ -0,0 +1,7 @@ +{% for event in activity %} +<div> + <p>{{ event.timestamp }}</p> + <p>{{ event.user }}</p> + <p>{{ event.message }}</p> +</div> +{% endfor %} diff --git a/opentech/apply/activity/views.py b/opentech/apply/activity/views.py index f7a15a82e..124df88ac 100644 --- a/opentech/apply/activity/views.py +++ b/opentech/apply/activity/views.py @@ -4,9 +4,10 @@ from .forms import CommentForm from .models import Activity, COMMENT -class CommentContextMixin: +class ActivityContextMixin: def get_context_data(self, **kwargs): extra = { + 'activity': Activity.activities.filter(submission=self.object), 'comments': Activity.comments.filter(submission=self.object), CommentFormView.context_name: CommentFormView.form_class(), } @@ -38,4 +39,4 @@ class CommentFormView(DelegatedViewMixin, CreateView): return super().form_valid(form) def get_success_url(self): - return self.object.application.get_absolute_url() + return self.object.submission.get_absolute_url() diff --git a/opentech/apply/funds/templates/funds/applicationsubmission_detail.html b/opentech/apply/funds/templates/funds/applicationsubmission_detail.html index 4ffd19992..d9ddb50cb 100644 --- a/opentech/apply/funds/templates/funds/applicationsubmission_detail.html +++ b/opentech/apply/funds/templates/funds/applicationsubmission_detail.html @@ -62,6 +62,7 @@ {% endif %} {% include "activity/include/comment_form.html" %} {% include "activity/include/comment_list.html" %} + {% include "activity/include/activity_list.html" %} </aside> </div> </div> diff --git a/opentech/apply/funds/views.py b/opentech/apply/funds/views.py index 1158689b5..a43b32b92 100644 --- a/opentech/apply/funds/views.py +++ b/opentech/apply/funds/views.py @@ -5,7 +5,7 @@ from django.views.generic import DetailView, UpdateView from django_filters.views import FilterView from django_tables2.views import SingleTableMixin -from opentech.apply.activity.views import CommentContextMixin, CommentFormView, DelegatedViewMixin +from opentech.apply.activity.views import ActivityContextMixin, CommentFormView, DelegatedViewMixin from opentech.apply.activity.models import Activity from .forms import ProgressSubmissionForm @@ -70,7 +70,7 @@ class ProgressSubmissionView(DelegatedViewMixin, UpdateView): return response -class SubmissionDetailView(CommentContextMixin, ProgressContextMixin, DetailView): +class SubmissionDetailView(ActivityContextMixin, ProgressContextMixin, DetailView): model = ApplicationSubmission form_views = { 'progress': ProgressSubmissionView, -- GitLab