From d95238c2071b0e7453786d191e3e99db508cb729 Mon Sep 17 00:00:00 2001 From: Todd Dembrey <todd.dembrey@torchbox.com> Date: Fri, 2 Mar 2018 15:14:02 +0000 Subject: [PATCH] Add all_activity to the page --- .../templates/activity/include/action_list.html | 6 +----- .../templates/activity/include/all_activity_list.html | 3 +++ .../templates/activity/include/comment_list.html | 6 +----- .../templates/activity/include/listing_base.html | 5 +++++ opentech/apply/activity/views.py | 10 ++++++++++ opentech/apply/funds/templates/funds/submissions.html | 4 ++++ opentech/apply/funds/views.py | 9 +++++++-- 7 files changed, 31 insertions(+), 12 deletions(-) create mode 100644 opentech/apply/activity/templates/activity/include/all_activity_list.html create mode 100644 opentech/apply/activity/templates/activity/include/listing_base.html diff --git a/opentech/apply/activity/templates/activity/include/action_list.html b/opentech/apply/activity/templates/activity/include/action_list.html index 98b106ed5..ebd8bbaa1 100644 --- a/opentech/apply/activity/templates/activity/include/action_list.html +++ b/opentech/apply/activity/templates/activity/include/action_list.html @@ -1,7 +1,3 @@ {% for action in actions %} -<div> - <p>{{ action.timestamp }}</p> - <p>{{ action.user }}</p> - <p>{{ action.message }}</p> -</div> + {% include "activity/include/listing_base.html" with activity=action %} {% endfor %} diff --git a/opentech/apply/activity/templates/activity/include/all_activity_list.html b/opentech/apply/activity/templates/activity/include/all_activity_list.html new file mode 100644 index 000000000..312a0b329 --- /dev/null +++ b/opentech/apply/activity/templates/activity/include/all_activity_list.html @@ -0,0 +1,3 @@ +{% for activity in all_activity %} + {% include "activity/include/listing_base.html" with activity=activity %} +{% endfor %} diff --git a/opentech/apply/activity/templates/activity/include/comment_list.html b/opentech/apply/activity/templates/activity/include/comment_list.html index 9217e3013..cfd58fa44 100644 --- a/opentech/apply/activity/templates/activity/include/comment_list.html +++ b/opentech/apply/activity/templates/activity/include/comment_list.html @@ -1,7 +1,3 @@ {% for comment in comments %} -<div> - <p>{{ comment.timestamp }}</p> - <p>{{ comment.user }}</p> - <p>{{ comment.message }}</p> -</div> + {% include "activity/include/listing_base.html" with activity=comment %} {% endfor %} diff --git a/opentech/apply/activity/templates/activity/include/listing_base.html b/opentech/apply/activity/templates/activity/include/listing_base.html new file mode 100644 index 000000000..8d44760d7 --- /dev/null +++ b/opentech/apply/activity/templates/activity/include/listing_base.html @@ -0,0 +1,5 @@ +<div> + <p>{{ activity.timestamp }}</p> + <p>{{ activity.user }}</p> + <p>{{ activity.message }}</p> +</div> diff --git a/opentech/apply/activity/views.py b/opentech/apply/activity/views.py index 881b1f1b8..716bcce1b 100644 --- a/opentech/apply/activity/views.py +++ b/opentech/apply/activity/views.py @@ -4,6 +4,16 @@ from .forms import CommentForm from .models import Activity, COMMENT +class AllActivityContextMixin: + def get_context_data(self, **kwargs): + extra = { + 'actions': Activity.actions.filter(submission__in=self.object_list), + 'comments': Activity.comments.filter(submission__in=self.object_list), + 'all_activity': Activity.objects.filter(submission__in=self.object_list), + } + return super().get_context_data(**extra, **kwargs) + + class ActivityContextMixin: def get_context_data(self, **kwargs): extra = { diff --git a/opentech/apply/funds/templates/funds/submissions.html b/opentech/apply/funds/templates/funds/submissions.html index 3428cc9a7..f039d269e 100644 --- a/opentech/apply/funds/templates/funds/submissions.html +++ b/opentech/apply/funds/templates/funds/submissions.html @@ -39,6 +39,10 @@ {% render_table table %} </div> +{% include "activity/include/comment_list.html" %} +{% include "activity/include/action_list.html" %} +{% include "activity/include/all_activity_list.html" %} + {% endblock %} {% block extra_js %} diff --git a/opentech/apply/funds/views.py b/opentech/apply/funds/views.py index 2867c82a4..fa5103e36 100644 --- a/opentech/apply/funds/views.py +++ b/opentech/apply/funds/views.py @@ -5,7 +5,12 @@ from django.views.generic import DetailView, UpdateView, View from django_filters.views import FilterView from django_tables2.views import SingleTableMixin -from opentech.apply.activity.views import ActivityContextMixin, CommentFormView, DelegatedViewMixin +from opentech.apply.activity.views import ( + AllActivityContextMixin, + ActivityContextMixin, + CommentFormView, + DelegatedViewMixin, +) from opentech.apply.activity.models import Activity from .forms import ProgressSubmissionForm @@ -14,7 +19,7 @@ from .tables import SubmissionsTable, SubmissionFilter, SubmissionFilterAndSearc from .workflow import SingleStage, DoubleStage -class SubmissionListView(SingleTableMixin, FilterView): +class SubmissionListView(AllActivityContextMixin, SingleTableMixin, FilterView): template_name = 'funds/submissions.html' table_class = SubmissionsTable -- GitLab