-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(article): can edit & delete comments
Close #282
- Loading branch information
Showing
7 changed files
with
197 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,40 @@ | ||
{% load i18n %} | ||
{% load i18n crispy_forms_tags partials %} | ||
|
||
<div id="comment-{{ comment.id }}" class="card mt-2"> | ||
<div class="card-body"> | ||
<p class="lead"> | ||
{% partialdef comment-card %} | ||
<div class="card mt-2" hx-target="this" hx-swap="outerHTML"> | ||
<div class="card-header"> | ||
{% blocktranslate with comment_date=comment.created_at|date:"SHORT_DATETIME_FORMAT" %} | ||
You commented on {{ comment_date }} | ||
{% endblocktranslate %} | ||
</p> | ||
<div class="card-text">{{ comment.text|markdown }}</div> | ||
You commented on {{ comment_date }} | ||
{% endblocktranslate %} | ||
</div> | ||
<div class="card-body"> | ||
<div class="card-text">{{ comment.text|markdown }}</div> | ||
</div> | ||
<div class="card-footer"> | ||
<button class="btn btn-sm btn-primary" | ||
type="button" | ||
hx-get="{% url 'reading:edit_comment' pk=comment.id %}">{% translate "Edit" %}</button> | ||
<form class="d-inline" | ||
data-modal-id="danger-modal" | ||
data-modal-title="{% translate 'Confirm deletion' %}" | ||
data-modal-body="{% translate 'Do you really want to delete this comment?' %}" | ||
hx-post="{% url 'reading:delete_comment' pk=comment.id %}" | ||
hx-confirm="Delete?"> | ||
{% csrf_token %} | ||
<button class="btn btn-sm btn-danger">{% translate "Delete" %}</button> | ||
</form> | ||
</div> | ||
</div> | ||
</div> | ||
{% endpartialdef %} | ||
{% partialdef edit-comment-form %} | ||
<form hx-post="{% url 'reading:edit_comment' pk=comment.id %}" | ||
hx-target="this" | ||
hx-swap="outerHTML"> | ||
{% csrf_token %} | ||
{{ comment_article_form|crispy }} | ||
<button class="btn btn-sm btn-outline-primary" type="submit">{% translate "Save" %}</button> | ||
<button class="btn btn-sm btn-outline-danger" | ||
type="button" | ||
hx-get="{% url 'reading:display_comment' pk=comment.id %}">{% translate "Cancel" %}</button> | ||
</form> | ||
{% endpartialdef %} |