예제 #1
0
    def __init__(self, key):
        super(CharacterInterface, self).__init__()

        try:
            self.key = EVECharacter.objects.get(id=key)
        except EVECharacter.DoesNotExist:
            raise HTTPNotFound()

        if self.key.owner.id != user.id:
            raise HTTPNotFound()
예제 #2
0
    def __init__(self, app):
        super(ApplicationInterface, self).__init__()

        try:
            self.app = Application.objects.get(id=app)
        except Application.DoesNotExist:
            raise HTTPNotFound()

        if self.app.owner.id != user.id and not user.admin:
            raise HTTPNotFound()
예제 #3
0
    def __init__(self, grant):
        super(GrantInterface, self).__init__()

        try:
            self.grant = ApplicationGrant.objects.get(id=grant)
        except ApplicationGrant.DoesNotExist:
            raise HTTPNotFound()

        if self.grant.user.id != user.id:
            raise HTTPNotFound()
예제 #4
0
    def __init__(self, char):
        super(CharacterInterface, self).__init__()

        try:
            self.char = EVECharacter.objects.get(id=char)
        except EVECharacter.DoesNotExist:
            raise HTTPNotFound()

        if (not self.char.owner
                or self.char.owner.id != user.id) and not user.admin:
            raise HTTPNotFound()
예제 #5
0
    def __init__(self, key):
        super(KeyInterface, self).__init__()
        
        try:
            self.key = EVECredential.objects.get(id=key)
        except EVECredential.DoesNotExist:
            raise HTTPNotFound()

        if self.key.owner.id != user.id:
            raise HTTPNotFound()
        
        self.index = KeyIndex(self.key)
예제 #6
0
    def __init__(self, userID):
        super(AccountInterface, self).__init__()

        try:
            self.user = User.objects.get(id=userID)
        except User.DoesNotExist:
            raise HTTPNotFound()
        except ValidationError:
            # Handles improper objectIDs
            raise HTTPNotFound()

        if self.user.id != user.id and not user.admin:
            raise HTTPNotFound()
예제 #7
0
    def post(self, keyID=None, keyMask=None, violation=None):

        # Have to be an admin to access admin pages.
        if not is_administrator:
            raise HTTPNotFound()

        # Seed the initial results.
        keys = EVECredential.objects()

        # Limit to keys with the specified ID.
        if keyID:
            keys = keys.filter(key=keyID)

        # Limit to keys with the specified Mask.
        if keyMask:
            keys = keys.filter(_mask=keyMask)

        # Limit to keys with the specified violation.
        if violation.lower() == "none":
            keys = keys.filter(violation=None)
        elif violation:
            keys = keys.filter(violation__iexact=violation)

        return 'brave.core.admin.template.searchKey', dict(area='admin',
                                                           result=keys,
                                                           success=True)
예제 #8
0
    def get(self):

        # Have to be an admin to access admin pages.
        if not is_administrator:
            raise HTTPNotFound()

        return 'brave.core.admin.template.searchKey', dict(area='admin')
예제 #9
0
    def post(self, username=None, userMethod=None, ip=None, duplicate=None):

        # Have to be an admin to access admin pages.
        if not is_administrator:
            raise HTTPNotFound()

        # Seed the initial results.
        users = User.objects()

        # Limit to users with the specified username.
        if username:
            if userMethod == 'contains':
                users = users.filter(username__icontains=username)
            elif userMethod == 'starts':
                users = users.filter(username__istartswith=username)
            elif userMethod == 'is':
                users = users.filter(username__iexact=username)
            else:
                return 'json:', dict(
                    success=False,
                    message=_("You broke the web page. Good Job."))

        # Limit to users with the specified IP address.
        if ip:
            users = users.filter(host=ip)

        # Limit to users with the specified duplicate status
        if duplicate.lower() == "ip":
            users = users.filter(other_accs_IP__exists=True)
        elif duplicate.lower() == "char":
            users = users.filter(other_accs_char_key__exists=True)

        return 'brave.core.admin.template.searchUser', dict(area='admin',
                                                            result=users,
                                                            success=True)
예제 #10
0
    def post(self, **kw):
        if not request.is_xhr:
            raise HTTPNotFound()

        u = user._current_obj()
        valid, invalid = manage_form().native(kw)

        app = Application(owner=u,
                          **{
                              k: v
                              for k, v in valid.iteritems()
                              if k in ('name', 'description', 'groups', 'site',
                                       'contact')
                          })

        app.key.public = valid['key']['public']
        app.mask.required = valid['required'] or 0
        app.mask.optional = valid['optional'] or 0

        if valid['development'] == "true" or valid['development'] == "True":
            app.development = True
        else:
            app.development = False

        app.save()

        return 'json:', dict(success=True, location='/application/manage/')
