Skip to content

Commit

Permalink
feat(forum): add tags to model
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentporte committed Aug 7, 2024
1 parent 94bbcd3 commit cb8f9ed
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lacommunaute/forum/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class ForumAdmin(BaseForumAdmin):
fieldsets = BaseForumAdmin.fieldsets
fieldsets[0][1]["fields"] += ("short_description", "certified")
fieldsets[0][1]["fields"] += ("short_description", "certified", "tags")
fieldsets[1][1]["fields"] += (
"members_group",
"invitation_token",
Expand Down
24 changes: 24 additions & 0 deletions lacommunaute/forum/migrations/0017_forum_tags.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Generated by Django 5.0.7 on 2024-08-07 14:21

import taggit.managers
from django.db import migrations


class Migration(migrations.Migration):
dependencies = [
("forum", "0016_forum_certified"),
("taggit", "0006_rename_taggeditem_content_type_object_id_taggit_tagg_content_8fc721_idx"),
]

operations = [
migrations.AddField(
model_name="forum",
name="tags",
field=taggit.managers.TaggableManager(
help_text="A comma-separated list of tags.",
through="taggit.TaggedItem",
to="taggit.Tag",
verbose_name="Tags",
),
),
]
3 changes: 3 additions & 0 deletions lacommunaute/forum/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from machina.apps.forum.abstract_models import AbstractForum
from machina.models import DatedModel
from storages.backends.s3boto3 import S3Boto3Storage
from taggit.managers import TaggableManager

from lacommunaute.forum.enums import Kind as Forum_Kind
from lacommunaute.forum_conversation.models import Topic
Expand Down Expand Up @@ -40,6 +41,8 @@ class Forum(AbstractForum):

upvotes = GenericRelation(UpVote, related_query_name="forum")

tags = TaggableManager()

objects = ForumQuerySet().as_manager()

def get_absolute_url(self):
Expand Down

0 comments on commit cb8f9ed

Please sign in to comment.