def test_GetAllMembersOfShed(self): """ """ #print (shedUtils.getAllMembersOfShed(self.getShed)) self.assertEqual(0, len(shedUtils.getAllMembersOfShed(self.getShed))) # this shed should have no people added yet self.getShed = Shed.objects.get(name = "Jake's Shed") self.assertIn (profUtils.getAllProfiles()[3], shedUtils.getAllMembersOfShed (self.getShed)) #Check if jake is in his own shed
def test_GetAllMembersOfShed(self): """ """ #print (shedUtils.getAllMembersOfShed(self.getShed)) self.assertEqual(0, len(shedUtils.getAllMembersOfShed( self.getShed))) # this shed should have no people added yet self.getShed = Shed.objects.get(name="Jake's Shed") self.assertIn(profUtils.getAllProfiles()[3], shedUtils.getAllMembersOfShed( self.getShed)) #Check if jake is in his own shed
def test_AddMemberToShed(self): """ """ shedUtils.addMemberToShed(self.getShed, profUtils.getAllProfiles()[2]) getShed = Shed.objects.get(name="Lightsaber Tools") self.assertIn(profUtils.getAllProfiles()[2], shedUtils.getAllMembersOfShed(self.getShed) ) #adding a member and then making sure he's there
def view_shed_page( request, id, contextArg): #contextArg is a dict to be added to the content dict if request.user.is_anonymous(): return HttpResponseRedirect("/accounts/login") else: if id is not None: try: shedObj = shedUtil.getShedFromID(id) except ObjectDoesNotExist: context = {} context['object'] = 'shed' context.update(content.genBaseLoggedIn(request)) return render_to_response("dne.html", context) else: context = {} context['object'] = 'shed' context.update(content.genBaseLoggedIn(request)) return render_to_response("dne.html", context) owner = shedUtil.getOwnerOfShed(shedObj) name = shedUtil.getNameOfShed(shedObj) admins = shedUtil.getAllAdminsOfShed(shedObj) isAdmin = False for admin in admins: if admin == profileUtil.getProfileFromUser(request.user): isAdmin = True members = shedUtil.getAllMembersOfShed(shedObj) tools = toolUtil.getAllToolsInShed(shedObj) userProfile = profileUtil.getProfileFromUser(request.user) meetsMinRep = userProfile.reputation >= shedObj.minimumReputation shedMembership = shedUtil.checkForMembership(userProfile, id) actions = actionUtil.getProfileAction( profileUtil.getProfileFromUser(request.user)) actionRequest = None pendingRequest = False for action in actions: if action.shed == shedObj: actionRequest = action if actionRequest: if actionRequest.currrentState == "userShedRequest" or actionRequest.currrentState == "acceptDeny": pendingRequest = True context = {} context.update(csrf(request)) context['shed'] = shedObj context['owner'] = owner context['currentUser'] = profileUtil.getProfileFromUser(request.user) context['name'] = name context['admins'] = admins context['members'] = members context['tools'] = tools context['meetsMin'] = meetsMinRep context['alreadyMember'] = shedMembership context['isAdmin'] = isAdmin context['pendingRequest'] = pendingRequest context.update(content.genBaseLoggedIn(request)) if contextArg: context.update(contextArg) return render_to_response('shed_page.html', context)
def test_RemoveMemberFromShed(self): """ """ shedUtils.removeMemberFromShed(self.getShed, profUtils.getAllProfiles()[2]) self.getShed = Shed.objects.get(name="Lightsaber Tools") self.assertNotIn(profUtils.getAllProfiles()[2], shedUtils.getAllMembersOfShed(self.getShed) ) #taking him out and then making sure he's not there
def view_shed_page(request, id, contextArg):#contextArg is a dict to be added to the content dict if request.user.is_anonymous(): return HttpResponseRedirect("/accounts/login") else: if id is not None: try: shedObj = shedUtil.getShedFromID(id) except ObjectDoesNotExist: context = {} context['object'] = 'shed' context.update(content.genBaseLoggedIn(request)) return render_to_response("dne.html", context) else: context = {} context['object'] = 'shed' context.update(content.genBaseLoggedIn(request)) return render_to_response("dne.html", context) owner = shedUtil.getOwnerOfShed(shedObj) name = shedUtil.getNameOfShed(shedObj) admins = shedUtil.getAllAdminsOfShed(shedObj) isAdmin = False for admin in admins: if admin == profileUtil.getProfileFromUser(request.user): isAdmin = True members = shedUtil.getAllMembersOfShed(shedObj) tools = toolUtil.getAllToolsInShed(shedObj) userProfile = profileUtil.getProfileFromUser(request.user) meetsMinRep = userProfile.reputation >= shedObj.minimumReputation shedMembership = shedUtil.checkForMembership(userProfile, id) actions = actionUtil.getProfileAction(profileUtil.getProfileFromUser(request.user)) actionRequest = None pendingRequest = False for action in actions: if action.shed == shedObj: actionRequest = action if actionRequest: if actionRequest.currrentState == "userShedRequest" or actionRequest.currrentState == "acceptDeny": pendingRequest = True context = {} context.update(csrf(request)) context['shed'] = shedObj context['owner'] = owner context['currentUser'] = profileUtil.getProfileFromUser(request.user) context['name'] = name context['admins'] = admins context['members'] = members context['tools'] = tools context['meetsMin'] = meetsMinRep context['alreadyMember'] = shedMembership context['isAdmin'] = isAdmin context['pendingRequest'] = pendingRequest context.update(content.genBaseLoggedIn(request)) if contextArg: context.update(contextArg) return render_to_response('shed_page.html', context)
def test_RemoveMemberFromShed(self): """ """ shedUtils.removeMemberFromShed (self.getShed, profUtils.getAllProfiles()[2]) self.getShed = Shed.objects.get (name = "Lightsaber Tools") self.assertNotIn (profUtils.getAllProfiles()[2], shedUtils.getAllMembersOfShed(self.getShed)) #taking him out and then making sure he's not there
def test_AddMemberToShed(self): """ """ shedUtils.addMemberToShed (self.getShed, profUtils.getAllProfiles()[2]) getShed = Shed.objects.get (name = "Lightsaber Tools") self.assertIn (profUtils.getAllProfiles()[2], shedUtils.getAllMembersOfShed (self.getShed)) #adding a member and then making sure he's there