diff options
author | anoop | 2010-02-04 23:17:59 +0530 |
---|---|---|
committer | anoop | 2010-02-04 23:17:59 +0530 |
commit | 7160035dad40895e77055718e9a5c9b59c98730b (patch) | |
tree | 7c03a9f2b08e6af8f562a58020dbaaaf86637744 | |
parent | b73b0118d99799c7f0abd553f82fac8a65f7f214 (diff) | |
download | pytask-7160035dad40895e77055718e9a5c9b59c98730b.tar.gz pytask-7160035dad40895e77055718e9a5c9b59c98730b.tar.bz2 pytask-7160035dad40895e77055718e9a5c9b59c98730b.zip |
changed the view my profile template.
-rw-r--r-- | taskapp/forms/user.py | 21 | ||||
-rw-r--r-- | taskapp/views/user.py | 5 | ||||
-rw-r--r-- | templates/user/my_profile.html | 51 |
3 files changed, 47 insertions, 30 deletions
diff --git a/taskapp/forms/user.py b/taskapp/forms/user.py index b80ee81..e13e3d0 100644 --- a/taskapp/forms/user.py +++ b/taskapp/forms/user.py @@ -16,27 +16,6 @@ class LoginForm(forms.Form): username = forms.CharField(max_length=30, required=True) password = forms.CharField(max_length=60, required=True, widget=forms.PasswordInput) -class UserProfileForm(ModelForm): - class Meta: - model = Profile - exclude = ('user','rights') - def __init__(self, *args, **kwargs): - super(UserProfileForm, self).__init__(*args, **kwargs) - instance = getattr(self, 'instance', None) - if instance and instance.id: - self.fields['dob'].widget.attrs['readonly'] = True - self.fields['gender'].widget.attrs['readonly'] = True - self.fields['credits'].widget.attrs['readonly'] = True - self.fields['aboutme'].widget.attrs['readonly'] = True - self.fields['foss_comm'].widget.attrs['readonly'] = True - self.fields['phonenum'].widget.attrs['readonly'] = True - self.fields['homepage'].widget.attrs['readonly'] = True - self.fields['street'].widget.attrs['readonly'] = True - self.fields['city'].widget.attrs['readonly'] = True - self.fields['country'].widget.attrs['readonly'] = True - self.fields['nick'].widget.attrs['readonly'] = True - #fields = ['dob','gender','credits','aboutme','foss_comm','phonenum','homepage','street','city','country','nick'] - class UserProfileEditForm(ModelForm): class Meta: model = Profile diff --git a/taskapp/views/user.py b/taskapp/views/user.py index 95a2711..231bc7d 100644 --- a/taskapp/views/user.py +++ b/taskapp/views/user.py @@ -1,7 +1,7 @@ from django.http import HttpResponse from django.shortcuts import redirect, render_to_response from pytask.taskapp.models import Task -from pytask.taskapp.forms.user import RegistrationForm, LoginForm, UserProfileForm, UserProfileEditForm +from pytask.taskapp.forms.user import RegistrationForm, LoginForm, UserProfileEditForm from pytask.taskapp.events.user import createUser, updateProfile from django.contrib.auth import login, logout, authenticate from django.contrib.auth.models import User @@ -104,10 +104,9 @@ def view_my_profile(request,uid): edit_profile = True if request.user == User.objects.get(pk=uid) else False try: profile = Profile.objects.get(user = User.objects.get(pk=uid)) - view_profile_form = UserProfileForm(instance = profile) except Profile.DoesNotExist: raise Http404 - return render_to_response('user/my_profile.html', {'view_profile_form': view_profile_form,'edit_profile':edit_profile}) + return render_to_response('user/my_profile.html', {'edit_profile':edit_profile,'profile':profile}) def edit_my_profile(request): """ enables the user to edit his/her user profile """ diff --git a/templates/user/my_profile.html b/templates/user/my_profile.html index 366d089..8e96b46 100644 --- a/templates/user/my_profile.html +++ b/templates/user/my_profile.html @@ -1,11 +1,50 @@ {% extends 'base.html' %} -{% block content %} -{% if edit_profile %} - <a href="/user/edit/">edit my profile</a> -{% endif %} +{% block title %} + {{ profile.user }}'s Profile +{% endblock %} -<br> -{{ view_profile_form.as_p }} +{% block content %} + <!--{{ view_profile_form.as_p }}--> + <h2>{{ profile }}'s Profile</h2><hr> + {% if edit_profile %} + <a href="/user/edit/">edit profile</a> + {% endif %} + <hr> + {% if profile.aboutme %} + <br><h4>About Me</h4><hr>{{ profile.aboutme }} + {% endif %} + {% if profile.nick %} + <br><h4>Nick Name</h4><hr>{{ profile.nick }} + {% endif %} + {% if profile.dob %} + <br><h4>Date of Birth</h4><hr>{{ profile.dob }} + {% endif %} + {% if profile.credits %} + <br><h4>Credits</h4><hr>{{ profile.credits }} + {% endif %} + {% if profile.foss_comm %} + <br><h4>Foss Community</h4><hr>{{ profile.foss_comm }} + {% endif %} + {% if profile.phonenum %} + <br><h4>Phone Number</h4><hr>{{ profile.phonenum }} + {% endif %} + {% if profile.homepage %} + <br><h4>Homepage</h4><hr>{{ profile.homepage }} + {% endif %} + {% if profile.street or profile.city or profile.country %} + <br><h4>Address</h4><hr> + {% if profile.street %} + {{ profile.street }} + <br> + {% endif %} + {% if profile.city %} + {{ profile.city }} + <br> + {% endif %} + {% if profile.country %} + {{ profile.country }} + {% endif %} + {% endif %} {% endblock %} |