]> git.lizzy.rs Git - cheatdb.git/blobdiff - app/templates/macros/threads.html
Add ability to edit comments
[cheatdb.git] / app / templates / macros / threads.html
index 5c3421ad0297d29ced6683b155878ba5d2d4f5f2..21283d794c67c1420fd1208c1ec9f32fca8a2d40 100644 (file)
@@ -8,7 +8,7 @@
                                <img class="img-responsive user-photo img-thumbnail img-thumbnail-1" src="{{ r.author.getProfilePicURL() }}">
                        </a>
                </div>
-               <div class="col">
+               <div class="col pr-0">
                        <div class="card">
                                <div class="card-header">
                                        <a class="author {{ r.author.rank.name }}"
                                </div>
 
                                <div class="card-body">
+                                       {% if current_user == thread.author and thread.review and thread.replies[0] == r %}
+                                               <a class="float-right btn btn-primary btn-sm ml-2"
+                                                               href="{{ thread.review.package.getReviewURL() }}">
+                                                       <i class="fas fa-edit"></i>
+                                               </a>
+                                       {% elif r.checkPerm(current_user, "EDIT_REPLY") %}
+                                               <a class="float-right btn btn-primary btn-sm ml-2"
+                                                               href="{{ url_for('threads.edit_reply', id=thread.id, reply=r.id) }}">
+                                                       <i class="fas fa-edit"></i>
+                                               </a>
+                                       {% endif %}
+
+                                       {% if r.checkPerm(current_user, "DELETE_REPLY") %}
+                                               <a class="float-right btn btn-secondary btn-sm ml-2"
+                                                               href="{{ url_for('threads.delete_reply', id=thread.id, reply=r.id) }}">
+                                                       <i class="fas fa-trash"></i>
+                                               </a>
+                                       {% endif %}
+
                                        {{ r.comment | markdown }}
                                </div>
                        </div>
        {% endfor %}
 </ul>
 
+{% if thread.locked %}
+       <p class="my-0 py-4 text-center">
+               <i class="fas fa-lock mr-3"></i>
+               {{ _("This thread has been locked by a moderator.") }}
+       </p>
+{% endif %}
+
 {% if current_user.is_authenticated %}
 <div class="row mt-0 mb-4 comments mx-0">
        <div class="col-md-1 p-1">
                                <a name="reply"></a>
                        </div>
 
-                       {% if current_user.canCommentRL() %}
+                       {% if not current_user.canCommentRL() %}
+                               <div class="card-body">
+                                       <textarea class="form-control" readonly disabled>{{ _("Please wait before commenting again.") }}</textarea><br />
+                                       <input class="btn btn-primary" type="submit" disabled value="Comment" />
+                               </div>
+                       {% elif not thread.checkPerm(current_user, "COMMENT_THREAD") %}
+                               <div class="card-body">
+                                       {% if thread.locked %}
+                                               <textarea class="form-control" readonly disabled>{{ _("This thread has been locked.") }}</textarea><br />
+                                       {% else %}
+                                               <textarea class="form-control" readonly disabled>{{ _("You don't have permission to post.") }}</textarea><br />
+                                       {% endif %}
+                                       <input class="btn btn-primary" type="submit" disabled value="Comment" />
+                               </div>
+                       {% else %}
                                <form method="post" action="{{ url_for('threads.view', id=thread.id)}}" class="card-body">
                                        <input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
                                        <textarea class="form-control markdown" required maxlength=500 name="comment"></textarea><br />
                                        <input class="btn btn-primary" type="submit" value="Comment" />
                                </form>
-                       {% else %}
-                               <div class="card-body">
-                                       <textarea class="form-control" readonly disabled>Please wait before commenting again.</textarea><br />
-                                       <input class="btn btn-primary" type="submit" disabled value="Comment" />
-                               </div>
                        {% endif %}
                </div>
        </div>
                                <div class="row">
                                        <div class="col-sm">
                                                <span class="mr-3">
-                                                       {% if not t.review %}
+                                                       {% if not t.review and t.private %}
+                                                               <i class="fas fa-lock" style="color:#ffac33;"></i>
+                                                       {% elif not t.review %}
                                                                <i class="fas fa-comment-alt" style="color:#666;"></i>
                                                        {% elif t.review.recommends %}
                                                                <i class="fas fa-thumbs-up" style="color:#6f6;"></i>
                                                        {% endif %}
                                                </span>
 
-                                               {% if t.private %}&#x1f512; {% endif %}
                                                <strong>{{ t.title }}</strong>
                                                by {{ t.author.display_name }}
                                        </div>
                                                {% endif %}
                                        </div>
 
-                                       <div class="col-sm text-muted text-right">
+                                       <div class="col-sm-auto text-muted text-right">
                                                {{ t.created_at | datetime }}
                                        </div>
                                </div>