summaryrefslogtreecommitdiff
path: root/tbc/templates
diff options
context:
space:
mode:
authorhardythe12014-07-30 17:13:02 +0530
committerhardythe12014-07-30 17:13:02 +0530
commit250fc9e92257994e5610892be40ab62939fbcbac (patch)
tree04290874702f299584ee821d20c0e8d7af482724 /tbc/templates
parentf71c45f91d582375643de198880b87e994300596 (diff)
downloadPython-TBC-Interface-250fc9e92257994e5610892be40ab62939fbcbac.tar.gz
Python-TBC-Interface-250fc9e92257994e5610892be40ab62939fbcbac.tar.bz2
Python-TBC-Interface-250fc9e92257994e5610892be40ab62939fbcbac.zip
added changes to check matching books while submitting proposal
Diffstat (limited to 'tbc/templates')
-rwxr-xr-xtbc/templates/base.html4
-rw-r--r--tbc/templates/tbc/ajax-matching-books.html24
-rw-r--r--tbc/templates/tbc/submit-proposal.html63
3 files changed, 87 insertions, 4 deletions
diff --git a/tbc/templates/base.html b/tbc/templates/base.html
index d0c8708..91e8454 100755
--- a/tbc/templates/base.html
+++ b/tbc/templates/base.html
@@ -64,8 +64,6 @@
</style>
{% endblock %}
- {% block script %}
- {% endblock %}
</head>
<body>
@@ -230,6 +228,8 @@
ga('send', 'pageview');
</script>
<!-- / google analytics -->
+ {% block script %}
+ {% endblock %}
</body>
</html>
diff --git a/tbc/templates/tbc/ajax-matching-books.html b/tbc/templates/tbc/ajax-matching-books.html
new file mode 100644
index 0000000..c5fbfa8
--- /dev/null
+++ b/tbc/templates/tbc/ajax-matching-books.html
@@ -0,0 +1,24 @@
+<html>
+<body>
+<div>
+ <span id="flag">{% if flag %}match exists{% endif %}</span>
+ <div id="matches">
+ <center><h5>The books you have proposed may already be <b>under progress</b> or <b>completed</b> by some other contributor. Kindly verify and submit the proposal.</h5></center>
+ <hr>
+ {% for match in matches %}
+ {% if match %}
+ <b><h5>Potential matching books for your book preference {{ forloop.counter }}</h5></b>
+ {% else %}
+ <h5>No matching books found for book preference {{ forloop.counter }}</h5>
+ {% endif %}
+ <ul>
+ {% for book in match %}
+ <li>{{ book.title }} by {{ book.author }}</li>
+ {% endfor %}
+ </ul>
+ <hr>
+ {% endfor %}
+ </div>
+</div>
+</body>
+</html>
diff --git a/tbc/templates/tbc/submit-proposal.html b/tbc/templates/tbc/submit-proposal.html
index 1f091bb..1da0e22 100644
--- a/tbc/templates/tbc/submit-proposal.html
+++ b/tbc/templates/tbc/submit-proposal.html
@@ -1,14 +1,73 @@
{% extends 'base.html' %}
{% block content %}
<div id="content-wrap" style="max-width:600px;">
- <form action="/submit-proposal/" method=POST enctype="multipart/form-data">
+ <form id="proposal-form" action="/submit-proposal/" method=POST enctype="multipart/form-data">
{% csrf_token %}
{% for form in book_forms %}
<h4>Book Preference {{ forloop.counter }}</h4>
{{ form.as_p }}
{% endfor %}
<hr>
- <input class="btn btn-primary" type=submit value=submit>
+ <input id="proposal-form-submit" class="btn btn-primary" type=submit value=submit>
</form>
</div>
+
+
+<!-- Button to trigger modal -->
+<!-- Modal -->
+<div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
+ <div class="modal-header">
+ <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
+ <h3 id="myModalLabel">Potential Matching Books</h3>
+ </div>
+ <div class="modal-body">
+ <p>One fine body…</p>
+ </div>
+ <div class="modal-footer">
+ <button class="btn btn-primary" data-dismiss="modal">Go Back</button>
+ <button id="modal-submit-proposal" class="btn btn-danger">Submit Proposal</button>
+ </div>
+</div>
+{% endblock %}
+
+{% block script %}
+ <script>
+ $(document).ready(function() {
+ $("#proposal-form-submit").click(function(e) {
+ var i = 0;
+ var titles = [];
+ $titles = $("input[name='title']");
+ $titles = $("input[name='title']");
+ $titles.each(function(index, value) {
+ titles[i] = $(this).val();
+ ++i;
+ });
+ titles = JSON.stringify(titles);
+
+ $.ajax({
+ url: "/ajax/matching-books/",
+ type: "POST",
+ dataType: "html",
+ data: {
+ titles: titles
+ },
+ success: function(output) {
+ console.log(output);
+ var $output = $(output);
+ if($output.find("#flag").html() == "") {
+ $("#proposal-form").submit();
+ } else {
+ $(".modal-body").html($output.find("#matches").html());
+ $("#myModal").modal();
+ }
+ }
+ });
+ e.preventDefault();
+ });
+ $("#modal-submit-proposal").click(function(e){
+ $("#proposal-form").submit();
+ e.preventDefault();
+ });
+ });
+ </script>
{% endblock %}