summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoradityacp2016-04-22 11:30:02 +0530
committeradityacp2016-04-22 11:30:02 +0530
commit3d49dc17e96fa2726c60942a44d8571d353542d4 (patch)
tree5adc0a5951174804aefa0839ba9dd2f56d18f69e
parentab5d550709322739629fffb7e7a3335ec1a6623c (diff)
downloadonline_test-3d49dc17e96fa2726c60942a44d8571d353542d4.tar.gz
online_test-3d49dc17e96fa2726c60942a44d8571d353542d4.tar.bz2
online_test-3d49dc17e96fa2726c60942a44d8571d353542d4.zip
profile form name changes
-rw-r--r--yaksh/forms.py9
-rw-r--r--yaksh/templates/yaksh/view_profile.html2
-rw-r--r--yaksh/views.py15
3 files changed, 12 insertions, 14 deletions
diff --git a/yaksh/forms.py b/yaksh/forms.py
index 271b503..681eca0 100644
--- a/yaksh/forms.py
+++ b/yaksh/forms.py
@@ -187,12 +187,13 @@ class CourseForm(forms.ModelForm):
model = Course
fields = ['name', 'active', 'enrollment']
-class EditProfile(forms.ModelForm):
- """ edit profile form for students and moderators """
+class ProfileForm(forms.ModelForm):
+ """ profile form for students and moderators """
class Meta:
model = Profile
- fields = ['first_name', 'last_name', 'institute', 'department', 'roll_number', 'position']
+ fields = ['first_name', 'last_name', 'institute',
+ 'department', 'roll_number', 'position']
first_name = forms.CharField(max_length=30)
last_name = forms.CharField(max_length=30)
@@ -200,6 +201,6 @@ class EditProfile(forms.ModelForm):
def __init__(self, *args, **kwargs):
if 'user' in kwargs:
user = kwargs.pop('user')
- super(EditProfile, self).__init__(*args, **kwargs)
+ super(ProfileForm, self).__init__(*args, **kwargs)
self.fields['first_name'].initial = user.first_name
self.fields['last_name'].initial = user.last_name
diff --git a/yaksh/templates/yaksh/view_profile.html b/yaksh/templates/yaksh/view_profile.html
index 69dac5a..be15d14 100644
--- a/yaksh/templates/yaksh/view_profile.html
+++ b/yaksh/templates/yaksh/view_profile.html
@@ -13,8 +13,8 @@
<a href="{{ URL_ROOT }}/exam/">Back to Home</a>
</ul>
<div class="span14">
- <h2 style="margin-left: 220px">Your Profile Information</h2>
<center>
+ <h2>Your Profile Information</h2>
<table class="span1">
<tr>
<th><label for="id_first_name"><h5>First name:</h5></label></th>
diff --git a/yaksh/views.py b/yaksh/views.py
index 49d7179..1709488 100644
--- a/yaksh/views.py
+++ b/yaksh/views.py
@@ -22,7 +22,7 @@ from yaksh.models import Quiz, Question, QuestionPaper, QuestionSet, Course
from yaksh.models import Profile, Answer, AnswerPaper, User, TestCase
from yaksh.forms import UserRegisterForm, UserLoginForm, QuizForm,\
QuestionForm, RandomQuestionForm, TestCaseFormSet,\
- QuestionFilterForm, CourseForm, EditProfile
+ QuestionFilterForm, CourseForm, ProfileForm
from yaksh.xmlrpc_clients import code_server
from settings import URL_ROOT
from yaksh.models import AssignmentUpload
@@ -66,11 +66,8 @@ def is_moderator(user):
return True
def has_profile(user):
- """ check if user is having profile """
- if hasattr(user, 'profile'):
- return True
- else:
- return False
+ """ check if user has profile """
+ return True if hasattr(user, 'profile') else False
def index(request):
"""The start page.
@@ -988,7 +985,7 @@ def view_profile(request):
if has_profile(user):
return my_render_to_response('yaksh/view_profile.html', {'user':user})
else:
- form = EditProfile(user=user)
+ form = ProfileForm(user=user)
msg = True
context['form'] = form
context['msg'] = msg
@@ -1009,7 +1006,7 @@ def edit_profile(request):
profile = None
if request.method == 'POST':
- form = EditProfile(request.POST, user=user, instance=profile)
+ form = ProfileForm(request.POST, user=user, instance=profile)
if form.is_valid():
form_data = form.save(commit=False)
form_data.user = user
@@ -1024,7 +1021,7 @@ def edit_profile(request):
return my_render_to_response('yaksh/editprofile.html', context,
context_instance=ci)
else:
- form = EditProfile(user=user, instance=profile)
+ form = ProfileForm(user=user, instance=profile)
context['form'] = form
return my_render_to_response('yaksh/editprofile.html', context,
context_instance=ci)