From 081adebd0d5be9a28af680b042eb0847e89bbe43 Mon Sep 17 00:00:00 2001 From: vincent porte Date: Wed, 28 Aug 2024 14:35:43 +0200 Subject: [PATCH] feat(partner): add app --- lacommunaute/forum/admin.py | 2 +- lacommunaute/forum/factories.py | 8 ++ .../forum/migrations/0018_forum_partner.py | 21 ++++ lacommunaute/forum/models.py | 2 + .../tests_partner_detailview.ambr | 104 +++++++++--------- .../__snapshots__/tests_partner_listview.ambr | 28 ++--- 6 files changed, 98 insertions(+), 67 deletions(-) create mode 100644 lacommunaute/forum/migrations/0018_forum_partner.py diff --git a/lacommunaute/forum/admin.py b/lacommunaute/forum/admin.py index 520b79f3..d299ccbc 100644 --- a/lacommunaute/forum/admin.py +++ b/lacommunaute/forum/admin.py @@ -6,7 +6,7 @@ class ForumAdmin(BaseForumAdmin): fieldsets = BaseForumAdmin.fieldsets - fieldsets[0][1]["fields"] += ("short_description", "certified", "tags") + fieldsets[0][1]["fields"] += ("short_description", "certified", "tags", "partner") fieldsets[1][1]["fields"] += ( "members_group", "invitation_token", diff --git a/lacommunaute/forum/factories.py b/lacommunaute/forum/factories.py index d41a9844..cc5f1713 100644 --- a/lacommunaute/forum/factories.py +++ b/lacommunaute/forum/factories.py @@ -47,6 +47,14 @@ def with_tags(self, create, extracted, **kwargs): for tag in extracted: self.tags.add(tag) + @factory.post_generation + def with_partner(self, create, extracted, **kwargs): + if not create or not extracted: + return + + self.partner = extracted + self.save() + class CategoryForumFactory(ForumFactory): type = Forum.FORUM_CAT diff --git a/lacommunaute/forum/migrations/0018_forum_partner.py b/lacommunaute/forum/migrations/0018_forum_partner.py new file mode 100644 index 00000000..08f7a6ee --- /dev/null +++ b/lacommunaute/forum/migrations/0018_forum_partner.py @@ -0,0 +1,21 @@ +# Generated by Django 5.0.8 on 2024-08-29 14:34 + +import django.db.models.deletion +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ("forum", "0017_forum_tags"), + ("partner", "0001_initial"), + ] + + operations = [ + migrations.AddField( + model_name="forum", + name="partner", + field=models.ForeignKey( + blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to="partner.partner" + ), + ), + ] diff --git a/lacommunaute/forum/models.py b/lacommunaute/forum/models.py index fdf68e52..d7f49257 100644 --- a/lacommunaute/forum/models.py +++ b/lacommunaute/forum/models.py @@ -14,6 +14,7 @@ from lacommunaute.forum.enums import Kind as Forum_Kind from lacommunaute.forum_conversation.models import Topic from lacommunaute.forum_upvote.models import UpVote +from lacommunaute.partner.models import Partner from lacommunaute.utils.validators import validate_image_size @@ -42,6 +43,7 @@ class Forum(AbstractForum): upvotes = GenericRelation(UpVote, related_query_name="forum") tags = TaggableManager() + partner = models.ForeignKey(Partner, on_delete=models.CASCADE, null=True, blank=True) objects = ForumQuerySet().as_manager() diff --git a/lacommunaute/partner/tests/__snapshots__/tests_partner_detailview.ambr b/lacommunaute/partner/tests/__snapshots__/tests_partner_detailview.ambr index dc69dc2d..81c35935 100644 --- a/lacommunaute/partner/tests/__snapshots__/tests_partner_detailview.ambr +++ b/lacommunaute/partner/tests/__snapshots__/tests_partner_detailview.ambr @@ -2,11 +2,11 @@ # name: test_partner_detailview[-partner_detailview as anonymous][partner_detailview as anonymous] '''
- - - - - + + + + +
- - - - + + + +
- + Best Partner Ever - +

Best Partner Ever

- +

short description for SEO

@@ -42,30 +42,30 @@

h3 long MD description

- +

lorem ipsum dolor sit amet, consectetur adipiscing elit.

- + - +
- - + +
''' # --- # name: test_partner_detailview[-partner_detailview as superuser][partner_detailview as superuser] '''
- - - - - + + + + +
- - - - + + + +
- + Best Partner Ever - +

Best Partner Ever

- + Mettre à jour - +

short description for SEO

@@ -103,30 +103,30 @@

h3 long MD description

- +

lorem ipsum dolor sit amet, consectetur adipiscing elit.

- + - +
- - + +
''' # --- # name: test_partner_detailview[-partner_detailview][partner_detailview] '''
- - - - - + + + + +
- - - - + + + +
- + Best Partner Ever - +

Best Partner Ever

- +

short description for SEO

@@ -162,19 +162,19 @@

h3 long MD description

- +

lorem ipsum dolor sit amet, consectetur adipiscing elit.

- + - +
- - + +
''' # --- diff --git a/lacommunaute/partner/tests/__snapshots__/tests_partner_listview.ambr b/lacommunaute/partner/tests/__snapshots__/tests_partner_listview.ambr index 410821c1..24a86816 100644 --- a/lacommunaute/partner/tests/__snapshots__/tests_partner_listview.ambr +++ b/lacommunaute/partner/tests/__snapshots__/tests_partner_listview.ambr @@ -6,12 +6,12 @@
- +
- +
- +
@@ -38,21 +38,21 @@
  • - - + +
  • 1
  • - - - - - + + + + +
  • 2
  • - - + +