Skip to content

Commit

Permalink
feat(partner): add app
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentporte committed Sep 3, 2024
1 parent 90506a0 commit 081adeb
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 67 deletions.
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", "tags")
fieldsets[0][1]["fields"] += ("short_description", "certified", "tags", "partner")
fieldsets[1][1]["fields"] += (
"members_group",
"invitation_token",
Expand Down
8 changes: 8 additions & 0 deletions lacommunaute/forum/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 21 additions & 0 deletions lacommunaute/forum/migrations/0018_forum_partner.py
Original file line number Diff line number Diff line change
@@ -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"
),
),
]
2 changes: 2 additions & 0 deletions lacommunaute/forum/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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()

Expand Down
104 changes: 52 additions & 52 deletions lacommunaute/partner/tests/__snapshots__/tests_partner_detailview.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
# name: test_partner_detailview[<lambda>-partner_detailview as anonymous][partner_detailview as anonymous]
'''
<main class="s-main" id="main" role="main">





<div class="container">
<nav aria-label="Fil d'ariane" class="c-breadcrumb">
<ol class="breadcrumb">
Expand All @@ -17,21 +17,21 @@
</ol>
</nav>
</div>




<section class="s-title-01 mt-lg-5">
<div class="s-title-01__container container">
<div class="s-title-01__row row">
<div class="s-title-01__col col-12">
<div class="d-flex gap-3 align-items-center mb-2">

<img alt="Best Partner Ever" class="img-fluid" src="[img src]" width="200"/>

<h1 class="mb-0">Best Partner Ever</h1>
</div>

<h2 class="mt-3">short description for SEO</h2>
</div>
</div>
Expand All @@ -42,30 +42,30 @@
<div class="s-section__row row">
<div class="col-12">
<article class="textarea_cms_md"><h3>h3 long MD description</h3>

<p>lorem ipsum dolor sit amet, consectetur adipiscing elit.</p></article>

<div class="mt-3">
<a class="has-external-link" href="https://www.best-partner-ever.com" rel="noopener noreferrer" target="_blank">https://www.best-partner-ever.com</a>
</div>

</div>
</div>
</div>
</section>


</main>
'''
# ---
# name: test_partner_detailview[<lambda>-partner_detailview as superuser][partner_detailview as superuser]
'''
<main class="s-main" id="main" role="main">





<div class="container">
<nav aria-label="Fil d'ariane" class="c-breadcrumb">
<ol class="breadcrumb">
Expand All @@ -76,23 +76,23 @@
</ol>
</nav>
</div>




<section class="s-title-01 mt-lg-5">
<div class="s-title-01__container container">
<div class="s-title-01__row row">
<div class="s-title-01__col col-12">
<div class="d-flex gap-3 align-items-center mb-2">

<img alt="Best Partner Ever" class="img-fluid" src="[img src]" width="200"/>

<h1 class="mb-0">Best Partner Ever</h1>
</div>

<a href="/admin/partner/partner/[PK of Partner]/change/"><small>Mettre à jour</small></a>

<h2 class="mt-3">short description for SEO</h2>
</div>
</div>
Expand All @@ -103,30 +103,30 @@
<div class="s-section__row row">
<div class="col-12">
<article class="textarea_cms_md"><h3>h3 long MD description</h3>

<p>lorem ipsum dolor sit amet, consectetur adipiscing elit.</p></article>

<div class="mt-3">
<a class="has-external-link" href="https://www.best-partner-ever.com" rel="noopener noreferrer" target="_blank">https://www.best-partner-ever.com</a>
</div>

</div>
</div>
</div>
</section>


</main>
'''
# ---
# name: test_partner_detailview[<lambda>-partner_detailview][partner_detailview]
'''
<main class="s-main" id="main" role="main">





<div class="container">
<nav aria-label="Fil d'ariane" class="c-breadcrumb">
<ol class="breadcrumb">
Expand All @@ -137,21 +137,21 @@
</ol>
</nav>
</div>




<section class="s-title-01 mt-lg-5">
<div class="s-title-01__container container">
<div class="s-title-01__row row">
<div class="s-title-01__col col-12">
<div class="d-flex gap-3 align-items-center mb-2">

<img alt="Best Partner Ever" class="img-fluid" src="[img src]" width="200"/>

<h1 class="mb-0">Best Partner Ever</h1>
</div>

<h2 class="mt-3">short description for SEO</h2>
</div>
</div>
Expand All @@ -162,19 +162,19 @@
<div class="s-section__row row">
<div class="col-12">
<article class="textarea_cms_md"><h3>h3 long MD description</h3>

<p>lorem ipsum dolor sit amet, consectetur adipiscing elit.</p></article>

<div class="mt-3">
<a class="has-external-link" href="https://www.best-partner-ever.com" rel="noopener noreferrer" target="_blank">https://www.best-partner-ever.com</a>
</div>

</div>
</div>
</div>
</section>


</main>
'''
# ---
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
<div class="s-section__row row">
<div class="s-section__col col-12">
<div class="row row-cols-1 row-cols-sm-2 row-cols-lg-3 row-cols-xl-4">

<div class="col mb-3 mb-md-5">
<div class="card c-card has-one-link-inside h-100">

<img alt="Best Partner Ever" class="card-img-top" loading="lazy" src="[img src]"/>

<div class="card-body pb-0">
<p class="h3 lh-base">Best Partner Ever</p>
<div class="card-text">short description for SEO</div>
Expand All @@ -23,9 +23,9 @@
</div>
</div>
</div>

</div>

</div>
</div>
</div>
Expand All @@ -38,21 +38,21 @@
<li class="page-item disabled">
<a aria-label="Précédent" class="page-link" href=""><i class="ri-arrow-left-s-line"></i></a>
</li>


<li class="page-item active">
<a class="page-link" href="/partners/?page=1">1</a>
</li>





<li class="page-item">
<a class="page-link" href="/partners/?page=2">2</a>
</li>


<li class="page-item">
<a aria-label="Suivant" class="page-link" href="/partners/?page=2"><i class="ri-arrow-right-s-line"></i></a>
</li>
Expand Down

0 comments on commit 081adeb

Please sign in to comment.