Beispiel #1
0
 def self(self):
     principal = self.handler.get_current_user()
     storage = zca.getUtility(IPersonStorage)
     person = storage.get_person(principal)
     result = Result()
     result.data = [
         Person(**person.get_properties())
     ]
     return result
Beispiel #2
0
    def attributes(self, person_id, app=None, key=None):
        storage = zca.getUtility(IPersonStorage)
        person = storage.get_person(person_id)

        result = Result()

        data = person.get_xattr(app, key)
        if data:
            result.data = [
                Attribute(person.get_xattr(app, key))
            ]

        return result
Beispiel #3
0
    def data(self, person_id):
        storage = zca.getUtility(IPersonStorage)
        person = storage.get_person(person_id)
        if not person:
            return Result(False, 101, 'unknown user id')

        if not person.viewable_by(self.handler.get_current_user()):
            return Result(False, 102, 'user is private')

        result = Result()
        result.data = [
            Person(**person.get_properties())
        ]

        return result
Beispiel #4
0
    def index(self):
        registry = zca.getUtility(IRegistry)
        data = [
            Config(
                version=registry.get('site.version', 'float'),
                website=registry.get('site.title'),
                host=registry.get('site.host'),
                contact=registry.get('site.contact'),
                ssl=registry.get('site.ssl_enabled', 'boolean'),
            )
        ]
        result = Result()
        result.data = data

        return result
Beispiel #5
0
    def index(self, person_id):
        storage = zca.getUtility(IActivityStorage)

        data = util.extract_data(self.handler, ['page', 'pagesize'])

        limit = int(data['pagesize'] or 0)
        offset = int(limit * (data['page'] or 0))
        activities = [
            a.data() for a in storage.get_activities(
                            person_id, limit, offset)
        ]

        result = Result()

        data = []
        for activity in activities:
            data.append(Activity(**activity))

        if data:
            result.data = data
        return result
Beispiel #6
0
    def check(self):
        login = self.request.get('login', None)
        password = self.request.get('password', None)

        if login is None:
            return Result(False, 101, 
                'please specify all mandatory fields ')

        auth = zca.getUtility(IAuthService)
        credentials = {
            'login': login,
            'password': password
        }

        if not auth.authenticate(credentials):
            return Result(False, 102, 'login not valid')

        principal = auth.principal(credentials)

        result = Result()
        result.data = [Person(personid=principal)]
        return result