예제 #11
0
    def get(self):
        if (not self.char.owner
                or self.char.owner.id != user.id) and not user.admin:
            raise HTTPNotFound()

        return 'brave.core.character.template.charDetails', dict(
            char=self.char, area='admin')
예제 #12
0
    def __init__(self, id):
        super(OneGroupController, self).__init__()

        try:
            self.group = Group.objects.get(id=id)
        except Group.DoesNotExist:
            raise HTTPNotFound()
예제 #13
0
    def post(self, **kw):
        if not request.is_xhr:
            raise HTTPNotFound()

        app = self.app
        valid, invalid = manage_form().native(kw)

        for k in ('name', 'description', 'groups', 'site', 'contact'):
            setattr(app, k, valid[k])

        if valid['key']['public'].startswith('-'):
            # Assume PEM format.
            valid['key']['public'] = hexlify(
                VerifyingKey.from_pem(valid['key']['public']).to_string())

        app.key.public = valid['key']['public']
        app.mask.required = valid['required'] or 0
        app.mask.optional = valid['optional'] or 0

        if valid['development'] == "true" or valid['development'] == "True":
            app.development = True
        else:
            app.development = False

        app.save()

        return 'json:', dict(success=True, )
예제 #14
0
 def __init__(self, app):
     super(ApplicationInterface, self).__init__()
     
     try:
         self.app = Application.objects.get(id=app)
     except Application.DoesNotExist:
         raise HTTPNotFound()
     
     self.authorize = ApplicationAuthorization(self.app)
예제 #15
0
    def get(self, admin=False):
        if admin and not is_administrator:
            raise HTTPNotFound()

        characters = user.characters
        if admin:
            characters = EVECharacter.objects()

        return 'brave.core.character.template.list', dict(area='chars',
                                                          admin=bool(admin),
                                                          records=characters)
예제 #16
0
    def put(self):
        if self.key.owner.id != user.id:
            raise HTTPNotFound()

        u = user._current_obj()
        u.primary = self.key
        u.save()

        if request.is_xhr:
            return 'json:', dict(success=True)

        raise HTTPFound(location='/character/')
예제 #17
0
    def post(self,
             character=None,
             charMethod=None,
             alliance=None,
             corporation=None,
             group=None):

        # Have to be an admin to access admin pages.
        if not is_administrator:
            raise HTTPNotFound()

        # Seed the initial results.
        chars = EVECharacter.objects()

        # Go through and check all of the possible posted values

        # Limit chars to the character name entered.
        if character:
            if charMethod == 'contains':
                chars = chars.filter(name__icontains=character)
            elif charMethod == 'starts':
                chars = chars.filter(name__istartswith=character)
            elif charMethod == 'is':
                chars = chars.filter(name__iexact=character)
            else:
                return 'json:', dict(
                    success=False,
                    message=_("You broke the web page. Good Job."))

        # Limit to characters in the specified alliance.
        if alliance:
            alliance = EVEAlliance.objects(name=alliance).first()
            chars = chars.filter(alliance=alliance)

        # Limit to characters in the specified corporation.
        if corporation:
            corporation = EVECorporation.objects(name=corporation).first()
            chars = chars.filter(corporation=corporation)

        # Limit to characters in the specified group.
        if group:
            groupList = []
            for c in chars:
                if group in c.tags:
                    groupList.append(c.id)

            chars = chars.filter(id__in=groupList)

        return 'brave.core.admin.template.searchChar', dict(area='admin',
                                                            result=chars,
                                                            success=True)
예제 #18
0
    def ar(self, ar):
        if not session.get('ar', None) == ar:
            session['ar'] = ar
            session.save()
            raise HTTPFound(
                location='/account/authenticate?redirect=%2Fauthorize%2F{0}'.
                format(ar))

        try:
            return AuthenticationRequest.objects.get(id=ar,
                                                     user=None,
                                                     grant=None)
        except AuthenticationRequest.DoesNotExist:
            raise HTTPNotFound()
예제 #19
0
    def get(self, admin=False):
        admin = boolean(admin)

        if admin and not is_administrator:
            raise HTTPNotFound()

        credentials = user.credentials
        if admin:
            #Don't send the verification code for the API keys.
            credentials = EVECredential.objects.only('violation', 'key',
                                                     'verified', 'owner')

        return 'brave.core.key.template.list', dict(area='keys',
                                                    admin=admin,
                                                    records=credentials)
예제 #20
0
    def get(self, admin=False):
        if admin and not is_administrator:
            raise HTTPNotFound()

        return 'brave.core.account.template.settings', dict()