diff options
author | hardythe1 | 2014-09-25 14:21:49 +0530 |
---|---|---|
committer | hardythe1 | 2014-09-25 14:21:49 +0530 |
commit | baa81d0e2e2d323c90c55ebba7b66dd0dc04a99e (patch) | |
tree | 2130bf6253c7056d43945448f53e75f69af15bd3 /tbc | |
parent | c498e86b5aa3f7afda65958adf81bee366c2dd1a (diff) | |
download | Python-TBC-Interface-baa81d0e2e2d323c90c55ebba7b66dd0dc04a99e.tar.gz Python-TBC-Interface-baa81d0e2e2d323c90c55ebba7b66dd0dc04a99e.tar.bz2 Python-TBC-Interface-baa81d0e2e2d323c90c55ebba7b66dd0dc04a99e.zip |
Fixed minor problems before deploying the automated proposal
Diffstat (limited to 'tbc')
-rw-r--r-- | tbc/models.py | 1 | ||||
-rw-r--r-- | tbc/templates/tbc/review-proposal.html | 7 | ||||
-rw-r--r-- | tbc/templates/tbc/submit-sample.html | 15 | ||||
-rwxr-xr-x | tbc/views.py | 11 |
4 files changed, 22 insertions, 12 deletions
diff --git a/tbc/models.py b/tbc/models.py index 46f265b..eb61c7c 100644 --- a/tbc/models.py +++ b/tbc/models.py @@ -42,6 +42,7 @@ ABOUT_PROJ = (("pythontbc website", "Python TBC Website"), PROPOSAL_STATUS = (("pending","Pending"), ("samples","Samples"), ("sample disapproved", "Sample Disapproved"), + ("sample resubmitted", "Sample Resubmitted"), ("book alloted","Book Alloted"), ("codes submitted", "Codes Submitted"), ("codes disapproved", "Codes Disapproved"), diff --git a/tbc/templates/tbc/review-proposal.html b/tbc/templates/tbc/review-proposal.html index c0ea983..f4ab9b3 100644 --- a/tbc/templates/tbc/review-proposal.html +++ b/tbc/templates/tbc/review-proposal.html @@ -71,11 +71,14 @@ {% ifequal proposal.proposal.status "samples" %} {% if proposal.sample.sample_notebook %} <h5><a href="{% static 'uploads/' %}{{ proposal.sample.sample_notebook }}">sample notebook</a><br></h5> + <a class="btn btn-primary" href="{% url 'tbc:DisapproveProposal' proposal.proposal.id %}">Disapprove Samples</a> + <a class="btn btn-primary" href="{% url 'tbc:AllotBook' proposal.proposal.id %}">Alot Book</a> {% else %} <h5>Contributor has not submitted sample notebook yet.</h5> {% endif %} - <a class="btn btn-primary" href="{% url 'tbc:DisapproveProposal' proposal.proposal.id %}">Disapprove Samples</a> - <a class="btn btn-primary" href="{% url 'tbc:AllotBook' proposal.proposal.id %}">Alot Book</a> + {% endifequal %} + {% ifequal proposal.proposal.status "sample disapproved" %} + <h5>Samples have been disapproved. Contributor has not resubmitted sample notebook yet.</h5> {% endifequal %} </div> {% endfor %} diff --git a/tbc/templates/tbc/submit-sample.html b/tbc/templates/tbc/submit-sample.html index 96f1209..404ede5 100644 --- a/tbc/templates/tbc/submit-sample.html +++ b/tbc/templates/tbc/submit-sample.html @@ -2,10 +2,9 @@ {% block script %} <script> -function validate_content() +function validate_content(element) { - no_notebooks = {{ no_notebooks }}.length; - extension = document.getElementById("sample_notebook").value; + extension = document.getElementById(element).value; extension = extension.split("."); if (extension == "" || name == "") { @@ -13,10 +12,14 @@ function validate_content() return false; } if(extension.slice(Math.max(extension.length - 1, 1)) == "ipynb") + { return true; + } else + { alert("Oops ! You can upload only Ipython Notebooks (.ipynb extension)"); return false; + } return true; } </script> @@ -24,10 +27,10 @@ function validate_content() {% block content %} <div id="content-wrap" style="max-width:600px;"> - <h5>You are uploading sample notebook for the book {{ proposal.accepted }} by {{ proposal.accepted.author }}</h5> + <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();"> + <form action="/submit-sample/{{ proposal.id }}/{{ old_notebook.id }}" name="with-old" method=POST enctype="multipart/form-data" onSubmit="return validate_content('old_notebook');"> {% 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> @@ -36,7 +39,7 @@ function validate_content() <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();"> + <form action="/submit-sample/{{ proposal.id }}" name="without-old" method=POST enctype="multipart/form-data" onSubmit="return validate_content('sample_notebook');"> {% 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/views.py b/tbc/views.py index 1fa3384..dfaa88c 100755 --- a/tbc/views.py +++ b/tbc/views.py @@ -463,6 +463,7 @@ def SubmitAICTEProposal(request, aicte_book_id=None): tempbook.no_chapters = request.POST['no_chapters'] tempbook.save() proposal.textbooks.add(tempbook) + print proposal.textbooks.all() add_log(curr_user, proposal, CHANGE, 'AICTE proposal' ,proposal.id) return HttpResponseRedirect('/?proposal=submitted') else: @@ -508,7 +509,7 @@ def ReviewProposals(request, proposal_id=None, textbook_id=None): else: new_proposals = Proposal.objects.filter(status="pending") old_proposals = [] - proposals = Proposal.objects.filter(status='samples') + proposals = Proposal.objects.filter(status__in=['samples', 'sample disapproved']) for proposal in proposals: try: sample_notebook = SampleNotebook.objects.get(proposal=proposal) @@ -541,9 +542,10 @@ def DisapproveProposal(request, proposal_id=None): changes_required add_log(request.user, proposal, CHANGE, 'Sample disapproved', proposal_id, chat=subject + '\n' + changes_required) - email_send(proposal.user.user.email, subject, message) context.update(csrf(request)) proposal.status = "sample disapproved" + proposal.save() + email_send(proposal.user.user.email, subject, message) return HttpResponseRedirect("/book-review/?mail_notify=done") else: context['proposal'] = proposal @@ -593,7 +595,8 @@ def SubmitSample(request, proposal_id=None, old_notebook_id=None): old_notebook.name = request.POST.get('ch_name_old') old_notebook.sample_notebook = request.FILES['old_notebook'] old_notebook.save() - curr_proposal.status = "sample resubmitted" + curr_proposal.status = "samples" + curr_proposal.save() return HttpResponseRedirect('/?sample_notebook=done') else: sample_notebook = SampleNotebook() @@ -605,7 +608,7 @@ def SubmitSample(request, proposal_id=None, old_notebook_id=None): else: profile = Profile.objects.get(user=user) try: - proposal = Proposal.objects.get(user=profile, status='samples') + proposal = Proposal.objects.get(user=profile, status__in=['samples','sample disapproved']) except Proposal.DoesNotExist: return HttpResponseRedirect('/?cannot_submit_sample=True') try: |