コード例 #1
0
ファイル: Commitment.py プロジェクト: Punto0/valuenetwork
 def resolve_involved_agents(self, args, context, info):
     involved = []
     if self.provider:
         involved.append(formatAgent(self.provider))
     events = self.fulfillment_events.all()
     for event in events:
         if event.provider:
             involved.append(formatAgent(event.provider))
     return list(set(involved))
コード例 #2
0
ファイル: Commitment.py プロジェクト: andreswebs/valuenetwork
 def resolve_involved_agents(self, context, **args):  #args, context, info):
     involved = []
     if self.provider:
         involved.append(formatAgent(self.provider))
     events = self.fulfillment_events.all()
     for event in events:
         if event.provider:
             involved.append(formatAgent(event.provider))
     return list(set(involved))
コード例 #3
0
ファイル: Agent.py プロジェクト: Punto0/valuenetwork
    def mutate(cls, root, args, context, info):
        id = args.get('id')
        name = args.get('name')
        image = args.get('image')
        note = args.get('note')
        primary_location_id = args.get('primary_location_id')
        email = args.get('email')

        agent = EconomicAgent.objects.get(pk=id)
        if agent:
            if note:
                agent.description = note
            if image:
                agent.photo_url = image
            if name:
                agent.name = name
            if primary_location_id:
                agent.primary_location = Location.objects.get(
                    pk=primary_location_id)
            if email:
                agent.email = email

            user_agent = AgentUser.objects.get(user=context.user).agent
            is_authorized = user_agent.is_authorized(object_to_mutate=agent)
            if is_authorized:
                agent.save()
            else:
                raise PermissionDenied(
                    'User not authorized to perform this action.')

        return UpdatePerson(person=formatAgent(agent))
コード例 #4
0
ファイル: Agent.py プロジェクト: FreedomCoop/valuenetwork
    def mutate(cls, root, args, context, info):
        id = args.get('id')
        name = args.get('name')
        image = args.get('image')
        note = args.get('note')
        primary_location_id = args.get('primary_location_id')
        email = args.get('email')

        agent = EconomicAgent.objects.get(pk=id)
        if agent:
            if note:
                agent.description = note
            if image:
                agent.photo_url = image
            if name:
                agent.name = name
            if primary_location_id:
                agent.primary_location = Location.objects.get(pk=primary_location_id)
            if email:
                agent.email = email

            user_agent = AgentUser.objects.get(user=context.user).agent
            is_authorized = user_agent.is_authorized(object_to_mutate=agent)
            if is_authorized:
                agent.save()
            else:
                raise PermissionDenied('User not authorized to perform this action.')

        return UpdateOrganization(organization=formatAgent(agent))
コード例 #5
0
ファイル: Agent.py プロジェクト: Punto0/valuenetwork
 def resolve_agent(self, args, *rargs):
     id = args.get('id')
     if id is not None:
         agent = EconomicAgent.objects.get(pk=id)
         if agent:
             return formatAgent(agent)
     raise PermissionDenied("Cannot find requested agent")
コード例 #6
0
ファイル: Agent.py プロジェクト: FreedomCoop/valuenetwork
 def resolve_agent(self, args, *rargs):
     id = args.get('id')
     if id is not None:
         agent = EconomicAgent.objects.get(pk=id)
         if agent:
             return formatAgent(agent)
     raise PermissionDenied("Cannot find requested agent")
コード例 #7
0
 def resolve_person(self, args, context, info):
     id = args.get('id')
     if id is not None:
         person = EconomicAgent.objects.get(pk=id)
         if person:
             if person.agent_type.party_type == "individual":
                 return formatAgent(person)
     return None
コード例 #8
0
ファイル: Person.py プロジェクト: FreedomCoop/valuenetwork
 def resolve_person(self, args, context, info):
     id = args.get('id')
     if id is not None:
         person = EconomicAgent.objects.get(pk=id)
         if person:
             if person.agent_type.party_type == "individual":
                 return formatAgent(person)
     return None
コード例 #9
0
 def resolve_organization(self, args, context, info):
     id = args.get('id')
     if id is not None:
         org = EconomicAgent.objects.get(pk=id)
         if org:
             if org.agent_type.party_type == "individual":
                 return None
             else:
                 return formatAgent(org)
     return None
コード例 #10
0
 def resolve_organization(self, args, context, info):
     id = args.get('id')
     if id is not None:
         org = EconomicAgent.objects.get(pk=id)
         if org:
             if org.agent_type.party_type == "individual":
                 return None
             else:
                 return formatAgent(org)
     return None
