summaryrefslogtreecommitdiff
path: root/static/website/templates/get-question.html
blob: ea6bfa3ac4a208691b7b9ab11959922dcd69e4a7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
{% extends 'website/templates/base.html' %}
{% load static %}
{% load widget_tweaks %}

{% load permission_tags %}

{% block title %}
    {{ question.category }} - {{ question.title }} - FOSSEE Forums
{% endblock %}

{% block content %}
 
<span class="saving hideme">saving . . .</span>
<span class="saved hideme">saved</span>

<div class="row">
 
        
                        
    <div class="question-wrapper col-lg-12 col-md-12 col-sm-12 col-xs-12">
    <div class="question {% if user|can_edit:question %}editable{% endif %}">
     <!-- VOTE CELL -->
 		
                
               
                   <div class="votecell" style="padding-top: 0.0cm;">
          		<div class="vote">
                            {% ifequal thisUserUpvote 0 %}
                                <img src="{% static 'website/images/up1-off.png' %}" class="vote-up" title="This question shows research effort; it is useful and clear"/>
                            {% else %}
                                <img src="{% static 'website/images/up1-on.png' %}" class="vote-up selected" title="This question shows research effort; it is useful and clear"/>
                            {% endifequal %}

                            <span class="vote-count-post" id="show_vote_count">
                                {{ net_count }}
                            </span>
                           

                            {% ifequal thisUserDownvote 0 %}
                                <img src="{% static 'website/images/down1-off.png' %}" class="vote-down" title="This question does not show any research effort; it is not useful and unclear"/>
                            {% else %}
                                <img src="{% static 'website/images/down1-on.png' %}" class="vote-down selected" title="This question does not show any research effort; it is not useful and unclear"/>
                            {% endifequal %}
                        </div>
                       
                  </div>
        <div class="title {% if user|can_edit:question %}title-editable{% endif %}">
           {{ question.title }}
        </div>
        
        <div id="title-edit" class="hideme">
        
            
            <h5>Title</h5>
            <input class="form-control" type="text">
            <h5>Question</h5>
        </div>
        
        <div id="questionNicPanel"></div>
        <div id="{% if user|can_edit:question  %}questionInstance{% endif %}" class="body">
            {{ question.body|safe }}
        </div>
        <br>
        
        <span class="category">
            <small>
                <a href="{% url 'website:filter' question.category %}">
                    {{ question.category }}
                </a>
            </small>
        </span>
      
        
        <a id="question-details-edit" data-toggle="modal" data-target="#detailsModal" href="#" class="hideme">
            <span class="glyphicon glyphicon-edit"></span>
        </a>
        
        <span class="modify">
            {% if user|can_edit:question  %}
                <a class="edit btn btn-xs btn-info" href="#">Edit</a>
                <a class="save btn btn-xs btn-success" data-qid="{{ question.id }}" href="#">Save</a>
            {% endif %}
        </span>
        
        <span class="meta">
            <small>
                <i>
                    {{ question.date_created|date:"d-m-y" }}, {{ question.date_created|time }}
                </i>
            </small>
            
            <span class="user">
                {{ question.user }}
            </span>
        </span>
       
    </div> <!-- /.question -->
    </div>
     
</div> <!-- /.row -->


<h4><u>Answers:</u></h4>
<div id="answerPanelWrapper" style="display:none;">
    <div id="answerNicPanel" style="display:none;"></div>
</div>

<div id="commentPanelWrapper" style="display:none;">
    <div id="commentNicPanel" style="display:none;"></div>
</div>


{% for answer in answers %}

