diff options
author | Sanmugasundaram K | 2015-05-07 15:24:25 +0530 |
---|---|---|
committer | Sanmugasundaram K | 2015-05-07 15:24:25 +0530 |
commit | 30d80e37ee5604196f465c2b2c73b1d1a4f11f79 (patch) | |
tree | fc4f4d803fd177fb17927cd94d6ffd08f46e38fe /static/website | |
parent | 8f29c847f23aef4b21a803766064d59289603196 (diff) | |
download | spoken-tutorial-forums-30d80e37ee5604196f465c2b2c73b1d1a4f11f79.tar.gz spoken-tutorial-forums-30d80e37ee5604196f465c2b2c73b1d1a4f11f79.tar.bz2 spoken-tutorial-forums-30d80e37ee5604196f465c2b2c73b1d1a4f11f79.zip |
question delete, hide, show feature
Diffstat (limited to 'static/website')
-rw-r--r-- | static/website/css/main.css | 13 | ||||
-rw-r--r-- | static/website/js/thread-user.js | 45 | ||||
-rw-r--r-- | static/website/templates/base.html | 9 | ||||
-rw-r--r-- | static/website/templates/get-question.html | 35 | ||||
-rw-r--r-- | static/website/templates/search.html | 4 |
5 files changed, 100 insertions, 6 deletions
diff --git a/static/website/css/main.css b/static/website/css/main.css index 5587da7..054f4d2 100644 --- a/static/website/css/main.css +++ b/static/website/css/main.css @@ -194,7 +194,7 @@ table .title a { .hideme { display: none; } -.saving, .saved { +.saving, .saved, .deleted, .hide-qmsg { position: fixed; z-index: 2000; left: 45%; @@ -215,6 +215,17 @@ table .title a { .saved { background: lightgreen; } +.deleted, .hide-qmsg{ + background: #5bc0de; + color: white; +} +.question-midify{ + overflow: hidden; +} +.question-midify .delete-question, .question-midify .edit, .question-midify .save, .question-midify .hide-question{ + float: left; + margin: 0 3px; +} #content .answer { position: relative; border-bottom: 1px solid #f5f5f5; diff --git a/static/website/js/thread-user.js b/static/website/js/thread-user.js index 1c43342..32e7fae 100644 --- a/static/website/js/thread-user.js +++ b/static/website/js/thread-user.js @@ -14,6 +14,8 @@ $(document).ready(function() { */ $saving = $(".saving"); $saved= $(".saved"); + $deleted= $(".deleted"); + $hide_qmsg= $(".hide-qmsg"); $question = $(".question"); $question_modify = $(".question .modify"); $question_edit = $(".question .modify .edit"); @@ -305,4 +307,47 @@ $(document).ready(function() { $form.submit(); e.preventDefault; }); + /* delete */ + $('.delete-question').on('click', function(e){ + question_id = parseInt($('.delete-question').data("qid")); + $('#confirm-delete').modal({ backdrop: 'static', keyboard: false }) + .one('click', '#delete', function() { + $.ajax({ + url: "/ajax-delete-question/", + type: "POST", + data: { + question_id: question_id, + }, + success: function(data) { + $deleted.hide(); + $deleted.show(); + $deleted.fadeOut(10000); + window.location = '/'; + } + }); + }); + }); + + /* hide */ + $('.hide-question').on('click', function(e){ + question_id = parseInt($('.hide-question').data("qid")); + status = parseInt($('.hide-question').data("status")); + $('#confirm-hide').modal({ backdrop: 'static', keyboard: false }) + .one('click', '#chide', function() { + $.ajax({ + url: "/ajax-hide-question/", + type: "POST", + data: { + question_id: question_id, + status : status, + }, + success: function(data) { + $hide_qmsg.hide(); + $hide_qmsg.show(); + $hide_qmsg.fadeOut(10000); + window.location.reload(); + } + }); + }); + }); }); diff --git a/static/website/templates/base.html b/static/website/templates/base.html index 86ca41a..506cf24 100644 --- a/static/website/templates/base.html +++ b/static/website/templates/base.html @@ -1,5 +1,6 @@ {% load compress %} {% load static %} +{% load permission_tags %} <html> <head> <title> @@ -37,6 +38,14 @@ <!-- Collect the nav links, forms, and other content for toggling --> <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1"> <ul class="nav navbar-nav navbar-right"> + {% if user|isadministrator %} + <li> + <a href="{% url 'website:hidden_questions' %}"> + <span class="glyphicon glyphicon-eye-close"></span> + Hidden Questions + </a> + </li> + {% endif %} <li> <a href="{% url 'website:search' %}"> <span class="glyphicon glyphicon-search"></span> diff --git a/static/website/templates/get-question.html b/static/website/templates/get-question.html index 2983412..cce6469 100644 --- a/static/website/templates/get-question.html +++ b/static/website/templates/get-question.html @@ -7,10 +7,11 @@ {% block title %} {{ question.category }} - {{ question.title }} - Spoken Tutorial Forums {% endblock %} - {% block content %} <span class="saving hideme">saving . . .</span> <span class="saved hideme">saved</span> +<span class="deleted hideme">{{ question.title }} has been deleted.</span> +<span class="hide-qmsg hideme">{{ question.title }} has been {% if question.status == 1 %} hidden {% else %} Shown {% endif %}.</span> <div class="row"> <div class="question-wrapper col-lg-12 col-md-12 col-sm-12 col-xs-12"> @@ -67,13 +68,42 @@ <span class="glyphicon glyphicon-edit"></span> </a> - <span class="modify"> + <span class="modify question-midify"> {% if user|can_edit:question %} + <a class="hide-question btn btn-xs btn-info" data-qid="{{ question.id }}" data-status="{{ question.status }} href="#">{% if question.status == 1 %} Hide {% else %} Show {% endif %}</a> + <a class="delete-question btn btn-xs btn-info" data-qid="{{ question.id }}" href="#">Delete</a> <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> + + <div id="confirm-delete" class="modal fade"> + <div class="modal-dialog"> + <div class="modal-content"> + <div class="modal-body"> + Are you sure want to delete this question? + </div> + <div class="modal-footer"> + <button type="button" data-dismiss="modal" class="btn btn-primary btn-sm" id="delete">Delete</button> + <button type="button" data-dismiss="modal" class="btn btn-primary btn-sm">Cancel</button> + </div> + </div><!-- /.modal-content --> + </div><!-- /.modal-dialog --> + </div><!-- /.modal --> + <div id="confirm-hide" class="modal fade"> + <div class="modal-dialog"> + <div class="modal-content"> + <div class="modal-body"> + Are you sure want to {% if question.status %} Hide {% else %} Show {% endif %} this question? + </div> + <div class="modal-footer"> + <button type="button" data-dismiss="modal" class="btn btn-primary btn-sm" id="chide">Yes</button> + <button type="button" data-dismiss="modal" class="btn btn-primary btn-sm">Cancel</button> + </div> + </div><!-- /.modal-content --> + </div><!-- /.modal-dialog --> + </div><!-- /.modal --> <span class="meta"> <small> <i> @@ -320,7 +350,6 @@ }); </script> {% endblock %} - {% block javascript %} <script src="{% static 'website/js/thread-user.js' %}"></script> <script src="{% static 'website/js/custom.js' %}"></script> diff --git a/static/website/templates/search.html b/static/website/templates/search.html index 3ffc871..a2dc483 100644 --- a/static/website/templates/search.html +++ b/static/website/templates/search.html @@ -45,13 +45,13 @@ <div class="col-lg-2 col-md-2 col-sm-2"> <select id="search-minute-range" class="form-control" disabled="disabled"> - <option value="None">min</option> + <option value="">min</option> </select> </div> <div class="col-lg-2 col-md-2 col-sm-2"> <select id="search-second-range" class="form-control" disabled="disabled"> - <option value="None">sec</option> + <option value="">sec</option> </select> </div> |