]> git.openstreetmap.org Git - osqa.git/blob - forum/skins/default/templates/question.html
Migrate to Django 1.6
[osqa.git] / forum / skins / default / templates / question.html
1 {% extends "base.html" %}
2 <!-- question.html -->
3 {% load node_tags %}
4 {% load extra_tags %}
5 {% load extra_filters %}
6 {% load general_sidebar_tags %}
7 {% load smart_if %}
8 {% load humanize %}
9 {% load i18n %}
10 {% load cache %}
11 {% block metadescription %}{{ question.meta_description }}{% endblock %}
12 {% block metakeywords %}{{question.tagname_meta_generator}}{% endblock %}
13 {% block meta %}
14         <link rel="canonical" href="{{settings.APP_BASE_URL}}{{question.get_absolute_url}}" />
15         <link rel="alternate" type="application/rss+xml" title="RSS" href="{{ question.get_absolute_url }}?type=rss">
16 {% endblock %}
17 {% block title %}{% spaceless %}{{ question.headline }}{% endspaceless %}{% endblock %}
18 {% block forejs %}
19         {% if not question.nis.closed %}
20         <script type='text/javascript' src='{% media  "/media/js/osqa.question.js" %}'></script>
21         <script type='text/javascript' src='{% media  "/media/js/jquery.caret.js" %}'></script>
22         <script type='text/javascript' src='{% media  "/media/js/wmd/showdown.js" %}'></script>
23         <script type='text/javascript' src='{% media  "/media/js/wmd/wmd.js" %}'></script>
24         <script type='text/javascript' src='{% media  "/media/js/html_sanitizer.js" %}'></script>
25         <link rel="stylesheet" type="text/css" href="{% media  "/media/js/wmd/wmd.css" %}" />
26
27         {% if embed_youtube_videos %}
28         <script type='text/javascript' src='{% media  "/media/js/viewbox_min.js" %}'></script>
29         <script type='text/javascript' src='{% media  "/media/js/youtube.js" %}'></script>
30         <link rel="stylesheet" type="text/css" href="{% media  "/media/js/viewbox.css" %}" />
31         {% endif %}
32         {% endif %}
33
34         <script type="text/javascript">
35         $().ready(function(){
36             $("#nav_questions").attr('className',"on");
37             var answer_sort_tab = "{{ tab_id }}";
38
39             if (answer_sort_tab) {
40                 $("#" + answer_sort_tab).attr('className',"on");
41             }
42
43             $('#editor').TextAreaResizer();
44
45             //toggle preview of editor
46             var display = true;
47             var txt = "[{% trans "hide preview" %}]";
48             $('#pre-collapse').text(txt);
49             $('#pre-collapse').bind('click', function(){
50                 txt = display ? "[{% trans "show preview" %}]" : "[{% trans "hide preview" %}]";
51                 display = !display;
52                 $('#previewer').toggle();
53                 $('#pre-collapse').text(txt);
54             });
55         });
56
57         function submitClicked(e, f) {
58             if(!(browserTester('chrome') || browserTester('safari'))) {
59                 $("input.submit")[0].disabled=true;
60             }
61             window.removeEventListener('beforeunload', beforeUnload, true);
62             if (f) {
63                 f.submit();
64             }
65         }
66
67         function beforeUnload(e) {
68
69             if($("textarea#editor")[0].value != "") {
70                 return yourWorkWillBeLost(e);
71             }
72
73             var commentBoxes = $("textarea.commentBox");
74             for(var index = 0; index < commentBoxes.length; index++) {
75                 if(commentBoxes[index].value != "") {
76                     return yourWorkWillBeLost(e);
77                 }
78             }
79         }
80         window.addEventListener('beforeunload', beforeUnload, true);
81         </script>
82         <noscript>
83             <style>
84                 .comment.not_top_scorer {
85                     display: block;
86                 }
87                 .comment-form-container {
88                     display: block;
89                 }
90                 .div.comment-tools {
91                     display: none;
92                 }
93             </style>
94         </noscript>
95 {% endblock %}
96
97 {% block content %}
98 <div class="headNormal">
99     <h1><a href="{{ question.get_absolute_url }}">{{ question.headline }}</a></h1>
100 </div>
101 <div id="main-body" class="">
102     <div id="askform">
103             <table style="width:100%;" id="question-table" {% post_classes question %}>
104                 <tr>
105                     <td style="width:30px;vertical-align:top">
106                         <div class="vote-buttons">
107                             {% vote_buttons question request.user %}
108                             {% favorite_mark question request.user %}
109                         </div>
110                     </td>
111                     <td>
112                         <div id="item-right">
113                             <div class="question-body">
114                                 {{ question.html|safe }}
115                             </div>
116                             <div id="question-tags" class="tags-container tags">
117                                 {% for tag in question.tagname_list %}
118                                     <a href="{% url "tag_questions" tag|urlencode %}" class="post-tag tag-link-{{ tag }}"
119                                         title="{% blocktrans with tag as tagname %}see questions tagged '{{ tagname }}'{% endblocktrans %}" rel="tag">{{ tag }}</a>
120                                 {% endfor %}
121                             </div>
122                             <div id="question-controls" class="post-controls">
123                                 {% post_controls question request.user %}
124                                 {% wiki_symbol request.user question %}
125                             </div>
126                             <div class="post-update-info-container">
127                                     {% contributors_info question %}
128                             </div>
129                             {% comments question request.user %}
130                         </div>
131
132                     </td>
133                 </tr>
134             </table>
135             {% if question.nis.closed %}
136             <div class="question-status" style="margin-bottom:15px">
137             <h3>
138                 {% blocktrans with question.nstate.closed.extra as close_reason %}The question has been closed for the following reason "{{ close_reason }}" by{% endblocktrans %}
139                 <a href="{{ question.nstate.closed.by.get_profile_url }}">{{ question.nstate.closed.by.username }}</a>
140                  {% diff_date question.nstate.closed.at %}
141             </h3>
142             </div>
143             {% endif %}
144             {% if answers %}
145                 <hr/>
146                 <div class="tabBar">
147                     <a name="sort-top"></a>
148                     <div class="headQuestions">
149                     {% blocktrans count answers.paginator.count as counter %}One Answer:{% plural %}{{counter}} Answers:{% endblocktrans %}
150                     </div>
151                     {{ answers.paginator.sort_tabs }}
152                 </div>
153                 {{ answers.paginator.page_numbers }}
154
155                 {% for answer in answers.paginator.page %}
156                     <a name="{{ answer.id }}"></a>
157                     <div id="answer-container-{{ answer.id }}" class="answer {% post_classes answer %}{% ifequal answer.id focused_answer_id %} focusedAnswer{% endifequal %}">
158                         <table style="width:100%;">
159                             <tr>
160                                 <td style="width:30px;vertical-align:top">
161                                     <div class="vote-buttons">
162                                         {% vote_buttons answer request.user %}
163                                         {% accept_button answer request.user %}
164                                     </div>
165                                 </td>
166                                 <td>
167                                     <div class="item-right">
168                                         <div class="answer-body">
169                                             {{ answer.html|safe }}
170                                         </div>
171                                         <div class="answer-controls post-controls">
172                                             {% post_controls answer request.user %}
173                                             {% wiki_symbol request.user answer %}
174                                         </div>
175                                         <div class="post-update-info-container">
176                                             {% contributors_info answer %}
177                                         </div>
178                                         {% comments answer request.user %}
179                                     </div>
180                                 </td>
181                             </tr>
182                         </table>
183                     </div>
184                 {% endfor %}
185                 <div class="paginator-container-left">
186                     {{ answers.paginator.page_numbers }}
187                 </div>
188             {% endif %}
189         <form id="fmanswer" action="{% url "answer" question.id %}" method="post">
190             {% csrf_token %}
191             <div style="clear:both">
192             </div>
193
194             {% if not question.closed %}
195                 <div style="padding:10px 0 0 0;">
196                     {% spaceless %}
197                     <div class="headNormal">
198                         {% if answers %}
199                             {% trans "Your answer" %}
200                         {% else %}
201                             {% trans "Be the first one to answer this question!" %}
202                         {% endif %}
203                     </div>
204                     {% endspaceless %}
205                 </div>
206                 {% comment %}
207                 {% if not request.user.is_authenticated %}
208                     <div class="message">{% trans "You can answer anonymously and then login." %}</div>
209                 {% else %}
210                     <p class="message">
211                         {% ifequal request.user question.author  %}
212                             {% trans "Answer your own question only to give an answer." %}
213                         {% else %}
214                             {% trans "Please only give an answer, no discussions." %}
215                         {% endifequal %}
216                         {% if not request.user.email_valid_and_can_answer %}
217                             {% blocktrans %}Remember, your answer will not be published until you validate your email.{% endblocktrans %}
218                             <a href="{% url "send_validation_email" %}">{% trans "Send me a validation link." %}</a>
219                         {% endif %}
220                     </p>
221                 {% endif %}
222                 {% endcomment %}
223
224                 <div id="description" class="" >
225                     <div id="wmd-button-bar" class="wmd-panel"></div>
226                     {{ answer.text }}
227                     <div class="preview-toggle">
228                         <table width="100%">
229                             <tr>
230                                 <td>
231                                     <span id="pre-collapse" 
232                                         title="{% trans "Toggle the real time Markdown editor preview" %}">
233                                             {% trans "toggle preview" %}
234                                     </span>
235                                 </td>
236                                 <td style="text-align: right;" id="editor-metrics"></td>
237                                 {% if settings.WIKI_ON %}
238                                 <td style="text-align:right;">
239                                     {{ answer.wiki }} 
240                                     <span style="font-weight:normal;cursor:help" 
241                                         title="{{answer.wiki.help_text}}">
242                                             {{ answer.wiki.label_tag }} 
243                                     </span>
244                                 </td>
245                                 {% endif %}
246                             </tr>
247
248                         </table>
249                     </div>
250                     {{ answer.text.errors }}
251                     <div id="previewer" class="wmd-preview"></div>
252                 </div>
253
254                 {% if answer.recaptcha %}
255                 <div class="question-captcha" style="float: left;">
256                     {{ answer.recaptcha.errors }}
257                     {{ answer.recaptcha }}
258                 </div>
259                 <div class="clear"></div>
260                 {% endif %}
261
262                 <p><span class="form-error"></span></p>
263                 <input type="button"
264                     {% if user.is_anonymous %}
265                         value="{% trans "Login/Signup to Post Your Answer" %}" 
266                     {% else %}
267                         {% if user == question.author %}
268                         value="{% trans "Answer Your Own Question" %}" 
269                         {% else %}
270                         value="{% trans "Answer the question" %}" 
271                         {% endif %}
272                     {% endif %}
273                     class="submit" style="float:left" onclick="submitClicked(event, this.form)"/>
274             {% endif %}
275         </form>
276     </div>
277 </div>
278 {% endblock %}
279
280 {% block sidebar %}
281 <div class="boxC" id="subscription_box">
282     {% include "subscription_status.html" %}
283 </div>
284
285 {% markdown_help %}
286
287 {% sidebar_upper %}
288
289 {% cache 60 questions_tags settings.APP_URL question.id %}
290 <div class="boxC">
291     <p>
292         {% trans "Question tags" %}:
293     </p>
294     <p class="tags" >
295         {% for tag in question.tags.all %}
296         <a href="{% url "tag_questions" tag.name|urlencode %}"
297             class="tag-link-{{ tag.name }}"
298             title="{% trans "see questions tagged"%}'{{tag.name}}'{% trans "using tags" %}"
299             rel="tag">{{ tag.name }}</a> <span class="tag-number">&#215;{{ tag.used_count|intcomma }}</span><br/>
300         {% endfor %}
301     </p>
302     <p>
303         {% trans "question asked" %}: <strong title="{{ question.added_at }}">{% diff_date question.added_at %}</strong>
304     </p>
305     <p> 
306         {% trans "question was seen" %}: <strong>{{ question.view_count|intcomma }} {% trans "times" %}</strong>
307     </p>
308     <p> 
309         {% trans "last updated" %}: <strong title="{{ question.last_activity_at }}">{% diff_date question.last_activity_at %}</strong>
310     </p>
311 </div>
312 {% endcache %}
313 {% sidebar_lower %}
314 <div class="boxC">
315     <h3 class="subtitle">{% trans "Related questions" %}</h3>
316     <div class="questions-related">
317
318         {% for question in similar_questions %}
319         <p>
320             <a href="{{ question.get_absolute_url }}">{{ question.headline }}</a>
321         </p>
322         {% endfor %}
323
324     </div>
325 </div>
326
327 {% endblock %}
328
329 {% block endjs %}
330 {% endblock %}
331 <!-- end question.html -->