def get_set(self,**kwargs): ifp = get_agent_ifp(json.loads(self.agent)) agent = models.Agent.objects.get(**ifp) if self.registration: state_set = models.ActivityState.objects.filter(agent=agent, activity_id=self.activity_id, registration_id=self.registration) else: state_set = models.ActivityState.objects.filter(agent=agent, activity_id=self.activity_id) return state_set
def get(self): ifp = get_agent_ifp(json.loads(self.agent)) agent = models.Agent.objects.get(**ifp) try: if self.registration: return models.ActivityState.objects.get(state_id=self.stateId, agent=agent, activity_id=self.activity_id, registration_id=self.registration) return models.ActivityState.objects.get(state_id=self.stateId, agent=agent, activity_id=self.activity_id) except models.ActivityState.DoesNotExist: err_msg = 'There is no activity state associated with the id: %s' % self.stateId raise IDNotFoundError(err_msg)
def agents_get(req_dict): rogueparams = set(req_dict['params']) - set(["agent"]) if rogueparams: raise ParamError("The get agent request contained unexpected parameters: %s" % ", ".join(rogueparams)) try: req_dict['params']['agent'] except KeyError: err_msg = "Error -- agents url, but no agent parameter.. the agent parameter is required" raise ParamError(err_msg) agent = json.loads(req_dict['params']['agent']) params = get_agent_ifp(agent) if not models.Agent.objects.filter(**params).exists(): raise IDNotFoundError("Error with Agent. The agent partial did not match any agents on record") req_dict['agent_ifp'] = params return req_dict