summaryrefslogtreecommitdiff
path: root/static/website/templates/get-question.html
diff options
context:
space:
mode:
Diffstat (limited to 'static/website/templates/get-question.html')
-rw-r--r--static/website/templates/get-question.html286
1 files changed, 185 insertions, 101 deletions
diff --git a/static/website/templates/get-question.html b/static/website/templates/get-question.html
index 1a3d96b..af9e4a2 100644
--- a/static/website/templates/get-question.html
+++ b/static/website/templates/get-question.html
@@ -8,131 +8,191 @@
<span class="saving hideme">saving . . .</span>
<span class="saved hideme">saved</span>
-<div class="question {% if user|can_edit:question %}editable{% endif %}">
- <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>
-
- <span class="tutorial">
- <small>
- <a href="{% url 'website:filter' question.category question.tutorial %}">
- {{ question.tutorial}}
- </a>
- </small>
- </span>
-
- <span class="minute_range {% if question.minute_range == 'None' %}hideme{% endif %}">
- <small>
- <a href="{% url 'website:filter' question.category question.tutorial question.minute_range %}">
- {{ question.minute_range }} min
- </a>
- </small>
- </span>
-
- <span class="second_range {% if question.minute_range == 'None' %}hideme{% endif %}">
- <small>
- <a href="{% url 'website:filter' question.category question.tutorial question.minute_range question.second_range%}">
- {{ question.second_range }} sec
- </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 -->
-
-<h4><u>Answers:</u></h4>
-
-<div id="replyPanelWrapper" style="display:none;">
- <div id="replyNicPanel" style="display:none;"></div>
-</div>
-
-{% for reply in replies %}
- <div class="reply {% if user|can_edit:reply %}editable{% endif %}" id="reply{{reply.id}}">
+<div class="row">
+ <div class="col-lg-12 question-wrapper">
+ <div class="question {% if user|can_edit:question %}editable{% endif %}">
+ <div class="title {% if user|can_edit:question %}title-editable{% endif %}">
+ {{ question.title }}
+ </div>
- <div class="body" id="body{{ reply.id }}">
- {{ reply.body|safe }}
+ <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>
+
+ <span class="tutorial">
+ <small>
+ <a href="{% url 'website:filter' question.category question.tutorial %}">
+ {{ question.tutorial}}
+ </a>
+ </small>
+ </span>
+
+ <span class="minute_range {% if question.minute_range == 'None' %}hideme{% endif %}">
+ <small>
+ <a href="{% url 'website:filter' question.category question.tutorial question.minute_range %}">
+ {{ question.minute_range }} min
+ </a>
+ </small>
+ </span>
+
+ <span class="second_range {% if question.minute_range == 'None' %}hideme{% endif %}">
+ <small>
+ <a href="{% url 'website:filter' question.category question.tutorial question.minute_range question.second_range%}">
+ {{ question.second_range }} sec
+ </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>
- {{ reply.date_created|date:"d-m-y" }}, {{ reply.date_created|time }}
+ {{ question.date_created|date:"d-m-y" }}, {{ question.date_created|time }}
</i>
</small>
-
+
<span class="user">
- {{ reply.user }}
+ {{ question.user }}
</span>
</span>
+ </div> <!-- /.question -->
+ </div>
+</div> <!-- /.row -->
- {% if user|can_edit:reply %}
- <span class="modify" style="display:block">
- <a class="edit btn btn-xs btn-info vs" href="#body{{ reply.id}}" data-target="body{{ reply.id }}">Edit</a>
- <a class="save btn btn-xs btn-success vs" data-target="body{{ reply.id }}" data-rid="{{ reply.id }}" href="#">Save</a>
- </span>
- {% endif %}
- </div> <!-- /.reply -->
+<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="col-lg-12 answer-wrapper">
+ <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="user">
+ {{ answer.user }}
+ </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 col-lg-11 pull-right">
+ <!-- displaying comments -->
+ {% for comment in answer.answercomment_set.all %}
+ <div class="comment" id="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" }}, {{ question.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_reply' %}" method="POST"> {% csrf_token %}
+ <form action="{% url 'website:question_answer' %}" method="POST"> {% csrf_token %}
{% with WIDGET_ERROR_CLASS='field_error' %}
<div class="row">
<div class="col-lg-12">
<div class="form-group">
{% render_field form.question value=question.id %}
- <label for="id_body">Reply</label>
+ <label for="id_body">Answer</label>
{% render_field form.body class+='form-control' %}
</div>
</div>
</div>
{% endwith %}
- <input class="btn btn-sm btn-info" type="submit" value="Submit Reply">
+ <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 reply to this question.
+ <a class="btn btn-xs btn-success" href="{% url 'user_login'%}"><b>Log-in</b></a> to answer to this question.
</h4>
{% endif %}
@@ -145,7 +205,7 @@
<h4 class="modal-title" id="myModalLabel">Edit Question Details</h4>
</div>
<div class="modal-body">
-
+
<h5>The Current question is under:</h5>
{{ question.category }}
--&gt; {{ question.tutorial }}
@@ -155,7 +215,7 @@
{% if question.second_range != 'None' %}
--&gt; {{ question.second_range}}
{% endif %}
-
+
<h5>Move the question to:</h5>
<div class="row">
<div class="col-lg-4 col-md-4 col-sm-4">
@@ -232,7 +292,6 @@
<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 -->
@@ -252,4 +311,29 @@
{% block javascript %}
<script src="{% static 'website/js/thread-user.js' %}"></script>
<script src="{% static 'website/js/custom.js' %}"></script>
+ <script>
+ $(document).ready(function() {
+ $vote = $(".vote");
+
+ $vote.click(function() {
+ if($(this).hasClass("upvote")) {
+ /* handle upvote click event */
+ if($(this).hasClass("voted")) {
+ $(this).removeClass("voted");
+ } else {
+ $(this).addClass("voted");
+ $(this).siblings(".downvote").removeClass("voted");
+ }
+ } else {
+ /* handle downvote click event */
+ if($(this).hasClass("voted")) {
+ $(this).removeClass("voted");
+ } else {
+ $(this).addClass("voted");
+ $(this).siblings(".upvote").removeClass("voted");
+ }
+ }
+ });
+ });
+ </script>
{% endblock %}