def view_profile(request, username=None): if request.user.is_anonymous(): #tell user they need to be logged in to do that #add message flag that will display to user "you must be logged in to..." return HttpResponseRedirect('/accounts/login/') #redirect to login page else: if username is not None: try: userProfile = profileUtil.getProfileFromUser(User.objects.get(username=username)) except ObjectDoesNotExist: context = {} context['object'] = 'profile' context.update(content.genBaseLoggedIn(request)) return render_to_response("dne.html", context) else: userProfile = profileUtil.getProfileFromUser(request.user) toolsOwned = toolUtil.getAllToolsOwnedBy(userProfile) toolsBorrowed = toolUtil.getAllToolsBorrowedBy(userProfile) sheds = shedUtil.getAllShedsJoinedBy(userProfile) context = {} context.update(csrf(request)) context['currentUser'] = request.user context['userProfile'] = userProfile context['toolsOwned'] = toolsOwned context['toolsBorrowed'] = toolsBorrowed context['sheds'] = sheds context.update(content.genBaseLoggedIn(request)) return render_to_response('view_profile.html', context)
def view_profile(request, username=None): if request.user.is_anonymous(): #tell user they need to be logged in to do that #add message flag that will display to user "you must be logged in to..." return HttpResponseRedirect( '/accounts/login/') #redirect to login page else: if username is not None: try: userProfile = profileUtil.getProfileFromUser( User.objects.get(username=username)) except ObjectDoesNotExist: context = {} context['object'] = 'profile' context.update(content.genBaseLoggedIn(request)) return render_to_response("dne.html", context) else: userProfile = profileUtil.getProfileFromUser(request.user) toolsOwned = toolUtil.getAllToolsOwnedBy(userProfile) toolsBorrowed = toolUtil.getAllToolsBorrowedBy(userProfile) sheds = shedUtil.getAllShedsJoinedBy(userProfile) context = {} context.update(csrf(request)) context['currentUser'] = request.user context['userProfile'] = userProfile context['toolsOwned'] = toolsOwned context['toolsBorrowed'] = toolsBorrowed context['sheds'] = sheds context.update(content.genBaseLoggedIn(request)) return render_to_response('view_profile.html', context)
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