summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tbc/templates/tbc/update-code.html45
-rwxr-xr-xtbc/views.py3
2 files changed, 45 insertions, 3 deletions
diff --git a/tbc/templates/tbc/update-code.html b/tbc/templates/tbc/update-code.html
index ee1d5b5..536617b 100644
--- a/tbc/templates/tbc/update-code.html
+++ b/tbc/templates/tbc/update-code.html
@@ -9,6 +9,47 @@ $(document).ready(function() {
});
});
</script>
+<script>
+function validate_content()
+{
+ no_notebooks = {{ no_notebooks }};
+ for(i=1;i<=no_notebooks;i++)
+ {
+ name = document.getElementById("chapter"+i).value;
+ extension = document.getElementById("notebook"+i).value;
+ extension = extension.split(".");
+ if (extension == "" || name == "")
+ {
+ alert("Chapter names & file fields cannot be empty !!");
+ return false;
+ }
+ if(extension.slice(Math.max(extension.length - 1, 1)) == "ipynb")
+ continue;
+ else
+ alert("Oops !! You can upload only Ipython Notebooks (.ipynb extension)");
+ return false;
+ }
+ for(i=1;i<=3;i++)
+ {
+ caption = document.getElementById("caption"+i).value;
+ extension = document.getElementById("image"+i).value;
+ extension = extension.split(".");
+ if (extension == "" || caption == "")
+ {
+ alert("Captions and file fields cannot be empty");
+ return false;
+ }
+
+ if(extension.slice(Math.max(extension.length - 1, 1)) == "png")
+ continue;
+ else
+ alert("Only .png files are allowed for screenshots");
+ return false;
+ }
+ return true;
+}
+</script>
+
{% endblock %}
{% block content %}
<div id="content-wrap" style="max-width:600px;">
@@ -18,7 +59,7 @@ $(document).ready(function() {
{% csrf_token %}
{% for chapter in chapters %}
<input class="chapters" type=text id=chapter{{forloop.counter}} name=chapter{{forloop.counter}} value="{{ chapter.name }}">
- <input type=file name=notebook{{forloop.counter}}>
+ <input type=file name=notebook{{forloop.counter}} id=notebook{{forloop.counter}}>
{% endfor %}
<br>
<hr>
@@ -33,7 +74,7 @@ $(document).ready(function() {
<input type=file id=image{{forloop.counter}} name=image{{forloop.counter}}>
{% endfor %}
<br><br>
- <center><input class="btn btn-primary" type=submit value=submit></center>
+ <center><input class="btn btn-primary" type=submit value=submit onClick="return validate_content();"></center>
</form>
</div>
{% endblock %}
diff --git a/tbc/views.py b/tbc/views.py
index 4ad7f8e..37891a4 100755
--- a/tbc/views.py
+++ b/tbc/views.py
@@ -665,7 +665,7 @@ def RejectProposal(request, proposal_id=None):
proposal.save()
remarks = request.POST['remarks']
subject = "Python-TBC: Rejection of Proposal"
- message = """Dear """+proposal.user.user.first_name+"""\nYour recent proposal for contributing in Python TBC has been rejected for the following reasons"""+request.POST.get('remarks')+"""\nHowever, your last proposal will be saved and you can edit the same proposal or propose a fresh one again.\n\nRegards\nPython TBC Team\nFOSSEE - IIT Bombay"""
+ message = """Dear """+proposal.user.user.first_name+"""\nYour recent proposal for contributing in Python TBC has been rejected for the following reasons\n"""+request.POST.get('remarks')+"""\n\nHowever, your last proposal will be saved and you can edit the same proposal or propose a fresh one again.\n\nRegards\nPython TBC Team\nFOSSEE - IIT Bombay"""
add_log(request.user, proposal, CHANGE, 'Proposal rejected',
proposal.id, chat=subject + '\n' + remarks)
email_send(proposal.user.user.email, subject, message)
@@ -738,6 +738,7 @@ def ConfirmBookDetails(request):
context['book'] = book_to_update
context['chapters'] = chapters
context['screenshots'] = screen_shots
+ context['no_notebooks'] = book_to_update.no_chapters
return render_to_response('tbc/update-code.html', context)
if request.method == 'POST':
book_form = BookForm(request.POST, instance=book_to_update)