コード例 #11
0
 def resolve_fc_organizations(self, args, context, info):
     joining_style = args.get("joining_style")
     visibility = args.get("visibility")
     orgs = Project.objects.all()
     if visibility:
         orgs = orgs.filter(visibility=visibility)
     if joining_style:
         orgs = orgs.filter(joining_style=joining_style)
     org_agents = []
     for org in orgs:
         org_agents.append(formatAgent(org.agent))
     return org_agents
コード例 #12
0
 def resolve_fc_organizations(self, args, context, info):
     joining_style = args.get("joining_style")
     visibility = args.get("visibility")
     orgs = Project.objects.all()
     if visibility:
         orgs = orgs.filter(visibility=visibility)
     if joining_style:
         orgs = orgs.filter(joining_style=joining_style)
     org_agents = []
     for org in orgs:
         org_agents.append(formatAgent(org.agent))
     return org_agents
コード例 #13
0
ファイル: Agent.py プロジェクト: FreedomCoop/valuenetwork
    def mutate(cls, root, args, context, info):
        id = args.get('id')
        agent = EconomicAgent.objects.get(pk=id)
        if agent:
            if agent.is_deletable():
                user_agent = AgentUser.objects.get(user=context.user).agent
                #is_authorized = user_agent.is_authorized(context_agent_id=agent.id) TODO: what should be the rule?
                #if is_authorized:
                agent.delete()
                #else:
                #    raise PermissionDenied('User not authorized to perform this action.')
            else:
                raise PermissionDenied("Organization has activity or relationships and cannot be deleted.")

        return DeleteOrganization(organization=formatAgent(agent))
コード例 #14
0
    def mutate(cls, root, args, context, info):
        #import pdb; pdb.set_trace()
        name = args.get('name')
        image = args.get('image')
        note = args.get('note')
        primary_location_id = args.get('primary_location_id')
        primary_phone = args.get('primary_phone')
        email = args.get('email')
        type = args.get('type')

        if not note:
            note = ""
        if not image:
            image = ""
        if primary_location_id:
            location = Location.objects.get(pk=primary_location_id)
        else:
            location = None
        get_type = None
        if type:
            get_type = AgentType.objects.get(name=type)
        if not type:
            get_types = AgentType.objects.get(party_type="org")
            if get_types:
                get_type = get_types[0]

        agent = EconomicAgent(
            name=name,
            nick=name,
            agent_type=get_type,
            photo_url=image,
            description=note,
            primary_location=location,
            phone_primary=primary_phone,
            email=email,
            created_by=context.user,
        )

        user_agent = AgentUser.objects.get(user=context.user).agent
        is_authorized = user_agent.is_authorized(object_to_mutate=agent)
        if is_authorized:
            agent.save()
        else:
            raise PermissionDenied(
                'User not authorized to perform this action.')

        return CreateOrganization(organization=formatAgent(agent))
コード例 #15
0
ファイル: Agent.py プロジェクト: FreedomCoop/valuenetwork
    def mutate(cls, root, args, context, info):
        #import pdb; pdb.set_trace()
        name = args.get('name')
        image = args.get('image')
        note = args.get('note')
        primary_location_id = args.get('primary_location_id')
        primary_phone = args.get('primary_phone')
        email = args.get('email')
        type = args.get('type')

        if not note:
            note = ""
        if not image:
            image = ""
        if primary_location_id:
            location = Location.objects.get(pk=primary_location_id)
        else:
            location = None
        get_type = None
        if type:
            get_type = AgentType.objects.get(name=type)
        if not type:
            get_types = AgentType.objects.get(party_type="org")
            if get_types:
                get_type = get_types[0]

        agent = EconomicAgent(
            name = name,
            nick = name,
            agent_type = get_type,
            photo_url = image,
            description = note,
            primary_location = location,
            phone_primary = primary_phone,
            email = email,
            created_by=context.user,
        )

        user_agent = AgentUser.objects.get(user=context.user).agent
        is_authorized = user_agent.is_authorized(object_to_mutate=agent)
        if is_authorized:
            agent.save()
        else:
            raise PermissionDenied('User not authorized to perform this action.')

        return CreateOrganization(organization=formatAgent(agent))