<div class="row">
    <div class="answer-wrapper col-lg-12 col-md-12 col-sm-12 col-xs-12">
        <div class="answer {% if user|can_edit:answer  %}editable{% endif %}" id="answer{{answer.id}}">
        	
            <div class="body" id="body{{ answer.id }}">
                {{ answer.body|safe }}
            </div>
            
            <span class="meta">
                <small>
                    <i>
                        {{ answer.date_created|date:"d-m-y" }}, {{ answer.date_created|time }}
                    </i>
                </small>
                
                <span class="user">
                    {{ answer.user }}
                </span>
            </span>
            {% if user|can_edit:answer  %}
            <span class="modify" style="display:block">
                <a class="edit btn btn-xs btn-info vs" href="#body{{ answer.id}}" data-target="body{{ answer.id }}">Edit</a>
                <a class="save btn btn-xs btn-success vs"  data-target="body{{ answer.id }}" data-aid="{{ answer.id }}" href="#">Save</a>
            </span>
            {% endif %}
        </div> <!-- /.answer -->
        
        <div class="row">
            <div class="comments pull-right col-lg-11 col-md-11 col-sm-11 col-xs-11">
                <!-- displaying comments -->
                {% for comment in answer.answercomment_set.all %}
                <div class="comment comment{{ comment.id }}">
                    <div class="body" id="cbody{{ comment.id }}">
                        {{ comment.body|safe }}
                    </div>
                    
                    <span class="meta">
                        <small>
                            <i>
                                {{ comment.date_created|date:"d-m-y" }}, {{ comment.date_created|time }}
                            </i>
                        </small>
                        
                        <span class="user">
                            {{ comment.user }}
                        </span>
                    </span>
                    {% if user|can_edit:comment %}
                    <div class="modify-wrapper">
                        <span class="modify" style="display:block">
                            <a class="edit btn btn-xs btn-info vs" href="#cbody{{ comment.id }}" data-target="cbody{{ comment.id }}">Edit</a>
                            <a class="save btn btn-xs btn-success vs"  data-target="cbody{{ comment.id }}" data-cid="{{ comment.id }}" href="#">Save</a>
                        </span>
                    </div>
                    {% endif %}
                </div> <!-- /.comment -->
                {% endfor %}
                
                
                <!-- form to add comment -->
                {% if user.is_authenticated %}
                 
                <form id="form{{ answer.id }}" method="post" action="/answer-comment/"> {% csrf_token %}
                    <input type="hidden" name="answer_id" value="{{ answer.id }}">
                    <textarea name="body" class="new-comment form-control" id="comment{{ answer.id }}" rows="2"></textarea>
                </form>
                
               
                <a class="add-comment" href="#" data-target="comment{{ answer.id }}">
                    <small>add comment</small>
                </a>
              
                 
                <a class="post-comment" href="#" data-target="comment{{ answer.id }}" data-aid="{{ answer.id }}" data-form="form{{ answer.id }}">
                    <small>post comment</small>
                </a>
                
                <a class="cancel-comment" href="#" data-target="comment{{ answer.id }}">
                    <small>cancel comment</small>
                </a>
               
                {% else %}
                <br>
                <a class="btn btn-xs btn-success vs" href="/accounts/login">
                    Login to add comment
                </a>
                {% endif %}
                 
            </div> <!-- comments -->
        </div> <!-- /.row -->
        <br> <hr>
    </div> <!-- /.answer-wrapper -->
</div> <!-- /.row -->
{% endfor %}

