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()
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 )
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, )
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)