Skip to content

Commit

Permalink
Display author choices in post edit and create only if user is in at …
Browse files Browse the repository at this point in the history
…least one club
  • Loading branch information
Ludovic Druette committed Apr 3, 2022
1 parent f7af20b commit 5fa5fff
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 5 additions & 3 deletions back/news/templates/news/post_edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@ <h3 class="page-title">{% if Edit %}Éditer{% else %}Créer{% endif %} un post</
{% csrf_token %}
<div class="news-card-content">
<div class="centered-div">
{{EditPost.club.errors}}
<div class="input-title">Publier en tant que :</div>
{{EditPost.club}}
{% if IsInClub %}
{{EditPost.club.errors}}
<div class="input-title">Publier en tant que :</div>
{{EditPost.club}}
{% endif %}

{{EditPost.event.errors}}
<div class="input-title">Est-ce que ce post est associé à un évènement ?</div>
Expand Down
2 changes: 2 additions & 0 deletions back/news/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ def post_edit(request, post_id):
else:
form = EditPost(request.user.id, instance=post)
context["EditPost"] = form
context["IsInClub"] = len(form.fields["club"].choices) > 1
context["post"] = post
context["Edit"] = True
request.session["origin"] = request.META.get("HTTP_REFERER", "news:posts")
Expand Down Expand Up @@ -196,6 +197,7 @@ def post_create(request, event_id=None):
form.fields["event"].initial = get_object_or_404(Event, id=event_id)
request.session["origin"] = request.META.get("HTTP_REFERER", "news:posts")
context["EditPost"] = form
context["IsInClub"] = len(form.fields["club"].choices) > 1
context["Edit"] = False
return render(request, "news/post_edit.html", context)

Expand Down

0 comments on commit 5fa5fff

Please sign in to comment.