summaryrefslogtreecommitdiff
path: root/tbc
diff options
context:
space:
mode:
Diffstat (limited to 'tbc')
-rw-r--r--tbc/templates/tbc/book-review.html14
-rw-r--r--tbc/templates/tbc/upload-content.html4
-rwxr-xr-xtbc/views.py36
3 files changed, 42 insertions, 12 deletions
diff --git a/tbc/templates/tbc/book-review.html b/tbc/templates/tbc/book-review.html
index 774998c..d7270b4 100644
--- a/tbc/templates/tbc/book-review.html
+++ b/tbc/templates/tbc/book-review.html
@@ -2,10 +2,20 @@
{% load static %}
{% block content %}
{% if book_review %}
-<p>Book has been approved !</p>
+<center>
+ <div class="alert" style="width:230px;height:23px;">
+ <a class="close" data-dismiss="alert" href="#">&times;</a>
+ <p>Book has been approved !</p>
+ </div>
+ </center>
{% endif %}
{% if mail_notify %}
-<p>Successfully notified the required changes !</p>
+<center>
+ <div class="alert" style="width:230px;height:23px;">
+ <a class="close" data-dismiss="alert" href="#">&times;</a>
+ <p>Successfully notified the required changes !</p>
+ </div>
+ </center>
{% endif %}
<center><h3>Books to be reviewed</h3></center>
<ol>
diff --git a/tbc/templates/tbc/upload-content.html b/tbc/templates/tbc/upload-content.html
index 01bb584..5f6025c 100644
--- a/tbc/templates/tbc/upload-content.html
+++ b/tbc/templates/tbc/upload-content.html
@@ -47,7 +47,7 @@ function validate_content()
<div id="content-wrap" style="max-width:600px;">
<p>Upload chapters as individual IPython notebooks. Please do not use spaces to name your Ipython Notebook files. For ex.
use "chapter1.ipynb instead of chapter 1.ipynb"</p>
- <form action="/upload-content/{{ curr_book.id }}" method=POST enctype="multipart/form-data">
+ <form action="/upload-content/{{ curr_book.id }}" method=POST enctype="multipart/form-data" onSubmit="return validate_content();">
{% csrf_token %}
{% for i in no_notebooks %}
<input type=text id=chapter{{i}} name=chapter{{i}} placeholder="Chapter {{ forloop.counter }} name">
@@ -60,7 +60,7 @@ function validate_content()
<input type=text id=caption{{i}} name=caption{{i}} placeholder="Caption {{ forloop.counter }}">
<input type=file id=image{{i}} name=image{{i}}>
{% endfor %}
- <center><input class="btn btn-primary" type=submit value=submit onClick="return validate_content();"></center>
+ <center><input class="btn btn-primary" type=submit value=submit></center>
</form>
</div>
{% endblock %}
diff --git a/tbc/views.py b/tbc/views.py
index d85666a..3dfb82d 100755
--- a/tbc/views.py
+++ b/tbc/views.py
@@ -141,7 +141,10 @@ def UserLogin(request):
def UserRegister(request):
context = {}
+<<<<<<< HEAD
return render_to_response('tbc/unavailable.html', context)
+=======
+>>>>>>> temporary_master
if request.method == 'POST':
form = UserRegisterForm(request.POST)
if form.is_valid():
@@ -160,6 +163,7 @@ def UserRegister(request):
def UserProfile(request):
+ context = {}
user = request.user
context = {}
return render_to_response('tbc/unavailable.html', context)
@@ -188,6 +192,7 @@ def UserProfile(request):
def UserLogout(request):
+ context = {}
user = request.user
if user.is_authenticated() and user.is_active:
logout(request)
@@ -233,9 +238,12 @@ def ForgotPassword(request):
def UpdatePassword(request):
- user = request.user
context = {}
+<<<<<<< HEAD
return render_to_response('tbc/unavailable.html', context)
+=======
+ user = request.user
+>>>>>>> temporary_master
context.update(csrf(request))
if user.is_authenticated():
if request.method == 'POST':
@@ -271,9 +279,12 @@ def UpdatePassword(request):
def SubmitBook(request):
- curr_user = request.user
context = {}
+<<<<<<< HEAD
return render_to_response('tbc/unavailable.html', context)
+=======
+ curr_user = request.user
+>>>>>>> temporary_master
if request.method == 'POST':
form = BookForm(request.POST)
if form.is_valid():
@@ -301,7 +312,10 @@ def SubmitBook(request):
def UpdateBook(request):
context = {}
+<<<<<<< HEAD
return render_to_response('tbc/unavailable.html', context)
+=======
+>>>>>>> temporary_master
current_user = request.user
user_profile = Profile.objects.get(user=current_user)
try:
@@ -343,7 +357,10 @@ def UpdateBook(request):
def ContentUpload(request, book_id=None):
context = {}
+<<<<<<< HEAD
return render_to_response('tbc/unavailable.html', context)
+=======
+>>>>>>> temporary_master
user = request.user
curr_book = Book.objects.get(id=book_id)
if request.method == 'POST':
@@ -383,7 +400,10 @@ def ContentUpload(request, book_id=None):
def UpdateContent(request, book_id=None):
context = {}
+<<<<<<< HEAD
return render_to_response('tbc/unavailable.html', context)
+=======
+>>>>>>> temporary_master
user = request.user
current_book = Book.objects.get(id=book_id)
chapters_to_update = Chapters.objects.filter(book=current_book)
@@ -499,22 +519,22 @@ def BookReview(request, book_id=None):
def ApproveBook(request, book_id=None):
- user = request.user
context = {}
- return render_to_response('tbc/unavailable.html', context)
+ user = request.user
if is_reviewer(request.user):
if request.method == 'POST' and request.POST['approve_notify'] == "approve":
book = Book.objects.get(id=book_id)
book.approved = True
book.save()
file_path = os.path.abspath(os.path.dirname(__file__))
- zip_path = "/".join(file_path.split("/")[1:-2])
- zip_path = "/"+zip_path+"/Python-Textbook-Companions/"
+ copy_path = "/".join(file_path.split("/")[1:-2])
+ copy_path = "/"+copy_path+"/Python-Textbook-Companions/"
file_path = file_path+"/static/uploads/"
directory = file_path+book.contributor.user.first_name
os.chmod(directory, 0777)
os.chdir(directory)
- fp = open(book.title+"/README.txt", 'w')
+ book_title = book.title.replace(" ", "_")
+ fp = open(book_title+"/README.txt", 'w')
fp.write("Contributed By: "+book.contributor.user.first_name+" "+book.contributor.user.last_name+"\n")
fp.write("Course: "+book.contributor.course+"\n")
fp.write("College/Institute/Organization: "+book.contributor.insti_org+"\n")
@@ -526,7 +546,7 @@ def ApproveBook(request, book_id=None):
fp.write("Isbn: "+book.isbn+"\n")
fp.write("Edition: "+book.edition)
fp.close()
- x = shutil.copytree(book.title, zip_path+book.title)
+ os.popen("cp -r '"+book_title+"' '"+copy_path+"'")
subject = "Python-TBC: Book Completion"
message = "Hi "+book.contributor.user.first_name+",\n"+\
"Congratulations !\n"+\