Exemplo n.º 1
0
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)
Exemplo n.º 2
0
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)
Exemplo n.º 3
0
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
Exemplo n.º 4
0
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
Exemplo n.º 5
0
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)
Exemplo n.º 6
0
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)
Exemplo n.º 7
0
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
Exemplo n.º 8
0
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
Exemplo n.º 9
0
 def test_UpdateShareZone(self):
     """
     """
     profUtils.updateSharezone(self.getProfile, "Sandpeople")
     self.assertEqual (profUtils.getSharezone(self.getProfile), "Sandpeople")
Exemplo n.º 10
0
 def test_GetShareZone(self):
     """
     """
     self.assertEqual (profUtils.getSharezone(self.getProfile), "Jedi Temple")
Exemplo n.º 11
0
 def test_UpdateShareZone(self):
     """
     """
     profUtils.updateSharezone(self.getProfile, "Sandpeople")
     self.assertEqual(profUtils.getSharezone(self.getProfile), "Sandpeople")
Exemplo n.º 12
0
 def test_GetShareZone(self):
     """
     """
     self.assertEqual(profUtils.getSharezone(self.getProfile),
                      "Jedi Temple")