summaryrefslogtreecommitdiff
path: root/tbc
diff options
context:
space:
mode:
Diffstat (limited to 'tbc')
-rw-r--r--tbc/admin.py1
-rw-r--r--tbc/models.py14
-rwxr-xr-xtbc/templates/base.html1
-rw-r--r--tbc/templates/tbc/aicte-books.html22
-rw-r--r--tbc/templates/tbc/confirm-aicte-details.html19
-rw-r--r--tbc/urls.py2
-rwxr-xr-xtbc/views.py66
7 files changed, 125 insertions, 0 deletions
diff --git a/tbc/admin.py b/tbc/admin.py
index 9983e27..30b5b34 100644
--- a/tbc/admin.py
+++ b/tbc/admin.py
@@ -9,3 +9,4 @@ admin.site.register(ScreenShots)
admin.site.register(TempBook)
admin.site.register(Proposal)
admin.site.register(SampleNotebook)
+admin.site.register(AicteBook)
diff --git a/tbc/models.py b/tbc/models.py
index 4b474f2..ec4c35d 100644
--- a/tbc/models.py
+++ b/tbc/models.py
@@ -149,3 +149,17 @@ class SampleNotebook(models.Model):
def __unicode__(self):
notebook = self.proposal.accepted.title or 'notebook'
return '%s'%(notebook)
+
+
+class AicteBook(models.Model):
+ title = models.TextField()
+ author = models.CharField(max_length=300L)
+ category = models.CharField(max_length=32L)
+ publisher_place = models.CharField(max_length=200L)
+ isbn = models.CharField(max_length=50L)
+ edition = models.CharField(max_length=15L)
+ year_of_pub = models.CharField(max_length=4L)
+ proposed = models.BooleanField(default=False)
+ def __unicode__(self):
+ notebook = self.title or 'Book'
+ return '%s'%(notebook)
diff --git a/tbc/templates/base.html b/tbc/templates/base.html
index 9708a53..803ad4d 100755
--- a/tbc/templates/base.html
+++ b/tbc/templates/base.html
@@ -93,6 +93,7 @@
<a href="#" class="dropdown-toggle" data-toggle="dropdown">{{ user.first_name }}<b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="{% url 'tbc:SubmitProposal' %}">Submit Proposal</a></li>
+ <li><a href="{% url 'tbc:ListAICTE' %}">Submit AICTE 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>
diff --git a/tbc/templates/tbc/aicte-books.html b/tbc/templates/tbc/aicte-books.html
new file mode 100644
index 0000000..6b0864b
--- /dev/null
+++ b/tbc/templates/tbc/aicte-books.html
@@ -0,0 +1,22 @@
+{% extends 'base.html' %}
+{% load static %}
+{% block content %}
+ <center><h3>List of AICTE Books</h3></center>
+ <hr>
+ <div id="content-wrap">
+ <table class="table table-bordered table-hover">
+ <th>SR #</th>
+ <th>Book (click on the link to propose the book)</th>
+ {% for book in aicte_books %}
+ <tr>
+ <td>
+ {{ forloop.counter }}
+ </td>
+ <td>
+ <a href="{% url 'tbc:SubmitAICTEProposal' book.id %}">{{ book.title }} by {{ book.author }}, {{ book.edition }} Edition</a>
+ </td>
+ </tr>
+ {% endfor %}
+ </table>
+ </div>
+{% endblock %}
diff --git a/tbc/templates/tbc/confirm-aicte-details.html b/tbc/templates/tbc/confirm-aicte-details.html
new file mode 100644
index 0000000..a13b1fb
--- /dev/null
+++ b/tbc/templates/tbc/confirm-aicte-details.html
@@ -0,0 +1,19 @@
+{% extends 'base.html' %}
+{% block content %}
+ <div id="content-wrap" style="max-width:600px;">
+ <center>
+ <h3>AICTE Book Details</h3>
+ <hr>
+ <p>
+ Kindly verify the book details. Also, fill in the missing details & submit the proposal.
+ </p>
+ <hr>
+ </center>
+ <form id="proposal-form" action="/submit-aicte-proposal/{{ aicte_book.id }}/" method=POST enctype="multipart/form-data">
+ {% csrf_token %}
+ {{ form.as_p }}
+ <hr>
+ <input id="proposal-form-submit" class="btn btn-primary" type=submit value=submit>
+ </form>
+ </div>
+{% endblock %}
diff --git a/tbc/urls.py b/tbc/urls.py
index f3f9aa4..9289155 100644
--- a/tbc/urls.py
+++ b/tbc/urls.py
@@ -14,6 +14,8 @@ urlpatterns = patterns('',
url(r'^submit-proposal/$', 'tbc.views.SubmitProposal', name='SubmitProposal'),
+ url(r'^submit-aicte-proposal/$', 'tbc.views.ListAICTE', name='ListAICTE'),
+ url(r'^submit-aicte-proposal/(?P<aicte_book_id>\d+)/$', 'tbc.views.SubmitAICTEProposal', name='SubmitAICTEProposal'),
url(r'^submit-book/$', 'tbc.views.SubmitBook', name='SubmitBook'),
url(r'^submit-sample/$', 'tbc.views.SubmitSample', name='SubmitSample'),
url(r'^submit-sample/(?P<proposal_id>\d+)$', 'tbc.views.SubmitSample', name='SubmitSample'),
diff --git a/tbc/views.py b/tbc/views.py
index a504628..8582538 100755
--- a/tbc/views.py
+++ b/tbc/views.py
@@ -347,6 +347,72 @@ def SubmitProposal(request):
return render_to_response('tbc/submit-proposal.html', context)
else:
return HttpResponseRedirect('/?proposal_pending=True')
+
+
+def ListAICTE(request):
+ curr_user = request.user
+ context = {}
+ context.update(csrf(request))
+ context['user'] = curr_user
+ aicte_books = AicteBook.objects.filter(proposed=0)
+ context['aicte_books'] = aicte_books
+ return render_to_response('tbc/aicte-books.html', context)
+
+
+def SubmitAICTEProposal(request, aicte_book_id=None):
+ curr_user = request.user
+ user_profile = Profile.objects.get(user=curr_user.id)
+ context = {}
+ context.update(csrf(request))
+ context['user'] = curr_user
+ user_proposals = Proposal.objects.filter(user=user_profile)
+ book_proposed = AicteBook.objects.get(id=aicte_book_id)
+ context['aicte_book'] = book_proposed
+ can_submit_new = True
+ for proposal in user_proposals:
+ if proposal.status is not "book completed":
+ can_submit_new = False
+ if can_submit_new:
+ if request.method == 'POST':
+ tempbook = TempBook()
+ book_proposed.title = request.POST['title']
+ book_proposed.author = request.POST['author']
+ book_proposed.category = request.POST['category']
+ book_proposed.publisher_place = request.POST['publisher_place']
+ book_proposed.isbn = request.POST['isbn']
+ book_proposed.edition = request.POST['edition']
+ book_proposed.year_of_pub = request.POST['year_of_pub']
+ book_proposed.proposed = True
+ book_proposed.save()
+ tempbook.title = book_proposed.title
+ tempbook.author = book_proposed.author
+ tempbook.category = book_proposed.category
+ tempbook.publisher_place = book_proposed.publisher_place
+ 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 = Proposal()
+ proposal.user = user_profile
+ proposal.save()
+ proposal.textbooks.add(tempbook)
+
+ return HttpResponseRedirect('/?proposal=submitted')
+ else:
+ book_form = BookForm()
+ book_form.initial['title'] = book_proposed.title
+ book_form.initial['author'] = book_proposed.author
+ book_form.initial['publisher_place'] = book_proposed.publisher_place
+ book_form.initial['category'] = book_proposed.category
+ book_form.initial['isbn'] = book_proposed.isbn
+ book_form.initial['edition'] = book_proposed.edition
+ book_form.initial['year_of_pub'] = book_proposed.year_of_pub
+ context['form'] = book_form
+ return render_to_response('tbc/confirm-aicte-details.html', context)
+ else:
+ return HttpResponseRedirect('/?proposal_pending=True')
+
def ReviewProposals(request, proposal_id=None, textbook_id=None):