summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xtbc/templates/base.html3
-rw-r--r--tbc/templates/tbc/confirm-aicte-details.html2
-rw-r--r--tbc/templates/tbc/confirm-details.html11
-rw-r--r--tbc/templates/tbc/review-proposal.html6
-rw-r--r--tbc/templates/tbc/submit-proposal.html6
-rw-r--r--tbc/templates/tbc/submit-sample.html9
-rw-r--r--tbc/templates/tbc/update-book.html2
-rw-r--r--tbc/urls.py2
-rwxr-xr-xtbc/views.py32
9 files changed, 42 insertions, 31 deletions
diff --git a/tbc/templates/base.html b/tbc/templates/base.html
index 9f1607a..ec9806a 100755
--- a/tbc/templates/base.html
+++ b/tbc/templates/base.html
@@ -101,8 +101,7 @@
<ul class="dropdown-menu">
<li><a href="{% url 'tbc:ListAICTE' %}">Submit Proposal</a></li>
<li><a href="{% url 'tbc:SubmitSample' %}">Submit Sample Notebook</a></li>
- <li><a href="{% url 'tbc:SubmitCode' %}">Submit Codes</a></li>
- <li><a href="{% url 'tbc:UpdateBook' %}">Update Submission</a></li>
+ <li><a href="{% url 'tbc:ConfirmBookDetails' %}">Submit Codes</a></li>
<li><a href="{% url 'tbc:UpdatePassword' %}">Update Password</a></li>
<li><a href="{% url 'tbc:UserLogout' %}">Logout</a></li>
</ul>
diff --git a/tbc/templates/tbc/confirm-aicte-details.html b/tbc/templates/tbc/confirm-aicte-details.html
index e26c453..e8ab88b 100644
--- a/tbc/templates/tbc/confirm-aicte-details.html
+++ b/tbc/templates/tbc/confirm-aicte-details.html
@@ -24,6 +24,8 @@ $( document ).ready(function() {
title = document.getElementById('id_title').readOnly = true;
author = document.getElementById('id_author').readOnly = true;
publisher_place = document.getElementById('id_publisher_place').readOnly = true;
+ $('#id_no_chapters').hide();
+ $('label[for="id_no_chapters"]').hide();
});
</script>
{% endblock %}
diff --git a/tbc/templates/tbc/confirm-details.html b/tbc/templates/tbc/confirm-details.html
new file mode 100644
index 0000000..26007ea
--- /dev/null
+++ b/tbc/templates/tbc/confirm-details.html
@@ -0,0 +1,11 @@
+{% extends 'base.html' %}
+{% block content %}
+<div id="content-wrap" style="max-width:600px;">
+ <form action="/confirm-book-details/" method=POST enctype="multipart/form-data">
+ {% csrf_token %}
+ {{ form.as_table }}
+ <br>
+ <input class="btn btn-primary" type=submit value="Update Book">
+ </form>
+</div>
+{% endblock %}
diff --git a/tbc/templates/tbc/review-proposal.html b/tbc/templates/tbc/review-proposal.html
index f4ab9b3..9c6aca9 100644
--- a/tbc/templates/tbc/review-proposal.html
+++ b/tbc/templates/tbc/review-proposal.html
@@ -62,9 +62,9 @@
</div>
{% endfor %}
<h5>
- <b>Status:</b>
+
{% ifequal proposal.proposal.status "samples" %}
- Sample notebook phase
+ <b>Status:</b> Sample notebook phase
{% endifequal %}
</h5>
<h5><b>Book Accepted/Alloted:</b> {{ proposal.proposal.accepted.title }}</h5>
@@ -78,7 +78,7 @@
{% endif %}
{% endifequal %}
{% ifequal proposal.proposal.status "sample disapproved" %}
- <h5>Samples have been disapproved. Contributor has not resubmitted sample notebook yet.</h5>
+ <b>Status:</b> Samples have been disapproved. Contributor has not resubmitted sample notebook yet.
{% endifequal %}
</div>
{% endfor %}
diff --git a/tbc/templates/tbc/submit-proposal.html b/tbc/templates/tbc/submit-proposal.html
index 1da0e22..167fa5a 100644
--- a/tbc/templates/tbc/submit-proposal.html
+++ b/tbc/templates/tbc/submit-proposal.html
@@ -5,6 +5,7 @@
{% csrf_token %}
{% for form in book_forms %}
<h4>Book Preference {{ forloop.counter }}</h4>
+ {{ form.errors }}
{{ form.as_p }}
{% endfor %}
<hr>
@@ -69,5 +70,10 @@
e.preventDefault();
});
});
+ $( document ).ready(function() {
+ $('input[id="id_no_chapters"]').hide();
+ $('label[for="id_no_chapters"]').hide();
+ });
+
</script>
{% endblock %}
diff --git a/tbc/templates/tbc/submit-sample.html b/tbc/templates/tbc/submit-sample.html
index 404ede5..322c339 100644
--- a/tbc/templates/tbc/submit-sample.html
+++ b/tbc/templates/tbc/submit-sample.html
@@ -2,9 +2,10 @@
{% block script %}
<script>
-function validate_content(element)
+function validate_content(ext, name)
{
- extension = document.getElementById(element).value;
+ extension = document.getElementById(ext).value;
+ name = document.getElementById(name).value;
extension = extension.split(".");
if (extension == "" || name == "")
{
@@ -30,7 +31,7 @@ function validate_content(element)
<h5>You are uploading sample notebook for the book <br>{{ proposal.accepted }} by {{ proposal.accepted.author }}</h5>
<p>Only .ipynb files are acceptable</p>
{% if has_old %}
- <form action="/submit-sample/{{ proposal.id }}/{{ old_notebook.id }}" name="with-old" method=POST enctype="multipart/form-data" onSubmit="return validate_content('old_notebook');">
+ <form action="/submit-sample/{{ proposal.id }}/{{ old_notebook.id }}" name="with-old" method=POST enctype="multipart/form-data" onSubmit="return validate_content('old_notebook', 'ch_name_old');">
{% csrf_token %}
<input type=text id=ch_name_old name=ch_name_old value="{{ old_notebook.name }}">
<input type=file id=old_notebook name=old_notebook>
@@ -39,7 +40,7 @@ function validate_content(element)
<center><input class="btn btn-primary" type=submit value=submit></center>
</form>
{% else %}
- <form action="/submit-sample/{{ proposal.id }}" name="without-old" method=POST enctype="multipart/form-data" onSubmit="return validate_content('sample_notebook');">
+ <form action="/submit-sample/{{ proposal.id }}" name="without-old" method=POST enctype="multipart/form-data" onSubmit="return validate_content('sample_notebook', 'ch_name');">
{% csrf_token %}
<input type=text id=ch_name name=ch_name placeholder="Name of the chapter you coded the solved example from">
<input type=file id=sample_notebook name=sample_notebook>
diff --git a/tbc/templates/tbc/update-book.html b/tbc/templates/tbc/update-book.html
index fb26a8b..c00d003 100644
--- a/tbc/templates/tbc/update-book.html
+++ b/tbc/templates/tbc/update-book.html
@@ -1,7 +1,7 @@
{% extends 'base.html' %}
{% block content %}
<div id="content-wrap" style="max-width:600px;">
- <form action="/update-book/" method=POST enctype="multipart/form-data">
+ <form action="/confirm-book-deetails/" method=POST enctype="multipart/form-data">
{% csrf_token %}
{{ form.as_table }}
<br>
diff --git a/tbc/urls.py b/tbc/urls.py
index 7cf07a7..4ee9609 100644
--- a/tbc/urls.py
+++ b/tbc/urls.py
@@ -20,7 +20,7 @@ urlpatterns = patterns('',
url(r'^submit-sample/$', 'tbc.views.SubmitSample', name='SubmitSample'),
url(r'^submit-sample/(?P<proposal_id>\d+)$', 'tbc.views.SubmitSample', name='SubmitSample'),
url(r'^submit-sample/(?P<proposal_id>\d+)/(?P<old_notebook_id>\d+)$', 'tbc.views.SubmitSample', name='SubmitSample'),
- url(r'^update-book/$', 'tbc.views.UpdateBook', name='UpdateBook'),
+ url(r'^confirm-book-details/$', 'tbc.views.ConfirmBookDetails', name='ConfirmBookDetails'),
url(r'^submit-code/$', 'tbc.views.SubmitCode', name='SubmitCode'),
url(r'^update-content/(?P<book_id>\d+)$', 'tbc.views.UpdateContent', name='UpdateContent'),
url(r'^get-zip/(?P<book_id>\d+)$', 'tbc.views.GetZip', name='GetZip'),
diff --git a/tbc/views.py b/tbc/views.py
index dfaa88c..4fcb0e2 100755
--- a/tbc/views.py
+++ b/tbc/views.py
@@ -365,7 +365,7 @@ def SubmitProposal(request):
textbooks = proposal.textbooks.all()
textbooks.delete()
for item in range(3):
- tempbook = TempBook()
+ tempbook = TempBook(no_chapters=0)
tempbook.title = book_titles[item]
tempbook.author = book_authors[item]
tempbook.category = book_categories[item]
@@ -373,7 +373,6 @@ def SubmitProposal(request):
tempbook.isbn = book_isbns[item]
tempbook.edition = book_editions[item]
tempbook.year_of_pub = book_years[item]
- tempbook.no_chapters = book_chapters[item]
tempbook.save()
proposal.textbooks.add(tempbook)
add_log(curr_user, proposal, CHANGE, 'Proposed Books', proposal.id)
@@ -452,7 +451,7 @@ def SubmitAICTEProposal(request, aicte_book_id=None):
textbooks = proposal.textbooks.all()
if textbooks:
textbooks.delete()
- tempbook = TempBook()
+ tempbook = TempBook(no_chapters=0)
tempbook.title = book_proposed.title
tempbook.author = book_proposed.author
tempbook.category = book_proposed.category
@@ -460,7 +459,6 @@ def SubmitAICTEProposal(request, aicte_book_id=None):
tempbook.isbn = book_proposed.isbn
tempbook.edition = book_proposed.edition
tempbook.year_of_pub = book_proposed.year_of_pub
- tempbook.no_chapters = request.POST['no_chapters']
tempbook.save()
proposal.textbooks.add(tempbook)
print proposal.textbooks.all()
@@ -566,6 +564,11 @@ def RejectProposal(request, proposal_id=None):
context.update(csrf(request))
proposal = Proposal.objects.get(id=proposal_id)
if request.method == 'POST':
+ books = proposal.textbooks.all()
+ if len(books) == 1:
+ aicte_book = AicteBook.objects.get(isbn=books[0].isbn)
+ aicte_book.proposed = False
+ aicte_book.save()
proposal.status = 'rejected'
proposal.save()
remarks = request.POST['remarks']
@@ -622,33 +625,22 @@ def SubmitSample(request, proposal_id=None, old_notebook_id=None):
return render_to_response('tbc/submit-sample.html', context)
-def UpdateBook(request):
+def ConfirmBookDetails(request):
context = {}
current_user = request.user
user_profile = Profile.objects.get(user=current_user)
- try:
- book_to_update = Book.objects.get(contributor=user_profile, approved=False) or None
- except:
- return HttpResponseRedirect("/?not_found=True")
- title = book_to_update.title
- chapters = Chapters.objects.filter(book=book_to_update)
- screenshots = ScreenShots.objects.filter(book=book_to_update)
+ proposal = Proposal.objects.get(user=user_profile, status="book alloted")
+ book_to_update = Book.objects.get(id=proposal.accepted.id)
if request.method == 'POST':
book_form = BookForm(request.POST, instance=book_to_update)
if book_form.is_valid():
- file_path = os.path.abspath(os.path.dirname(__file__))
- file_path = file_path+"/static/uploads/"
- directory = file_path+book_to_update.contributor.user.first_name
- os.chdir(directory)
- os.popen("mv '"+title+"' '"+book_to_update.title+"'")
data = book_form.save(commit=False)
data.contributor = user_profile
data.save()
context.update(csrf(request))
context['form'] = book_form
- proposal = Proposal.objects.get(accepted=book_to_update)
add_log(current_user, book_to_update, CHANGE, 'Book updated', proposal.id)
- return HttpResponseRedirect('/update-content/'+str(book_to_update.id))
+ return HttpResponseRedirect('/submit-code/')
else:
book_form = BookForm()
book_form.initial['title'] = book_to_update.title
@@ -662,7 +654,7 @@ def UpdateBook(request):
book_form.initial['reviewer'] = book_to_update.reviewer
context.update(csrf(request))
context['form'] = book_form
- return render_to_response('tbc/update-book.html', context)
+ return render_to_response('tbc/confirm-details.html', context)
def SubmitCode(request):