diff options
author | kinitrupti | 2016-11-04 17:52:23 +0530 |
---|---|---|
committer | kinitrupti | 2016-11-04 17:52:23 +0530 |
commit | 9b564418c062ea43e465eebc7ac5ffd865556507 (patch) | |
tree | 281a5fd16ff267961ca2430059a037d73b51501e | |
parent | eb3321f80def84e84329f213e21ef5ac94d4ccd6 (diff) | |
download | Python-TBC-Interface-9b564418c062ea43e465eebc7ac5ffd865556507.tar.gz Python-TBC-Interface-9b564418c062ea43e465eebc7ac5ffd865556507.tar.bz2 Python-TBC-Interface-9b564418c062ea43e465eebc7ac5ffd865556507.zip |
Hitcount updated
-rw-r--r-- | PythonTBC/settings.py | 1 | ||||
-rw-r--r-- | PythonTBC/urls.py | 2 | ||||
-rw-r--r-- | requirements.txt | 1 | ||||
-rw-r--r-- | tbc/templates/tbc/book-details.html | 23 |
4 files changed, 26 insertions, 1 deletions
diff --git a/PythonTBC/settings.py b/PythonTBC/settings.py index 46131a9..bd0f0b8 100644 --- a/PythonTBC/settings.py +++ b/PythonTBC/settings.py @@ -136,6 +136,7 @@ INSTALLED_APPS = ( 'django.contrib.admin', # Uncomment the next line to enable admin documentation: # 'django.contrib.admindocs', + 'hitcount', 'tbc', 'comments', #'south', diff --git a/PythonTBC/urls.py b/PythonTBC/urls.py index 77d166a..9cae5d6 100644 --- a/PythonTBC/urls.py +++ b/PythonTBC/urls.py @@ -27,7 +27,7 @@ urlpatterns = [ url(r'^admin-tools/commenting', commentingapp.views.commenting, name = 'commenting'), url(r'^admin-tools/error_page', tbc_error_page.views.error, name = 'error_page'), url(r'^admin-tools/broken_page', tbc_error_page.views.broken, name = 'broken_page'), - + url(r'hitcount/', include('hitcount.urls', namespace='hitcount')), ] diff --git a/requirements.txt b/requirements.txt index ac72f30..ab8f58a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -14,3 +14,4 @@ wsgiref==0.1.2 scrapy==1.0.3 django-taggit django-taggit-templatetags2 +django-hitcount diff --git a/tbc/templates/tbc/book-details.html b/tbc/templates/tbc/book-details.html index fc67847..0119117 100644 --- a/tbc/templates/tbc/book-details.html +++ b/tbc/templates/tbc/book-details.html @@ -2,6 +2,24 @@ {% load static %} {% block script %} +{% load staticfiles %} +<script src="{% static 'hitcount/jquery.postcsrf.js' %}"></script> + +{% load hitcount_tags %} +{% get_hit_count_js_variables for book as hitcount %} +<script type="text/javascript"> +jQuery(document).ready(function($) { + // use the template tags in our JavaScript call + $.postCSRF("{{ hitcount.ajax_url }}", { hitcountPK : "{{ hitcount.pk }}" }) + .done(function(data){ + $('<i />').text(data.hit_counted).attr('id','hit-counted-value').appendTo('#hit-counted'); + $('#hit-response').text(data.hit_message); + }).fail(function(data){ + console.log('POST failed'); + console.log(data); + }); +}); +</script> <script> function redirectToIpynb(notebook) { @@ -50,6 +68,7 @@ function redirectToIpynb(notebook) <tr> <td>Author: </td> <td>{{ book.author }}</td> + </tr> <tr> <td>Publisher: </td> @@ -79,7 +98,11 @@ function redirectToIpynb(notebook) <td>GitHub: </td> <td><a href= 'https://github.com/FOSSEE/Python-Textbook-Companions/tree/master/{{ book.title.split|join:"_" }}_by_{{ book.author.split|join:"_" }}' target="_blank">{{ book.title }}</a></td> </tr> +<tr> + <td>Page Hits: </td> +<td>{% get_hit_count for book %}</td> +</tr> </table> </div> |