def view_current_profile(request, contextArg): """this view displays account information and allows users to edit their information """ if request.user.is_anonymous(): #tell user they need to be logged in to do that return HttpResponseRedirect('/accounts/login/') #redirect to login page else: currentUser = request.user userProfile = profileUtil.getProfileFromUser(currentUser) print(userProfile.personalShed) reputation = profileUtil.getReputation(userProfile) timeCreated = userProfile.timeCreated streetAddress = profileUtil.getAddress(userProfile) city = profileUtil.getCity(userProfile) state = profileUtil.getStateName(userProfile) shareZone = profileUtil.getSharezone(userProfile) context = {} context.update(csrf(request)) context['userProfile'] = userProfile context['timeStamp'] = timeCreated context['streetAddress'] = streetAddress context['reputation'] = reputation context['city'] = city context['state'] = state context['sharezone'] = shareZone context.update(content.genBaseLoggedIn(request)) if contextArg: context.update(contextArg) return render_to_response('my_account.html', context)
def view_current_profile(request, contextArg): """this view displays account information and allows users to edit their information """ if request.user.is_anonymous(): #tell user they need to be logged in to do that return HttpResponseRedirect( '/accounts/login/') #redirect to login page else: currentUser = request.user userProfile = profileUtil.getProfileFromUser(currentUser) print(userProfile.personalShed) reputation = profileUtil.getReputation(userProfile) timeCreated = userProfile.timeCreated streetAddress = profileUtil.getAddress(userProfile) city = profileUtil.getCity(userProfile) state = profileUtil.getStateName(userProfile) shareZone = profileUtil.getSharezone(userProfile) context = {} context.update(csrf(request)) context['userProfile'] = userProfile context['timeStamp'] = timeCreated context['streetAddress'] = streetAddress context['reputation'] = reputation context['city'] = city context['state'] = state context['sharezone'] = shareZone context.update(content.genBaseLoggedIn(request)) if contextArg: context.update(contextArg) return render_to_response('my_account.html', context)
def genBaseLoggedIn(request): results = dict() results.update(genSuper()) results['username'] = request.user.username results['community'] = profileUtil.getSharezone(profileUtil.getProfileFromUser(request.user)) results['first_name'] = request.user.first_name results['last_name'] = request.user.last_name #get pict location results['picture'] = None #get top sheds results['topSheds'] = None #get notifications results.update(getNotifications(request)) return results
def genBaseLoggedIn(request): results = dict() results.update(genSuper()) results['username'] = request.user.username results['community'] = profileUtil.getSharezone( profileUtil.getProfileFromUser(request.user)) results['first_name'] = request.user.first_name results['last_name'] = request.user.last_name #get pict location results['picture'] = None #get top sheds results['topSheds'] = None #get notifications results.update(getNotifications(request)) return results
def genJustRegistered(account, profile): results = genSuper() results['username'] = account.username results['first_name'] = account.first_name results['last_name'] = account.last_name results['picture'] = None results['topSheds'] = None sheds = shedUtil.getAllShedsJoinedBy(profile) sharezone = profileUtil.getSharezone(profile) sharezoneMembers = profileUtil.getAllProfilesInSharezone(sharezone) #not done results['tools'] = None results['sheds'] = sheds results['borrowed'] = None results['sharezone'] = sharezone results['sharezoneMembers'] = sharezoneMembers return addGoodRegisterNoti(results)
def genUserHome(request): results = genBaseLoggedIn(request) profile = profileUtil.getProfileFromUser(request.user) tools = toolUtil.getAllToolsOwnedBy(profile) sheds = shedUtil.getAllShedsJoinedBy(profile) #sheds = None borrowedTools = toolUtil.getAllToolsBorrowedBy(profile) #borrowedTools = None #print(profile) #results['notif'] = notifUtil.getAllActiveProfileNotifs(profile) sharezone = profileUtil.getSharezone(profile) sharezoneMembers = profileUtil.getAllProfilesInSharezone(sharezone) #not done results['tools'] = tools results['sheds'] = sheds results['borrowed'] = borrowedTools results['sharezone'] = sharezone results['sharezoneMembers'] = sharezoneMembers return results
def test_UpdateShareZone(self): """ """ profUtils.updateSharezone(self.getProfile, "Sandpeople") self.assertEqual (profUtils.getSharezone(self.getProfile), "Sandpeople")
def test_GetShareZone(self): """ """ self.assertEqual (profUtils.getSharezone(self.getProfile), "Jedi Temple")
def test_UpdateShareZone(self): """ """ profUtils.updateSharezone(self.getProfile, "Sandpeople") self.assertEqual(profUtils.getSharezone(self.getProfile), "Sandpeople")
def test_GetShareZone(self): """ """ self.assertEqual(profUtils.getSharezone(self.getProfile), "Jedi Temple")