def personalProfile(request): print(request.POST) currentProfile = request.user if request.method == 'POST': form = ProfileForm(request.POST, request.FILES) if form.is_valid(): year = form.cleaned_data.get('year') major = form.cleaned_data.get('major') gender = form.cleaned_data.get('gender') sexualOrientation = form.cleaned_data.get('sexualOrientation') bio = form.cleaned_data.get('bio') idealDate = form.cleaned_data.get('idealDate') kagin = form.cleaned_data.get('kagin') cafemac = form.cleaned_data.get('cafemac') athletes = form.cleaned_data.get('athletes') cold = form.cleaned_data.get('cold') lookingFor = form.cleaned_data.get('lookingFor') friendLookingFor = form.cleaned_data.get('friendLookingFor') politics = form.cleaned_data.get('politics') aesthetics = form.cleaned_data.get('aesthetics') nap = form.cleaned_data.get('nap') saturday = form.cleaned_data.get('saturday') appSampler = form.cleaned_data.get('appSampler') pic = request.FILES['pic'] total = idealDate+kagin+cafemac+athletes+cold+lookingFor+friendLookingFor+politics+aesthetics+nap+saturday+appSampler score = float(total)/12.0 Profile.objects.create(user=currentProfile,year=year,major=major,gender=gender,sexualOrientation=sexualOrientation,bio=bio,idealDate=idealDate,kagin=kagin,cafemac=cafemac,athletes=athletes,cold=cold,lookingFor=lookingFor,friendLookingFor=friendLookingFor,politics=politics,aesthetics=aesthetics,nap=nap,appSampler=appSampler,saturday=saturday,score=score,pic=pic) return redirect('home') else: form = ProfileForm() return render(request, 'smack/personProfile.html',{'form':form})
def editProfile(request): profile = Profile.objects.get(user=request.user) if request.method == 'POST': form = ProfileForm(request.POST, request.FILES) if form.is_valid(): profile.year = form.cleaned_data.get('year') profile.major = form.cleaned_data.get('major') profile.gender = form.cleaned_data.get('gender') profile.sexualOrientation = form.cleaned_data.get('sexualOrientation') profile.bio = form.cleaned_data.get('bio') profile.idealDate = form.cleaned_data.get('idealDate') profile.kagin = form.cleaned_data.get('kagin') profile.cafemac = form.cleaned_data.get('cafemac') profile.athletes = form.cleaned_data.get('athletes') profile.cold = form.cleaned_data.get('cold') profile.lookingFor = form.cleaned_data.get('lookingFor') profile.friendLookingFor = form.cleaned_data.get('friendLookingFor') profile.politics = form.cleaned_data.get('politics') profile.aesthetics = form.cleaned_data.get('aesthetics') profile.nap = form.cleaned_data.get('nap') profile.saturday = form.cleaned_data.get('saturday') profile.appSampler = form.cleaned_data.get('appSampler') pic = request.FILES['pic'] total = idealDate+kagin+cafemac+athletes+cold+lookingFor+friendLookingFor+politics+aesthetics+nap+saturday+appSampler profile.score = float(total)/12.0 profile.save() return redirect('home') else: data = {'year':profile.year,'major':profile.major,'gender':profile.gender,'sexualOrientation':profile.sexualOrientation,'bio':profile.bio,'email':profile.email,'idealDate':profile.idealDate,'kagin':profile.kagin,'cafemac':profile.cafemac,'athletes':profile.athletes,'cold':profile.cold,'lookingFor':profile.lookingFor} data1 = {'politics':profile.politics,'aesthetics':profile.aesthetics,'nap':profile.nap,'saturday':profile.saturday,'appSampler':profile.appSampler,'friendLookingFor':profile.friendLookingFor,'pic':profile.pic} data.update(data1) form = ProfileForm(initial=data) return render(request, 'smack/editProfile.html', {'form':form})
def editProfile(request): title="Edit Profile" if request.method == 'POST': userform = ProfileForm(request.POST) # A form bound to the POST data adressform = AdressForm(request.POST) if userform.is_valid(): # All validation rules pass oldpassword = userform.cleaned_data['oldpassword'] password = userform.cleaned_data['password'] secpassword = userform.cleaned_data['secpassword'] email = userform.cleaned_data['email'] if adressform.is_valid(): publicadress = adressform.cleaned_data['publicAdress'] country = adressform.cleaned_data['country'] city = adressform.cleaned_data['city'] zipcode = adressform.cleaned_data['zipcode'] street = adressform.cleaned_data['street'] housenumber = adressform.cleaned_data['housenumber'] userprofile = request.user.profile l = Location(country=country, city=city, zipcode=zipcode, street=street, housenumber=housenumber) l.save() userprofile.adress = l userprofile.publicAdress = publicadress userprofile.save() else: user = request.user try: userform = ProfileForm({'email': user.email,}) except: userform = UserForm() try: adressform = AdressForm({ 'publicAdress': user.profile.publicAdress, 'country': user.profile.adress.country, 'city': user.profile.adress.city, 'zipcode': user.profile.adress.zipcode, 'street': user.profile.adress.street, 'housenumber': user.profile.adress.housenumber}) except: adressform = AdressForm() context = util.generateContext(request, contextType = 'RequestContext', userform=userform, adressform=adressform, title=title) return render_to_response('usermanag/edit.html', context)
def personalProfile(request): print(request.POST) currentProfile = request.user if request.method == 'POST': form = ProfileForm(request.POST, request.FILES) if form.is_valid(): full_name = form.cleaned_data.get('full_name') email = form.cleaned_data.get('email') year = form.cleaned_data.get('year') major = form.cleaned_data.get('major') gender = form.cleaned_data.get('gender') sexualOrientation = form.cleaned_data.get('sexualOrientation') bio = form.cleaned_data.get('bio') idealDate = form.cleaned_data.get('idealDate') kagin = form.cleaned_data.get('kagin') cafemac = form.cleaned_data.get('cafemac') athletes = form.cleaned_data.get('athletes') cold = form.cleaned_data.get('cold') lookingFor = form.cleaned_data.get('lookingFor') friendLookingFor = form.cleaned_data.get('friendLookingFor') politics = form.cleaned_data.get('politics') aesthetics = form.cleaned_data.get('aesthetics') nap = form.cleaned_data.get('nap') saturday = form.cleaned_data.get('saturday') appSampler = form.cleaned_data.get('appSampler') pic = request.FILES['pic'] total = int(idealDate) + int(kagin) + int(cafemac) + int( athletes) + int(cold) + int(lookingFor) + int( friendLookingFor) + int(politics) + int(aesthetics) + int( nap) + int(saturday) + int(appSampler) score = int(total) / 12 Profile.objects.create(full_name=full_name, email=email, user=currentProfile, year=year, major=major, gender=gender, sexualOrientation=sexualOrientation, bio=bio, idealDate=idealDate, kagin=kagin, cafemac=cafemac, athletes=athletes, cold=cold, lookingFor=lookingFor, friendLookingFor=friendLookingFor, politics=politics, aesthetics=aesthetics, nap=nap, appSampler=appSampler, saturday=saturday, score=score, pic=pic) if request.user.is_authenticated(): user = request.user profile = Profile.objects.get(user=user) profile.dislike.add(profile) return redirect('home') else: form = ProfileForm() return render(request, 'smack/personProfile.html', {'form': form})