|
| 1 | +{# This macro should be imported "with context". #} |
| 2 | + |
| 3 | +{% macro question(msg, user_id) %} |
| 4 | +{# |
| 5 | +Render one question by a participant. |
| 6 | + |
| 7 | +msg (Question): the question object. |
| 8 | +user_id (int|None): if we are rendering a single user's questions, this is the |
| 9 | + user's id. if we are rendering all questions of the contest, then None. |
| 10 | +#} |
| 11 | +<div class="notification communication {{ ("answered" if msg.reply_timestamp is not none else ("ignored" if msg.ignored else "")) }}"> |
| 12 | + <div class="notification_msg"> |
| 13 | + <div class="notification_timestamp"> |
| 14 | + {% if user_id is none %} |
| 15 | + <a href="{{ url("contest", contest.id, "user", msg.participation.user.id, "edit") }}" title="{{ msg.participation.user.first_name }} {{ msg.participation.user.last_name }}">{{ msg.participation.user.username }}</a> — |
| 16 | + {% endif %} |
| 17 | + {{ msg.question_timestamp }} |
| 18 | + </div> |
| 19 | + <div class="notification_subject">{{ msg.subject }}</div> |
| 20 | + <div class="notification_text preserve_line_breaks">{{ msg.text }}</div> |
| 21 | + {% if msg.reply_timestamp is not none %} |
| 22 | + <hr> |
| 23 | + <div class="notification_subject">Reply: {{ msg.reply_subject }}</div> |
| 24 | + <div class="notification_text preserve_line_breaks">{{ msg.reply_text }}</div> |
| 25 | + <hr> |
| 26 | + <div class="notification_admin_owner"> |
| 27 | + Reply from: {{ msg.admin.name if msg.admin is not none else "<unknown>" }}</div> |
| 28 | + {% else %} |
| 29 | + <hr> |
| 30 | + <div class="notification_subject">Not yet replied.</div> |
| 31 | + <hr> |
| 32 | + {% if msg.admin is not none %} |
| 33 | + <div class="notification_admin_owner"> |
| 34 | + {{ "Ignored" if msg.ignored else "Claimed" }} by: {{ msg.admin.name }} |
| 35 | + </div> |
| 36 | + {% endif %} |
| 37 | + {% endif %} |
| 38 | + {% if admin.permission_all or admin.permission_messaging %} |
| 39 | + {% if msg.reply_timestamp is none %} |
| 40 | + {% if not msg.ignored %} |
| 41 | + <div class="claim_reply"> |
| 42 | + <form class="claim_question_form" action="{{ url("contest", contest.id, "question", msg.id, "claim") }}" name="claim{{ msg.id }}" method="POST"> |
| 43 | + {{ xsrf_form_html|safe }} |
| 44 | + {% if user_id is not none %} |
| 45 | + <input type="hidden" name="user_id" value="{{ user_id }}" /> |
| 46 | + {% endif %} |
| 47 | + {% if msg.admin is none %} |
| 48 | + <input type="hidden" name="claim" value="yes"/> |
| 49 | + <a href="javascript:void(0);" onclick="document.claim{{ msg.id }}.submit();">Claim</a> |
| 50 | + {% else %} |
| 51 | + <input type="hidden" name="claim" value="no"/> |
| 52 | + <a href="javascript:void(0);" onclick="document.claim{{ msg.id }}.submit();">Unclaim</a> |
| 53 | + {% endif %} |
| 54 | + </form> |
| 55 | + </div> |
| 56 | + {% endif %} |
| 57 | + <div class="ignore_reply"> |
| 58 | + <form class="ignore_question_form" action="{{ url("contest", contest.id, "question", msg.id, "ignore") }}" name="ignore{{ msg.id }}" method="POST"> |
| 59 | + {{ xsrf_form_html|safe }} |
| 60 | + {% if user_id is not none %} |
| 61 | + <input type="hidden" name="user_id" value="{{ user_id }}" /> |
| 62 | + {% endif %} |
| 63 | + {% if not msg.ignored %} |
| 64 | + <input type="hidden" name="ignore" value="yes"/> |
| 65 | + <a href="javascript:void(0);" onclick="document.ignore{{ msg.id }}.submit();">Ignore</a> |
| 66 | + {% else %} |
| 67 | + <input type="hidden" name="ignore" value="no"/> |
| 68 | + <a href="javascript:void(0);" onclick="document.ignore{{ msg.id }}.submit();">Unignore</a> |
| 69 | + {% endif %} |
| 70 | + </form> |
| 71 | + </div> |
| 72 | + {% endif %} |
| 73 | + <div class="reply_question_toggle"> |
| 74 | + <a href="javascript:void(0);" onclick="utils.question_reply_toggle(event, this);"> |
| 75 | + {% if msg.reply_timestamp is none %} |
| 76 | + Reply |
| 77 | + {% else %} |
| 78 | + Edit reply |
| 79 | + {% endif %} |
| 80 | + </a> |
| 81 | + </div> |
| 82 | + <div class="reply_question"> |
| 83 | + <hr/> |
| 84 | + <form class="reply_question_form" action="{{ url("contest", contest.id, "question", msg.id, "reply") }}" method="POST"> |
| 85 | + {{ xsrf_form_html|safe }} |
| 86 | + {% if user_id is not none %} |
| 87 | + <input type="hidden" name="user_id" value="{{ user_id }}" /> |
| 88 | + {% endif %} |
| 89 | + Precompiled answer: |
| 90 | + <select name="reply_question_quick_answer" onchange="utils.update_additional_answer(event, this);"> |
| 91 | + {% for key, value in question_quick_answers.items() %} |
| 92 | + <option value="{{ key }}">{{ value }}</option> |
| 93 | + {% endfor %} |
| 94 | + <option value="other" selected>Other</option> |
| 95 | + </select> |
| 96 | + <br/> |
| 97 | + <div class="alternative_answer"> |
| 98 | + Alternative answer:<br/> |
| 99 | + <textarea name="reply_question_text"></textarea><br/> |
| 100 | + You can use Markdown here. URLs are not automatically linked, surround them with <> like <http://example.org>. |
| 101 | + </div> |
| 102 | + <input type="submit" value="Send"/> |
| 103 | + </form> |
| 104 | + </div> |
| 105 | +{% endif %} |
| 106 | + </div> |
| 107 | +</div> |
| 108 | +{% endmacro %} |
0 commit comments