{% if user.is_authenticated %}
    <form action="{% url 'website:question_answer' question.id %}" method="POST"> {% csrf_token %}
        {% with WIDGET_ERROR_CLASS='field_error' %}
            <div class="row"> 
                <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                 {{ form.body.errors }}
                    <div class="form-group">
                        {% render_field form.question value=question.id %}
                        <label for="id_body"><h4><u>Your Answer:</u></h4></label>
                        {% render_field form.body class+='form-control' %}
                    </div>
                   
                </div>
            </div>
            
             
        {% endwith %}
        <input class="btn btn-sm btn-info" type="submit" value="Submit Answer">
    </form>
{% else %}
    <h4>
        <a class="btn btn-xs btn-success" href="{% url 'user_login'%}"><b>Log-in</b></a> to answer to this question.
    </h4> 
{% endif %}

    <!-- Modal -->
    <div class="modal fade" id="detailsModal" tabindex="-1" role="dialog" aria-labelledby="detailsModalLabel" aria-hidden="true">
      <div class="modal-dialog">
        <div class="modal-content">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
            <h4 class="modal-title" id="myModalLabel">Edit Question Details</h4>
          </div>
          <div class="modal-body">
            
            <h5>The Current question is under:</h5>
            {{ question.category }}
            <hr>
            <div class="pull-right">
                <a id="question-details-ok" class="btn btn-sm btn-success hideme" data-qid={{ question.id }} href="#">Ok</a>
                <a class="btn btn-sm btn-default" data-dismiss="modal" href="#">Close</a>
            </div>
            <div class="clearfix"></div>
          </div> <!-- /.modal-body -->
        </div><!-- /.modal-content -->
      </div><!-- /.modal-dialog -->
    </div><!-- /.modal -->
<!-- AJAX SCRIPT -->

   

{% endblock %}

{% block javascript %}
    <script src="{% static 'website/js/nicEdit.js' %}" type="text/javascript"></script>
<script type="text/javascript">
    bkLib.onDomLoaded(function() {
        new nicEditor({
            iconsPath: "{% static 'website/js/nicEditorIcons.gif' %}",
            buttonList : ['fontSize','bold','italic','underline','strikeThrough','subscript','superscript','html','image', 'link']
        }).panelInstance('id_body');
    });
</script>
   <script src="{% static 'website/js/thread-user.js' %}"></script>
    <script type="text/javascript">

        $(document).ready(function() {
        
	 $.ajaxSetup({
            data: {csrfmiddlewaretoken: '{{ csrf_token }}' },
        });

	
        $('div.vote img.vote-up').click(function() {
         
            
	    
            var id = {{ question.pk }};
            var vote_type = 'up';
		
            /* USER HAS ALREADY VOTED */

            if ($(this).hasClass('selected')) {
                var vote_action = 'recall-vote'

                $.post('/vote_post/', {id:id, type:vote_type, action:vote_action}, function(response) {

                    $('img.vote-up').removeAttr('src')
                        .attr('src', '{% static 'website/images/up1-off.png' %}')
                        .removeClass('selected');
                    $('div.vote span.vote-count-post').html(response);
                });
            }
            /* USER WISHES TO VOTE */
            else {
                var vote_action = 'vote'
                $.post('/vote_post/', {id:id, type:vote_type, action:vote_action}, function(response) {

                    $('img.vote-up').removeAttr('src')
                        .attr('src', '{% static 'website/images/up1-on.png' %}')
                        .addClass('selected');
                    $('div.vote span.vote-count-post').html(response);
                });
            }
        });

        /* DOWNVOTE */

        $('div.vote img.vote-down').click(function() {

            var id = {{ question.pk }};
            var vote_type = 'down';
		
            /* USER HAS ALREADY DOWN-VOTED */

            if ($(this).hasClass('selected')) {
                var vote_action = 'recall-vote'

                $.post('/vote_post/', {id:id, type:vote_type, action:vote_action}, function(response) {

                    $('img.vote-down').removeAttr('src')
                        .attr('src', '{% static 'website/images/down1-off.png' %}')
                        .removeClass('selected');
                    $('div.vote span.vote-count-post').html(response);
                });
            }
            /* USER WISHES TO VOTE */
            else {
                var vote_action = 'vote'
                $.post('/vote_post/', {id:id, type:vote_type, action:vote_action}, function(response) {

                    $('img.vote-down').removeAttr('src')
                        .attr('src', '{% static 'website/images/down1-on.png' %}')
                        .addClass('selected');
                    $('div.vote span.vote-count-post').html(response);
                });
            }
        });
        
         
        });
 
  </script>
   
    
    <script src="{% static 'website/js/custom.js' %}"></script>
{% endblock %}