Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentporte committed Jun 29, 2023
1 parent 1ee9ddf commit ecccdc9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
3 changes: 2 additions & 1 deletion lacommunaute/forum/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ class ForumFactory(BaseForumFactory):
type = Forum.FORUM_POST
members_group = factory.SubFactory(GroupFactory, name=factory.SelfAttribute("..name"))
name = factory.Faker("name")
description = factory.Faker("sentence", nb_words=10)
description = factory.Faker("sentence", nb_words=100)
short_description = factory.Faker("sentence", nb_words=10)

@factory.post_generation
def with_public_perms(self, create, extracted, **kwargs):
Expand Down
6 changes: 4 additions & 2 deletions lacommunaute/forum/tests/tests_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from machina.core.db.models import get_model
from machina.core.loading import get_class

from lacommunaute.forum.enums import Kind as ForumKind
from lacommunaute.forum.factories import ForumFactory
from lacommunaute.forum.models import Forum
from lacommunaute.forum_conversation.factories import TopicFactory
Expand All @@ -20,11 +21,12 @@

class ForumManagerTest(TestCase):
def test_private_forum(self):
ForumFactory(is_private=True)
ForumFactory(kind=ForumKind.NEWS)
ForumFactory(kind=ForumKind.PRIVATE_FORUM)
self.assertEqual(Forum.objects.public().count(), 0)

def test_public_forum(self):
forum = ForumFactory(is_private=False)
forum = ForumFactory(kind=ForumKind.PUBLIC_FORUM)
self.assertEqual(Forum.objects.public().count(), 1)
self.assertIn(forum, Forum.objects.public())

Expand Down
4 changes: 3 additions & 1 deletion lacommunaute/pages/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ def get_context_data(self, **kwargs: Any) -> dict[str, Any]:
"-last_post_on"
)[:4]
context["topics_newsfeed"] = Topic.objects.filter(forum__kind=ForumKind.NEWS).order_by("-last_post_on")[:4]
context["forums_category"] = Forum.objects.filter(kind=ForumKind.PUBLIC_FORUM, parent__type=1)[:4]
context["forums_category"] = Forum.objects.filter(kind=ForumKind.PUBLIC_FORUM, parent__type=1).order_by(
"-updated"
)[:4]
context["forum"] = Forum.objects.filter(kind=ForumKind.PUBLIC_FORUM, lft=1, level=0).first()
return context

Expand Down

0 comments on commit ecccdc9

Please sign in to comment.