|
1 import os |
1 from django.http import HttpResponse, Http404 |
2 from django.http import HttpResponse, Http404 |
2 from django.shortcuts import redirect, render_to_response |
3 from django.shortcuts import redirect, render_to_response |
3 from pytask.taskapp.models import Task |
4 from pytask.taskapp.models import Task |
4 from pytask.taskapp.forms.user import UserProfileEditForm |
5 from pytask.taskapp.forms.user import UserProfileEditForm |
5 from pytask.taskapp.events.user import createUser, updateProfile |
6 from pytask.taskapp.events.user import createUser, updateProfile |
72 # edit_profile_form = UserProfileEditForm(instance = form) |
73 # edit_profile_form = UserProfileEditForm(instance = form) |
73 # return render_to_response('user/edit_profile.html',{'edit_profile_form' : edit_profile_form}) |
74 # return render_to_response('user/edit_profile.html',{'edit_profile_form' : edit_profile_form}) |
74 if request.user.is_authenticated() == True: |
75 if request.user.is_authenticated() == True: |
75 profile = Profile.objects.get(user = request.user) |
76 profile = Profile.objects.get(user = request.user) |
76 data = request.POST#form.cleaned_data |
77 data = request.POST#form.cleaned_data |
77 properties = {'aboutme':data['aboutme'], 'foss_comm':data['foss_comm'], 'phonenum':data['phonenum'], 'homepage':data['homepage'], 'street':data['street'], 'city':data['city'], 'country':data['country'], 'nick':data['nick'],'photo':request.FILES['photo']} |
78 properties = {'aboutme':data['aboutme'], |
|
79 'foss_comm':data['foss_comm'], |
|
80 'phonenum':data['phonenum'], |
|
81 'homepage':data['homepage'], |
|
82 'street':data['street'], |
|
83 'city':data['city'], |
|
84 'country':data['country'], |
|
85 'nick':data['nick']} |
|
86 uploaded_photo = request.FILES.get('photo',None) |
|
87 prev_photo = profile.photo |
|
88 if uploaded_photo: |
|
89 if prev_photo: |
|
90 os.remove(prev_photo.path) |
|
91 properties['photo'] = uploaded_photo |
78 #fields = ['dob','gender','credits','aboutme','foss_comm','phonenum','homepage','street','city','country','nick'] |
92 #fields = ['dob','gender','credits','aboutme','foss_comm','phonenum','homepage','street','city','country','nick'] |
79 updateProfile(profile,properties) |
93 updateProfile(profile,properties) |
80 return redirect('/user/view/uid='+str(profile.user_id)) |
94 return redirect('/user/view/uid='+str(profile.user_id)) |
81 else: |
95 else: |
82 profile = Profile.objects.get(user = request.user) |
96 profile = Profile.objects.get(user = request.user) |