summaryrefslogtreecommitdiff
path: root/tbc
diff options
context:
space:
mode:
authorprathamesh2016-09-15 10:50:08 +0530
committerprathamesh2016-09-15 10:50:08 +0530
commit21a153e8c64afd38d9e20ce23543e53e65b5e2c3 (patch)
tree778d37cc47e46b39117a047c8f920924fb2a44e2 /tbc
parent3928f602bf0e4d36db3e702990bf129867bd4f28 (diff)
downloadPython-TBC-Interface-21a153e8c64afd38d9e20ce23543e53e65b5e2c3.tar.gz
Python-TBC-Interface-21a153e8c64afd38d9e20ce23543e53e65b5e2c3.tar.bz2
Python-TBC-Interface-21a153e8c64afd38d9e20ce23543e53e65b5e2c3.zip
added attributes to Profile
Diffstat (limited to 'tbc')
-rw-r--r--tbc/models.py3
-rw-r--r--tbc/templates/tbc/books.html11
-rw-r--r--tbc/templates/tbc/profile.html1
-rw-r--r--tbc/views.py32
4 files changed, 27 insertions, 20 deletions
diff --git a/tbc/models.py b/tbc/models.py
index 0747882..7deb31c 100644
--- a/tbc/models.py
+++ b/tbc/models.py
@@ -80,6 +80,9 @@ class Profile(models.Model):
gender = models.CharField(max_length=10, choices=GENDER)
phone_no = models.CharField(max_length=15)
about_proj = models.CharField(max_length=50, choices=ABOUT_PROJ)
+ city = models.CharField(max_length=50, default=None)
+ state = models.CharField(max_length=50, default=None)
+ pin_code = models.IntegerField(max_length=6, default=None)
def __unicode__(self):
name = self.user.first_name or 'Profile'
return '%s'%(name)
diff --git a/tbc/templates/tbc/books.html b/tbc/templates/tbc/books.html
index b1d975f..80070f1 100644
--- a/tbc/templates/tbc/books.html
+++ b/tbc/templates/tbc/books.html
@@ -5,8 +5,17 @@
<div class="row-fluid">
<div class="span6">
<u> Books without start and end time </u>
+ <br \>
+ <u> Books without any log available </u>
<ol>
- {% for book in books_incomplete %}
+ {% for book in manual %}
+ <li><a href="{% url 'tbc:edit_book' book.id %}"> {{ book.title }} </a> </li>
+ {% endfor %}
+ </ol>
+ <br \>
+ <u> Books with log available, so can be automated </u>
+ <ol>
+ {% for book in auto %}
<li><a href="{% url 'tbc:edit_book' book.id %}"> {{ book.title }} </a> </li>
{% endfor %}
</ol>
diff --git a/tbc/templates/tbc/profile.html b/tbc/templates/tbc/profile.html
index e6f706a..1485849 100644
--- a/tbc/templates/tbc/profile.html
+++ b/tbc/templates/tbc/profile.html
@@ -15,7 +15,6 @@
<form action="/profile/" method=POST>
{% csrf_token %}
{{ form.as_p }}
- {{ form.errors }}
<br>
<input class="btn btn-primary" type=submit value=submit>
</form>
diff --git a/tbc/views.py b/tbc/views.py
index 647037d..358a606 100644
--- a/tbc/views.py
+++ b/tbc/views.py
@@ -228,12 +228,10 @@ def user_profile(request):
context = {}
user = request.user
if user.is_authenticated():
+ user_profile = Profile.objects.filter(user=user)
+ profile = user_profile[0] if user_profile.exists() else None
if request.method == 'POST':
- user_profile = Profile.objects.filter(user=user)
- if user_profile.exists():
- form = UserProfileForm(request.POST, instance=user_profile[0])
- else:
- form = UserProfileForm(request.POST)
+ form = UserProfileForm(request.POST, instance=profile)
if form.is_valid():
data = form.save(commit=False)
data.user = request.user
@@ -244,8 +242,7 @@ def user_profile(request):
context.update(csrf(request))
context['form'] = form
return render_to_response('tbc/profile.html', context)
- else:
- form = UserProfileForm()
+ form = UserProfileForm(instance=profile)
context.update(csrf(request))
context['form'] = form
context['user'] = user
@@ -267,7 +264,7 @@ def update_profile(request):
context['user'] = user
user_profile = Profile.objects.get(user=user)
if request.method == "POST":
- form = UserProfileForm(request.POST)
+ form = UserProfileForm(request.POST, instance=user_profile)
if form.is_valid():
data = form.save(commit=False)
data.user = request.user
@@ -278,15 +275,7 @@ def update_profile(request):
context['form'] = form
return render_to_response('tbc/update-profile.html', context)
else:
- form = UserProfileForm()
- form.initial['about'] = user_profile.about
- form.initial['insti_org'] = user_profile.insti_org
- form.initial['course'] = user_profile.course
- form.initial['dept_desg'] = user_profile.dept_desg
- form.initial['dob'] = user_profile.dob
- form.initial['gender'] = user_profile.gender
- form.initial['phone_no'] = user_profile.phone_no
- form.initial['about_proj'] = user_profile.about_proj
+ form = UserProfileForm(instance=user_profile)
context['form'] = form
return render_to_response('tbc/update-profile.html', context)
@@ -372,12 +361,19 @@ def books(request):
books = Book.objects.all()
books_incomplete = []
books_complete = []
+ auto = []
+ manual = []
for book in books:
if book.start_time is None or book.end_time is None:
books_incomplete.append(book)
else:
books_complete.append(book)
- context = {'books_incomplete': books_incomplete, 'books_complete': books_complete}
+ for book in books_incomplete:
+ if book.approved_textbook.all():
+ auto.append(book)
+ else:
+ manual.append(book)
+ context = {'auto': auto, 'manual': manual, 'books_complete': books_complete}
return render_to_response('tbc/books.html', context)
else:
return HttpResponseRedirect("/login/?require_login=true")