def security(request, uid=-1): userInfos = common.Users(request, -1) userProfile = userInfos[2] if utility.HasPostData(request, "ok"): userProfile.avatar = utility.SaveFile(request.FILES['avatar'], 'avatar/') userProfile.save() return HttpResponseRedirect('/') else: return utility.my_render_to_response(request, "pub/profile/security.html", locals())
def avatar(request, uid=-1): userInfos = common.Users(request, -1) currentUserProfile = userInfos["currentuserprofile"] #000/00/01 if utility.HasPostData(request, "okkk"): avatarPath = ("%d" % currentUserProfile.user_id).rjust(7, "0") dir1 = avatarPath[0:3] dir2 = avatarPath[3:5] fileName = avatarPath[5:7] path = "%s/%s/%s/" % ("avatar", dir1, dir2) currentUserProfile.avatar = utility.SaveFile(request.FILES['avatar'], path, fileName) currentUserProfile.save() return HttpResponseRedirect('/') else: return utility.my_render_to_response(request, "pub/profile/avatar.html", locals())