]> git.lizzy.rs Git - cheatdb.git/blob - app/templates/macros/threads.html
Add ability to edit comments
[cheatdb.git] / app / templates / macros / threads.html
1 {% macro render_thread(thread, current_user) -%}
2
3 <ul class="comments mt-4 mb-0">
4         {% for r in thread.replies %}
5         <li class="row my-2 mx-0">
6                 <div class="col-md-1 p-1">
7                         <a href="{{ url_for('users.profile', username=r.author.username) }}">
8                                 <img class="img-responsive user-photo img-thumbnail img-thumbnail-1" src="{{ r.author.getProfilePicURL() }}">
9                         </a>
10                 </div>
11                 <div class="col pr-0">
12                         <div class="card">
13                                 <div class="card-header">
14                                         <a class="author {{ r.author.rank.name }}"
15                                                         href="{{ url_for('users.profile', username=r.author.username) }}">
16                                                 {{ r.author.display_name }}
17                                         </a>
18                                         <a name="reply-{{ r.id }}" class="text-muted float-right"
19                                                         href="{{ url_for('threads.view', id=thread.id) }}#reply-{{ r.id }}">
20                                                 {{ r.created_at | datetime }}
21                                         </a>
22                                 </div>
23
24                                 <div class="card-body">
25                                         {% if current_user == thread.author and thread.review and thread.replies[0] == r %}
26                                                 <a class="float-right btn btn-primary btn-sm ml-2"
27                                                                 href="{{ thread.review.package.getReviewURL() }}">
28                                                         <i class="fas fa-edit"></i>
29                                                 </a>
30                                         {% elif r.checkPerm(current_user, "EDIT_REPLY") %}
31                                                 <a class="float-right btn btn-primary btn-sm ml-2"
32                                                                 href="{{ url_for('threads.edit_reply', id=thread.id, reply=r.id) }}">
33                                                         <i class="fas fa-edit"></i>
34                                                 </a>
35                                         {% endif %}
36
37                                         {% if r.checkPerm(current_user, "DELETE_REPLY") %}
38                                                 <a class="float-right btn btn-secondary btn-sm ml-2"
39                                                                 href="{{ url_for('threads.delete_reply', id=thread.id, reply=r.id) }}">
40                                                         <i class="fas fa-trash"></i>
41                                                 </a>
42                                         {% endif %}
43
44                                         {{ r.comment | markdown }}
45                                 </div>
46                         </div>
47                 </div>
48         </li>
49         {% endfor %}
50 </ul>
51
52 {% if thread.locked %}
53         <p class="my-0 py-4 text-center">
54                 <i class="fas fa-lock mr-3"></i>
55                 {{ _("This thread has been locked by a moderator.") }}
56         </p>
57 {% endif %}
58
59 {% if current_user.is_authenticated %}
60 <div class="row mt-0 mb-4 comments mx-0">
61         <div class="col-md-1 p-1">
62                 <img class="img-responsive user-photo img-thumbnail img-thumbnail-1" src="{{ current_user.getProfilePicURL() }}">
63         </div>
64         <div class="col">
65                 <div class="card">
66                         <div class="card-header {{ current_user.rank.name }}">
67                                 {{ current_user.display_name }}
68                                 <a name="reply"></a>
69                         </div>
70
71                         {% if not current_user.canCommentRL() %}
72                                 <div class="card-body">
73                                         <textarea class="form-control" readonly disabled>{{ _("Please wait before commenting again.") }}</textarea><br />
74                                         <input class="btn btn-primary" type="submit" disabled value="Comment" />
75                                 </div>
76                         {% elif not thread.checkPerm(current_user, "COMMENT_THREAD") %}
77                                 <div class="card-body">
78                                         {% if thread.locked %}
79                                                 <textarea class="form-control" readonly disabled>{{ _("This thread has been locked.") }}</textarea><br />
80                                         {% else %}
81                                                 <textarea class="form-control" readonly disabled>{{ _("You don't have permission to post.") }}</textarea><br />
82                                         {% endif %}
83                                         <input class="btn btn-primary" type="submit" disabled value="Comment" />
84                                 </div>
85                         {% else %}
86                                 <form method="post" action="{{ url_for('threads.view', id=thread.id)}}" class="card-body">
87                                         <input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
88                                         <textarea class="form-control markdown" required maxlength=500 name="comment"></textarea><br />
89                                         <input class="btn btn-primary" type="submit" value="Comment" />
90                                 </form>
91                         {% endif %}
92                 </div>
93         </div>
94 </div>
95 {% endif %}
96 {% endmacro %}
97
98 {% macro render_threadlist(threads, compact=False) -%}
99         {% for t in threads %}
100                 <a class="list-group-item list-group-item-action"
101                                 href="{{ url_for('threads.view', id=t.id) }}">
102                         {% if compact %}
103                                 {% if t.private %}&#x1f512; {% endif %}
104                                 <strong>{{ t.title }}</strong>
105                                 by {{ t.author.display_name }}
106                         {% else %}
107                                 <div class="row">
108                                         <div class="col-sm">
109                                                 <span class="mr-3">
110                                                         {% if not t.review and t.private %}
111                                                                 <i class="fas fa-lock" style="color:#ffac33;"></i>
112                                                         {% elif not t.review %}
113                                                                 <i class="fas fa-comment-alt" style="color:#666;"></i>
114                                                         {% elif t.review.recommends %}
115                                                                 <i class="fas fa-thumbs-up" style="color:#6f6;"></i>
116                                                         {% else %}
117                                                                 <i class="fas fa-thumbs-down" style="color:#f66;"></i>
118                                                         {% endif %}
119                                                 </span>
120
121                                                 <strong>{{ t.title }}</strong>
122                                                 by {{ t.author.display_name }}
123                                         </div>
124
125                                         <div class="col-sm">
126                                                 {% if t.package %}
127                                                         {{ _("%(title)s by %(author)s",
128                                                                         title="<b>" | safe + t.package.title + "</b>" | safe,
129                                                                         author=t.package.author.display_name) }}
130                                                 {% endif %}
131                                         </div>
132
133                                         <div class="col-sm-auto text-muted text-right">
134                                                 {{ t.created_at | datetime }}
135                                         </div>
136                                 </div>
137                         {% endif %}
138                 </a>
139         {% else %}
140                 <p class="list-group-item"><i>No threads found</i></p>
141         {% endfor %}
142 {% endmacro %}