Beispiel #1
0
    def get(self, key):
        mo = MidautumnObject.get_by_id(int(key))

        args = None

        if not mo:
            args = {'result': 'not_exist', 'key': key}
        else:
            args = {'result': 'success',
                    'objects': [mo.to_dict(current_user=self.current_user),]}

        self.response.headers['Content-Type'] = 'application/json'
        self.response.out.write(json.dumps(args))
Beispiel #2
0
    def post(self, key):
        user = self.current_user

        mo = MidautumnObject.get_by_id(int(key))

        args = None

        if not user:
            args = {'result': 'not_authorized'}
        elif not mo:
            args = {'result': 'not_exist', 'key': key}
        elif mo.owner.id != user.id:
            args = {'result': 'not_authorized'}
        else:
            mo.delete()
            args = {'result': 'success', 'key': key}

        self.response.headers['Content-Type'] = 'application/json'
        self.response.out.write(json.dumps(args))
Beispiel #3
0
    def get(self, key):
        pagename = None
        args = None

        mo = MidautumnObject.get_by_id(int(key))
        if mo == None:
            pagename = "object_not_found.html"
            args = {}
        else:
            pagename = "object.html"
            args = mo.to_dict(details=True)

        # current user related info
        if self.current_user:
            args['profile'] = self.current_user.profile

        dirname = os.path.dirname(__file__)
        path = os.path.join(dirname, 'view', pagename)
        self.response.out.write(template.render(path, args))