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