Skip to content

Commit

Permalink
feat(forum_member): remove unused subscriptions views and urls
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentporte committed Mar 17, 2023
1 parent c76eaf4 commit aebb27e
Show file tree
Hide file tree
Showing 6 changed files with 0 additions and 98 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
{% load forum_permission_tags %}

{% get_permission 'can_add_post' topic request.user as user_can_add_post %}
{% comment %}{% get_permission 'can_subscribe_to_topic' topic request.user as user_can_subscribe_to_topic %}
{% get_permission 'can_unsubscribe_from_topic' topic request.user as user_can_unsubscribe_from_topic %} {% endcomment %}
{% get_permission 'can_lock_topics' topic.forum request.user as user_can_lock_topics %}
{% get_permission 'can_move_topics' topic.forum request.user as user_can_move_topics %}
{% get_permission 'can_delete_topics' topic.forum request.user as user_can_delete_topics %}
Expand Down Expand Up @@ -42,11 +40,6 @@
</a>
{% endif %}

{% if user_can_subscribe_to_topic %}
<a href="{% url 'members:topic_subscribe' topic.pk %}" class="btn btn-info btn-sm btn-subscription"><i class="fas fa-check">&nbsp;</i>{% trans "Subscribe" %}</a>
{% elif user_can_unsubscribe_from_topic %}
<a href="{% url 'members:topic_unsubscribe' topic.pk %}" class="btn btn-info btn-sm btn-subscription"><i class="fas fa-times">&nbsp;</i>{% trans "Unsubscribe" %}</a>
{% endif %}
{% if user_can_lock_topics and not topic.is_locked or user_can_move_topics or user_can_delete_topics %}
<button id="id_dropdown_moderation_menu_button" class="btn btn-outline-primary btn-ico-only btn-sm" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<i class="ri-more-line" aria-label="Plus d'actions"></i>
Expand Down

This file was deleted.

35 changes: 0 additions & 35 deletions lacommunaute/www/forum_member_views/tests.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import uuid
from unittest import mock

from django.contrib.auth.models import Group
from django.test import RequestFactory, TestCase
from django.urls import reverse
from machina.core.loading import get_class
from machina.test.factories.forum import create_forum

from lacommunaute.forum_conversation.factories import TopicFactory
from lacommunaute.forum_member.factories import ForumProfileFactory
from lacommunaute.users.factories import DEFAULT_PASSWORD, UserFactory
from lacommunaute.www.forum_member_views.views import ForumProfileUpdateView
Expand Down Expand Up @@ -168,36 +166,3 @@ def test_already_in_group(self):
self.client.force_login(self.user)
self.client.post(self.url)
self.assertTrue(self.forum.members_group.user_set.filter(id=self.user.id).exists())


@mock.patch(
"lacommunaute.www.forum_member_views.views.TopicSubscribeView.perform_permissions_check", return_value=True
)
class TopicSubscribeViewTest(TestCase):
def test_authentified_access(self, _mock):
topic = TopicFactory(with_post=True)
url = reverse("members:topic_subscribe", kwargs={"pk": topic.pk})

self.client.force_login(topic.poster)
response = self.client.get(url)
self.assertEqual(response.status_code, 200)


@mock.patch(
"lacommunaute.www.forum_member_views.views.TopicUnsubscribeView.perform_permissions_check", return_value=True
)
class TopicUnsubscribeViewTest(TestCase):
def test_authentified_access(self, _mock):
topic = TopicFactory(with_post=True)
url = reverse("members:topic_unsubscribe", kwargs={"pk": topic.pk})

self.client.force_login(topic.poster)
response = self.client.get(url)
self.assertEqual(response.status_code, 200)


class TopicSubscriptionListViewTest(TestCase):
def test_access(self):
self.client.force_login(UserFactory())
response = self.client.get(reverse("members:user_subscriptions"))
self.assertEqual(response.status_code, 200)
6 changes: 0 additions & 6 deletions lacommunaute/www/forum_member_views/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
JoinForumFormView,
JoinForumLandingView,
ModeratorProfileListView,
TopicSubscribeView,
TopicSubscriptionListView,
TopicUnsubscribeView,
)


Expand All @@ -20,7 +17,4 @@
path("forum/<str:slug>-<int:pk>/", ModeratorProfileListView.as_view(), name="forum_profiles"),
path("join-forum-landing/<uuid:token>/", JoinForumLandingView.as_view(), name="join_forum_landing"),
path("join-forum/<uuid:token>/", JoinForumFormView.as_view(), name="join_forum_form"),
path("topic/<int:pk>/subscribe/", TopicSubscribeView.as_view(), name="topic_subscribe"),
path("topic/<int:pk>/unsubscribe/", TopicUnsubscribeView.as_view(), name="topic_unsubscribe"),
path("subscriptions/", TopicSubscriptionListView.as_view(), name="user_subscriptions"),
]
15 changes: 0 additions & 15 deletions lacommunaute/www/forum_member_views/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@
from machina.apps.forum_member.views import (
ForumProfileDetailView as BaseForumProfileDetailView,
ForumProfileUpdateView as BaseForumProfileUpdateView,
TopicSubscribeView as BaseTopicSubscribeView,
TopicSubscriptionListView as BaseTopicSubscriptionListView,
TopicUnsubscribeView as BaseTopicUnsubscribeView,
)
from machina.core.loading import get_class

Expand Down Expand Up @@ -134,15 +131,3 @@ def get_success_url(self):
"pk": self.forum.pk,
},
)


class TopicSubscribeView(BaseTopicSubscribeView):
pass


class TopicUnsubscribeView(BaseTopicUnsubscribeView):
pass


class TopicSubscriptionListView(BaseTopicSubscriptionListView):
pass
27 changes: 0 additions & 27 deletions lacommunaute/www/forum_views/tests_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,33 +97,6 @@ def setUpTestData(cls):

cls.url = reverse("forum_extension:forum", kwargs={"pk": cls.forum.pk, "slug": cls.forum.slug})

def test_subscription_button_is_hidden(self):
self.client.force_login(self.user)
response = self.client.get(self.url)

self.assertEqual(response.status_code, 200)
self.assertContains(
response,
reverse(
"forum_conversation_extension:post_create",
kwargs={
"forum_pk": self.forum.pk,
"forum_slug": self.forum.slug,
"pk": self.topic.pk,
"slug": self.topic.slug,
},
),
)
self.assertNotContains(
response,
reverse(
"members:topic_subscribe",
kwargs={
"pk": self.topic.pk,
},
),
)

def test_show_comments(self):
topic_url = reverse(
"forum_conversation_extension:showmore_posts",
Expand Down

0 comments on commit aebb27e

Please sign in to comment.