Exemplo n.º 1
0
 def merge(self, other):
     """Consumes other and takes its children."""
     
     other.credentials.update(set__owner=self)
     other.characters.update(set__owner=self)
     
     LoginHistory.objects(user=other).update(set__user=self)
     
     from brave.core.group.model import Group
     from brave.core.application.model import Application, ApplicationGrant
     
     Group.objects(creator=other).update(set__creator=self)
     Application.objects(owner=other).update(set__owner=self)
     ApplicationGrant.objects(user=other).update(set__user=self)
     
     other.delete()
Exemplo n.º 2
0
    def merge(self, other):
        """Consumes other and takes its children."""

        other.credentials.update(set__owner=self)
        other.characters.update(set__owner=self)

        LoginHistory.objects(user=other).update(set__user=self)

        from brave.core.group.model import Group
        from brave.core.application.model import Application, ApplicationGrant

        Group.objects(creator=other).update(set__creator=self)
        Application.objects(owner=other).update(set__owner=self)
        ApplicationGrant.objects(user=other).update(set__user=self)

        other.delete()
Exemplo n.º 3
0
 def info(self, token):
     from brave.core.application.model import ApplicationGrant
     from brave.core.group.model import Group
     
     # Step 1: Get the appropraite grant.
     token = ApplicationGrant.objects.get(id=token, application=request.service)
     character = token.character
     
     # Step 2: Update info about the character from the EVE API
     mask, key = character.credential_multi_for((EVECharacterKeyMask.CHARACTER_SHEET,
      EVECharacterKeyMask.CHARACTER_INFO_PUBLIC, EVECharacterKeyMask.NULL))
     
     #User has no keys registered.
     if not key:
         return None
         
     key.pull()
     
     # Step 3: Match ACLs.
     tags = []
     for group in Group.objects(id__in=request.service.groups):
         if group.evaluate(token.user, character):
             tags.append(group.id)
     
     return dict(
             character = dict(id=character.identifier, name=character.name),
             corporation = dict(id=character.corporation.identifier, name=character.corporation.name),
             alliance = dict(id=character.alliance.identifier, name=character.alliance.name) if character.alliance else None,
             tags = tags,
             expires = None,
             mask = token.mask
         )
Exemplo n.º 4
0
    def get(self):
        if not is_administrator:
            raise HTTPNotFound

        groups = sorted(Group.objects(), key=lambda g: g.id)
        return 'brave.core.group.template.list_groups', dict(
            area='group',
            groups=groups,
        )
Exemplo n.º 5
0
    def get(self):
        if not is_administrator:
            raise HTTPNotFound

        groups = sorted(Group.objects(), key=lambda g: g.id)
        return 'brave.core.group.template.list_groups', dict(
            area='group',
            groups=groups,
        )
Exemplo n.º 6
0
    def create(self, id=None, title=None):
        if not id:
            return 'json:', dict(success=False, message=_("id required"))
        if not title:
            return 'json:', dict(success=False, message=_("title required"))
        g = Group.create(id, title, user)
        if not g:
            return 'json:', dict(
                success=False, message=_("group with that id already existed"))

        return 'json:', dict(success=True, id=g.id)
Exemplo n.º 7
0
    def post(self, id=None, title=None):
        if not id:
            return 'json:', dict(success=False,
                                 message=_("id required"))
        if not title:
            return 'json:', dict(success=False,
                                 message=_("title required"))
        g = Group.create(id, title, user)
        if not g:
            return 'json:', dict(success=False,
                                 message=_("group with that id already existed"))

        return 'json:', dict(success=True, id=g.id)
Exemplo n.º 8
0
    def info(self, token):
        from brave.core.application.model import ApplicationGrant
        from brave.core.group.model import Group

        # Step 1: Get the appropraite grant.
        token = ApplicationGrant.objects.get(id=token,
                                             application=request.service)
        character = token.character

        # Step 2: Update info about the character from the EVE API
        mask, key = character.credential_multi_for(
            (api.char.CharacterSheet.mask, api.char.CharacterInfoPublic.mask,
             EVECharacterKeyMask.NULL))

        # User has no keys registered.
        if not key:
            return None

        # Update key info, and if something goes wrong, abort the call.
        if not key.pull():
            return None

        # Step 3: Match ACLs.
        tags = []
        for group in Group.objects(id__in=request.service.groups):
            if group.evaluate(token.user, character):
                tags.append(group.id)

        return dict(character=dict(id=character.identifier,
                                   name=character.name),
                    corporation=dict(id=character.corporation.identifier,
                                     name=character.corporation.name),
                    alliance=dict(id=character.alliance.identifier,
                                  name=character.alliance.name)
                    if character.alliance else None,
                    tags=tags,
                    expires=None,
                    mask=token.mask)