diff options
-rwxr-xr-x | tbc/templates/base.html | 5 | ||||
-rw-r--r-- | tbc/templates/tbc/aicte-books.html | 42 | ||||
-rwxr-xr-x | tbc/views.py | 15 |
3 files changed, 58 insertions, 4 deletions
diff --git a/tbc/templates/base.html b/tbc/templates/base.html index 3551246..e5ad52f 100755 --- a/tbc/templates/base.html +++ b/tbc/templates/base.html @@ -68,8 +68,6 @@ } </style> {% endblock %} - {% block script %} - {% endblock %} </head> <body> @@ -275,6 +273,9 @@ <script src="{% static 'js/jquery.js' %}"></script> <script src="{% static 'js/bootstrap.min.js' %}"></script> + {% block script %} + {% endblock %} + <!-- google analytics --> <script> (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ diff --git a/tbc/templates/tbc/aicte-books.html b/tbc/templates/tbc/aicte-books.html index 4cc3d15..5ed4021 100644 --- a/tbc/templates/tbc/aicte-books.html +++ b/tbc/templates/tbc/aicte-books.html @@ -1,5 +1,17 @@ {% extends 'base.html' %} {% load static %} + +{% block script %} +<script type="text/javascript"> +function submitCategory() +{ + alert("hello"); + document.forms.aictebooks.submit(); +} +</script> +{% endblock %} + + {% block content %} <center><h3>List of AICTE Books</h3></center> <hr> @@ -7,6 +19,31 @@ <p>Below is the list of AICTE recommended books. You can propose a book just by clicking on the link. However, if you wish to submit your own preferences other than AICTE books, click the button given below.</p> <a href="{% url 'tbc:SubmitProposal' %}" class="btn btn-primary">I don't want to propose AICTE book</a> <hr> + <center><h4>Select a Category</h4></center> + <form name="aictebooks" action="/submit-aicte-proposal/" method=POST enctype="multipart/form-data"> + {% csrf_token %} + <center><select name="category" id="category" onchange="submitCategory();"> + <option value="all">All</option> + <option value="fluid mechanics">Fluid Mechanics</option> + <option value="control systems">Control Theory & Control Systems</option> + <option value="chemical engineering">Chemical Engineering</option> + <option value="thermodynamics">Thermodynamics</option> + <option value="Physics">Physics</option> + <option value="mechanical engineering">Mechanical Engineering</option> + <option value="Mechanics">Mechanics</option> + <option value="Signal Processing">Signal Processing</option> + <option value="Digital Signal Processing">Ditgital Signal Processing</option> + <option value="digital communications">Digital Communications</option> + <option value="Electrical Technology">Electrical Technology</option> + <option value="maths & science">Mathematics & Pure Science</option> + <option value="Analog Electronics">Analog Electronics</option> + <option value="digital electronics">Digital Electronics</option> + <option value="computer programming">Computer Programming</option> + <option value="others">Others</option> + </select> + {% if no_books %} + <h5>No books under the requested category</h5> + {% else %} <table class="table table-bordered table-hover"> <th>SR #</th> <th>Book (click on the link to propose the book)</th> @@ -21,5 +58,10 @@ </tr> {% endfor %} </table> + {% endif %} </div> {% endblock %} + +<script> + document.getElementById('category').value = "{{ category }}"; +</script> diff --git a/tbc/views.py b/tbc/views.py index 049f838..d5ff195 100755 --- a/tbc/views.py +++ b/tbc/views.py @@ -450,8 +450,19 @@ def ListAICTE(request): context = {} context.update(csrf(request)) context['user'] = curr_user - aicte_books = AicteBook.objects.filter(proposed=0) - context['aicte_books'] = aicte_books + if request.method == "POST": + category = request.POST['category'] + return HttpResponse(category) + context['category'] = category + if category == "all": + aicte_books = AicteBook.objects.filter(proposed=0) + else: + aicte_books = AicteBook.objects.filter(category=category, proposed=0) + if len(aicte_books) == 0: + context['no_books'] = True + else: + aicte_books = AicteBook.objects.filter(proposed=0) + context['aicte_books'] = aicte_books return render_to_response('tbc/aicte-books.html', context) |