コード例 #16
0
    def mutate(cls, root, args, context, info):
        id = args.get('id')
        agent = EconomicAgent.objects.get(pk=id)
        if agent:
            if agent.is_deletable():
                user_agent = AgentUser.objects.get(user=context.user).agent
                #is_authorized = user_agent.is_authorized(context_agent_id=agent.id) TODO: what should be the rule?
                #if is_authorized:
                agent.delete()
                #else:
                #    raise PermissionDenied('User not authorized to perform this action.')
            else:
                raise PermissionDenied(
                    "Organization has activity or relationships and cannot be deleted."
                )

        return DeleteOrganization(organization=formatAgent(agent))
コード例 #17
0
 def resolve_provider(self, args, *rargs):
     return formatAgent(self.provider)
コード例 #18
0
ファイル: EconomicEvent.py プロジェクト: Punto0/valuenetwork
 def resolve_scope(self, args, *rargs):
     return formatAgent(self.scope)
コード例 #19
0
ファイル: EconomicEvent.py プロジェクト: Punto0/valuenetwork
 def resolve_receiver(self, args, *rargs):
     return formatAgent(self.receiver)
コード例 #20
0
ファイル: EconomicEvent.py プロジェクト: Punto0/valuenetwork
 def resolve_provider(self, args, *rargs):
     return formatAgent(self.provider)
コード例 #21
0
ファイル: Exchange.py プロジェクト: valueflows/valuenetwork
 def resolve_involved_agents(self, args, context, info):
     agents = self.related_agents()
     formatted_agents = []
     for agent in agents:
         formatted_agents.append(formatAgent(agent))
     return formatted_agents
コード例 #22
0
ファイル: Plan.py プロジェクト: FreedomCoop/valuenetwork
 def resolve_created_by(self, args, *rargs):
     return formatAgent(self.created_by_agent)
コード例 #23
0
 def resolve_agent(self, args, *rargs):
     return formatAgent(self.user.agent.agent)
コード例 #24
0
 def resolve_object(self, args, *rargs):
     return formatAgent(self.object)
コード例 #25
0
ファイル: Exchange.py プロジェクト: FreedomCoop/valuenetwork
 def resolve_involved_agents(self, args, context, info):
     agents = self.related_agents()
     formatted_agents = []
     for agent in agents:
         formatted_agents.append(formatAgent(agent))
     return formatted_agents
コード例 #26
0
 def resolve_scope(self, context, **args):  #args, *rargs):
     return formatAgent(self.scope)
コード例 #27
0
 def resolve_validated_by(self, args, *rargs):
     return formatAgent(self.validated_by)
コード例 #28
0
ファイル: Plan.py プロジェクト: andreswebs/valuenetwork
 def resolve_created_by(self, context, **args):  #args, *rargs):
     return formatAgent(self.created_by_agent)
コード例 #29
0
ファイル: Agent.py プロジェクト: Punto0/valuenetwork
 def resolve_my_agent(self, args, *rargs):
     agentUser = AgentUser.objects.filter(user=self.user).first()
     agent = agentUser.agent
     if agent:
         return formatAgent(agent)
     raise PermissionDenied("Cannot find requested agent")
コード例 #30
0
 def resolve_validated_by(self, args, *rargs):
     return formatAgent(self.validated_by)
コード例 #31
0
 def resolve_receiver(self, args, *rargs):
     return formatAgent(self.receiver)
コード例 #32
0
 def resolve_scope(self, args, *rargs):
     return formatAgent(self.scope)
コード例 #33
0
ファイル: Process.py プロジェクト: FreedomCoop/valuenetwork
 def resolve_working_agents(self, args, context, info):
     agents = self.all_working_agents()
     formatted_agents = []
     for agent in agents:
         formatted_agents.append(formatAgent(agent))
     return formatted_agents
コード例 #34
0
 def resolve_agent(self, args, *rargs):
     return formatAgent(self.agent)
コード例 #35
0
 def resolve_working_agents(self, args, context, info):
     agents = self.all_working_agents()
     formatted_agents = []
     for agent in agents:
         formatted_agents.append(formatAgent(agent))
     return formatted_agents
コード例 #36
0
 def resolve_receiver(self, context, **args):  #args, *rargs):
     return formatAgent(self.receiver)
コード例 #37
0
ファイル: Agent.py プロジェクト: FreedomCoop/valuenetwork
 def resolve_my_agent(self, args, *rargs):
     agentUser = AgentUser.objects.filter(user=self.user).first()
     agent = agentUser.agent
     if agent:
         return formatAgent(agent)
     raise PermissionDenied("Cannot find requested agent")
コード例 #38
0
 def resolve_provider(self, context, **args):  #args, *rargs):
     return formatAgent(self.provider)
コード例 #39
0
 def resolve_context_agent(self, args, *rargs):
     return formatAgent(self.context_agent)