From 8578c176941d4e6f00d0d7559bf7d83d4152f128 Mon Sep 17 00:00:00 2001 From: Fredrik Jonsson <frjo@xdeb.org> Date: Mon, 4 Nov 2019 13:15:05 +0100 Subject: [PATCH] Remove the global activity feed. No one is using it so lets save some queries. --- opentech/apply/activity/views.py | 28 ---------- .../funds/includes/activity-feed.html | 34 ------------ .../funds/templates/funds/submissions.html | 12 ----- .../templates/funds/submissions_by_round.html | 11 ---- .../templates/funds/submissions_overview.html | 12 ----- opentech/apply/funds/views.py | 9 ++-- .../src/javascript/apply/activity-feed.js | 52 ------------------- .../sass/apply/components/_activity-feed.scss | 37 ------------- opentech/static_src/src/sass/apply/main.scss | 1 - 9 files changed, 4 insertions(+), 192 deletions(-) delete mode 100644 opentech/apply/funds/templates/funds/includes/activity-feed.html delete mode 100644 opentech/static_src/src/javascript/apply/activity-feed.js delete mode 100644 opentech/static_src/src/sass/apply/components/_activity-feed.scss diff --git a/opentech/apply/activity/views.py b/opentech/apply/activity/views.py index 7249fd422..c04b4b267 100644 --- a/opentech/apply/activity/views.py +++ b/opentech/apply/activity/views.py @@ -8,34 +8,6 @@ from .messaging import messenger, MESSAGES from .models import Activity, COMMENT -ACTIVITY_LIMIT = 50 - - -class AllActivityContextMixin: - def get_context_data(self, **kwargs): - extra = { - 'actions': Activity.actions.select_related( - 'user', - ).prefetch_related( - 'source', - 'related_object', - )[:ACTIVITY_LIMIT], - 'comments': Activity.comments.select_related( - 'user', - ).prefetch_related( - 'source', - 'related_object', - )[:ACTIVITY_LIMIT], - 'all_activity': Activity.objects.select_related( - 'user', - ).prefetch_related( - 'source', - 'related_object', - )[:ACTIVITY_LIMIT], - } - return super().get_context_data(**extra, **kwargs) - - class ActivityContextMixin: def get_context_data(self, **kwargs): related_query = self.model.activities.rel.related_query_name diff --git a/opentech/apply/funds/templates/funds/includes/activity-feed.html b/opentech/apply/funds/templates/funds/includes/activity-feed.html deleted file mode 100644 index 37117315c..000000000 --- a/opentech/apply/funds/templates/funds/includes/activity-feed.html +++ /dev/null @@ -1,34 +0,0 @@ -<div class="js-activity-feed activity-feed"> - <div class="activity-feed__header"> - <div class="wrapper wrapper--medium wrapper--relative"> - <h4 class="activity-feed__heading">Activity Feed <svg class="icon icon--speech-bubble"><use xlink:href="#speech-bubble"></use></svg></h4> - <a href="#" class="js-close-feed link link--close-feed">Close</a> - <div class="tabs js-tabs"> - <div class="tabs__container"> - <a class="tab__item tab__item--active" href="#" data-tab="tab-1">Communications</a> - <a class="tab__item" href="#" data-tab="tab-2">Activity</a> - <a class="tab__item" href="#" data-tab="tab-3">All</a> - </div> - </div> - </div> - </div> - - <div class="wrapper wrapper--medium wrapper--activity-feed js-tabs-content"> - <div class="tabs__content tabs__content--current" id="tab-1"> - {% include "activity/include/comment_list.html" with submission_title=True editable=False %} - </div> - - <div class="tabs__content" id="tab-2"> - {% include "activity/include/action_list.html" with submission_title=True %} - </div> - - <div class="tabs__content" id="tab-3"> - {% include "activity/include/all_activity_list.html" with submission_title=True %} - </div> - </div> - - <a href="#" class="js-to-top link link--to-top"> - <svg class="icon icon--to-top"><use xlink:href="#chevron"></use></svg> - <h6>Back to top</h6> - </a> -</div> diff --git a/opentech/apply/funds/templates/funds/submissions.html b/opentech/apply/funds/templates/funds/submissions.html index 353450fa7..0ed85d1e4 100644 --- a/opentech/apply/funds/templates/funds/submissions.html +++ b/opentech/apply/funds/templates/funds/submissions.html @@ -1,5 +1,4 @@ {% extends "funds/base_submissions_table.html" %} -{% load static %} {% block title %}Submissions{% endblock %} {% block content %} @@ -18,15 +17,4 @@ {{ block.super }} {% endblock %} </div> - -<a href="#" class="js-open-feed link link--open-feed"> - <h4 class="heading heading--no-margin heading--activity-feed">Activity Feed</h4> -</a> -{% include "funds/includes/activity-feed.html" %} - -{% endblock %} - -{% block extra_js %} - {{ block.super }} - <script src="{% static 'js/apply/activity-feed.js' %}"></script> {% endblock %} diff --git a/opentech/apply/funds/templates/funds/submissions_by_round.html b/opentech/apply/funds/templates/funds/submissions_by_round.html index f09d574a2..b4f56a7ce 100644 --- a/opentech/apply/funds/templates/funds/submissions_by_round.html +++ b/opentech/apply/funds/templates/funds/submissions_by_round.html @@ -23,15 +23,4 @@ </div> </div> {% render_bundle 'submissionsByRound' %} - -<a href="#" class="js-open-feed link link--open-feed"> - <h4 class="heading heading--no-margin heading--activity-feed">Activity Feed</h4> -</a> -{% include "funds/includes/activity-feed.html" %} - -{% endblock %} - -{% block extra_js %} - {{ block.super }} - <script src="{% static 'js/apply/activity-feed.js' %}"></script> {% endblock %} diff --git a/opentech/apply/funds/templates/funds/submissions_overview.html b/opentech/apply/funds/templates/funds/submissions_overview.html index e712be96f..94c9092a8 100644 --- a/opentech/apply/funds/templates/funds/submissions_overview.html +++ b/opentech/apply/funds/templates/funds/submissions_overview.html @@ -1,5 +1,4 @@ {% extends "funds/base_submissions_table.html" %} -{% load static %} {% load render_table from django_tables2 %} {% block title %}Submissions{% endblock %} @@ -32,15 +31,4 @@ </div> {% endblock %} </div> - -<a href="#" class="js-open-feed link link--open-feed"> - <h4 class="heading heading--no-margin heading--activity-feed">Activity Feed</h4> -</a> -{% include "funds/includes/activity-feed.html" %} - -{% endblock %} - -{% block extra_js %} - {{ block.super }} - <script src="{% static 'js/apply/activity-feed.js' %}"></script> {% endblock %} diff --git a/opentech/apply/funds/views.py b/opentech/apply/funds/views.py index b134a851b..3347d8621 100644 --- a/opentech/apply/funds/views.py +++ b/opentech/apply/funds/views.py @@ -19,7 +19,6 @@ from django_tables2.views import SingleTableMixin from wagtail.core.models import Page from opentech.apply.activity.views import ( - AllActivityContextMixin, ActivityContextMixin, CommentFormView, DelegatedViewMixin, @@ -231,7 +230,7 @@ class BaseReviewerSubmissionsTable(BaseAdminSubmissionsTable): @method_decorator(staff_required, name='dispatch') -class SubmissionOverviewView(AllActivityContextMixin, BaseAdminSubmissionsTable): +class SubmissionOverviewView(BaseAdminSubmissionsTable): template_name = 'funds/submissions_overview.html' table_class = SummarySubmissionsTable table_pagination = False @@ -274,7 +273,7 @@ class SubmissionOverviewView(AllActivityContextMixin, BaseAdminSubmissionsTable) ) -class SubmissionAdminListView(AllActivityContextMixin, BaseAdminSubmissionsTable, DelegateableListView): +class SubmissionAdminListView(BaseAdminSubmissionsTable, DelegateableListView): template_name = 'funds/submissions.html' form_views = [ BatchUpdateLeadView, @@ -283,7 +282,7 @@ class SubmissionAdminListView(AllActivityContextMixin, BaseAdminSubmissionsTable ] -class SubmissionReviewerListView(AllActivityContextMixin, BaseReviewerSubmissionsTable): +class SubmissionReviewerListView(BaseReviewerSubmissionsTable): template_name = 'funds/submissions.html' @@ -293,7 +292,7 @@ class SubmissionListView(ViewDispatcher): @method_decorator(staff_required, name='dispatch') -class SubmissionsByRound(AllActivityContextMixin, BaseAdminSubmissionsTable, DelegateableListView): +class SubmissionsByRound(BaseAdminSubmissionsTable, DelegateableListView): template_name = 'funds/submissions_by_round.html' form_views = [ BatchUpdateLeadView, diff --git a/opentech/static_src/src/javascript/apply/activity-feed.js b/opentech/static_src/src/javascript/apply/activity-feed.js deleted file mode 100644 index bedfb677d..000000000 --- a/opentech/static_src/src/javascript/apply/activity-feed.js +++ /dev/null @@ -1,52 +0,0 @@ -(function ($) { - - 'use strict'; - - // Open the activity feed - $('.js-open-feed').click((e) => { - e.preventDefault(); - $('body').addClass('no-scroll'); - $('.js-activity-feed').addClass('is-open'); - }); - - // Close the activity feed - $('.js-close-feed').click((e) => { - e.preventDefault(); - $('body').removeClass('no-scroll'); - $('.js-activity-feed').removeClass('is-open'); - }); - - // Show scroll to top of activity feed button on scroll - $('.js-activity-feed').on('scroll', function () { - if ($(this).scrollTop() === 0) { - $('.js-to-top').removeClass('is-visible'); - } - else { - $('.js-to-top').addClass('is-visible'); - } - }); - - // Scroll to the top of the activity feed - $('.js-to-top').click((e) => { - e.preventDefault(); - $('.js-activity-feed').animate({scrollTop: 0}, 250); - }); - - // Collaps long comments in activity feed. - $('.feed__item').each(function () { - var $content = $(this).find('.feed__content'); - var content_height = $content.outerHeight(); - if (content_height > 300) { - $(this).addClass('feed__item--collaps'); - $(this).append('<p class="feed__show-button"><a class="link link--button link--button--narrow" href="#">Show</a></p>'); - } - }); - - // Allow users to show full comment. - $('.feed__show-button').find('.link').click(function (e) { - e.preventDefault(); - $(this).parents('.feed__item').removeClass('feed__item--collaps'); - $(this).parent().detach(); - }); - -})(jQuery); diff --git a/opentech/static_src/src/sass/apply/components/_activity-feed.scss b/opentech/static_src/src/sass/apply/components/_activity-feed.scss deleted file mode 100644 index c239ded17..000000000 --- a/opentech/static_src/src/sass/apply/components/_activity-feed.scss +++ /dev/null @@ -1,37 +0,0 @@ -.activity-feed { - position: fixed; - top: 100vh; - right: 0; - left: 0; - transition: top .3s cubic-bezier(0, .52, .58, 1); - - &.is-open { - top: 0; - z-index: 99999; - width: 100%; - height: 100vh; - max-height: 100%; - overflow: scroll; - background: $color--white; - } - - &__header { - padding: 0 20px; - background-color: $color--default; - - @include media-query(tablet-portrait) { - padding: 0; - } - } - - &__heading { - display: flex; - align-items: center; - padding: 20px 0; - color: $color--white; - - @include media-query(tablet-portrait) { - justify-content: center; - } - } -} diff --git a/opentech/static_src/src/sass/apply/main.scss b/opentech/static_src/src/sass/apply/main.scss index 2846143b7..d2cd0d97d 100644 --- a/opentech/static_src/src/sass/apply/main.scss +++ b/opentech/static_src/src/sass/apply/main.scss @@ -11,7 +11,6 @@ @import 'components/all-submissions-table'; @import 'components/all-rounds-table'; @import 'components/admin-bar'; -@import 'components/activity-feed'; @import 'components/actions-bar'; @import 'components/card'; @import 'components/comment'; -- GitLab