Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better author choice #88

Merged
merged 5 commits into from
May 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ repos:
rev: 21.12b0
hooks:
- id: black
additional_dependencies: ["click<8.1.0"]
args:
- --line-length=88
- repo: https://github.com/pycqa/isort
Expand Down
10 changes: 7 additions & 3 deletions back/news/templates/news/event_edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,18 @@ <h3 class="page-title">{% if Edit %}Éditer{% else %}Créer{% endif %} un event<

{{EditEvent.club.errors}}
<div class="input-title">Club :</div>
{{EditEvent.club}}
{% if EditEvent.club|length > 1 %}
{{EditEvent.club}}
{% else %}
{{EditEvent.club|first|default:"Vous n'êtes membre d'aucun club"}}
{% endif %}

{{EditEvent.shotgun.errors}}
<div class="input-title">Shotgun :</div>
{{EditEvent.shotgun}}
</div>
</div>
{%if event.poster%}
{% if event.poster %}
<div class="news-card-images">
<!--All-Images-Linked-With-The-Event-->
<div class="news-card-carousel">
Expand All @@ -71,7 +75,7 @@ <h3 class="page-title">{% if Edit %}Éditer{% else %}Créer{% endif %} un event<
</div>
</div>
</div>
{%endif%}
{% endif %}
<div class="centered-div">
<a href="{% if event %}{% url 'news:event_detail' event.id %}{% else %}{% url 'news:events' %}{% endif %}"><button type="button" class="button red-button">Annuler</button></a>
<button class="button green-button" type="submit" name="Valider">Valider</button>
Expand Down
6 changes: 4 additions & 2 deletions back/news/templates/news/post_edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ <h3 class="page-title">{% if Edit %}Éditer{% else %}Créer{% endif %} un post</
<div class="news-card-content">
<div class="centered-div">
{{EditPost.club.errors}}
<div class="input-title">Publier en tant que :</div>
{{EditPost.club}}
{% if EditPost.club|length > 1 %}
<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
42 changes: 29 additions & 13 deletions react/src/components/commentForm.jsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import React from 'react';
import {getCookie} from '/src/csrf'


function timeout(delay) {
return new Promise(res => setTimeout(res, delay));
}


class CommentForm extends React.Component {
constructor(props) {
super(props);
Expand Down Expand Up @@ -64,28 +62,46 @@ class CommentForm extends React.Component {
options.push(<option key={key} value={key}>{value}</option>);
}
}
let field1, field2;
field1 =

const field1 =
<div className="news-card-edit-comment">
<div className="news-card-comment-user-pic"><img src={this.props.currentStudent.picture_url}></img></div>
<textarea className="news-card-edit-comment-input" type="text" name="content" id="" value={this.state.content} onChange={this.handleChange}></textarea>
</div>
field2 =
<div className="news-card-edit-comment">
<select className="profil-select" name="club" id="id_club" required value={this.state.club} onChange={this.handleChange}>
{options}
</select>
<button className="button green-button news-card-button" type="submit"><i className="far fa-comment"></i></button>
</div>

return (

if (options.length > 1) {
// The user is member of at least one club, he/she can choose to comment as a club
const field2 =
<div className="news-card-edit-comment">
<select className="profil-select" name="club" id="id_club" required value={this.state.club} onChange={this.handleChange}>
{options}
</select>
<button className="button green-button news-card-button" type="submit"><i className="far fa-comment"></i></button>
</div>

return (
<form method="post" onSubmit={this.handleSubmit.bind(this)}>
{field1}
Publier en tant que :
{field2}
<input type="hidden" name="post" value={this.state.post.id}></input>
</form>
);
);
} else {
const field2 =
<div className="news-card-edit-comment">
<button className="button green-button news-card-button" type="submit"><i className="far fa-comment"></i></button>
</div>

return (
<form method="post" onSubmit={this.handleSubmit.bind(this)}>
{field1}
{field2}
<input type="hidden" name="post" value={this.state.post.id}></input>
</form>
);
}
}
}

Expand Down