diff options
-rw-r--r-- | tbc/templates/tbc/book-details.html | 16 | ||||
-rw-r--r-- | tbc/urls.py | 1 | ||||
-rwxr-xr-x | tbc/views.py | 9 |
3 files changed, 26 insertions, 0 deletions
diff --git a/tbc/templates/tbc/book-details.html b/tbc/templates/tbc/book-details.html index baaeaeb..3099063 100644 --- a/tbc/templates/tbc/book-details.html +++ b/tbc/templates/tbc/book-details.html @@ -1,6 +1,19 @@ {% extends 'base.html' %} {% load static %} +{% block script %} +<script> +function redirectToIpynb(notebook) +{ + alert(notebook); + notebook = notebook.split("/") + alert("http://ipynb.fossee.in/notebooks/"+notebook[1]+"/"+notebook[2]); + url = "http://ipynb.fossee.in/notebooks/"+notebook[1]+"/"+notebook[2] + window.location.replace(url) +} +</script> +{% endblock %} + {% block content %} <center><h3>{{ book.title }}</h3></center> <div class="row-fluid"> @@ -24,6 +37,9 @@ <td> <a href="{% static 'uploads/' %}{{ chapter.notebook }}">Download</a> </td> + <td> + <a href="{% url 'tbc:RedirectToIpynb' chapter.notebook %}">Edit examples of this chapter</a> + </td> </tr> {% endfor %} </table> diff --git a/tbc/urls.py b/tbc/urls.py index c3ca12f..bb71951 100644 --- a/tbc/urls.py +++ b/tbc/urls.py @@ -25,6 +25,7 @@ urlpatterns = patterns('', url(r'^completed-books/$', 'tbc.views.CompletedBooks', name='CompletedBooks'), url(r'^completed-books/(?P<category>.+)$', 'tbc.views.CompletedBooks', name='CompletedBooks'), url(r'^books-under-progress/$', 'tbc.views.BooksUnderProgress', name='BooksUnderProgress'), + url(r'^redirect-ipynb/(?P<notebook_path>.+)$', 'tbc.views.RedirectToIpynb', name='RedirectToIpynb'), url(r'^book-review/$', 'tbc.views.BookReview', name='BookReview'), diff --git a/tbc/views.py b/tbc/views.py index a232b36..bc3913b 100755 --- a/tbc/views.py +++ b/tbc/views.py @@ -652,3 +652,12 @@ def BooksUnderProgress(request): else: context['user'] = request.user return render_to_response('tbc/books_under_progress.html', context) + + +def RedirectToIpynb(request, notebook_path=None): + context = {} + notebook = notebook_path.split("/") + notebook[0] = "notebooks" + notebook = "/".join(notebook) + redirect_url = "https://ipynb.fossee.in/"+notebook + return redirect(redirect_url) |