Beispiel #1
0
 def add_action(self, req):
     page = self.page
     app = page.app
     if app.can_admin(req.user):
         x = req.get_form_var('x', None)
         y = req.get_form_var('y', None)
         w = req.get_form_var('w', None)
         h = req.get_form_var('h', None)
         x = x and str(x).isdigit() and int(x) or 0
         y = y and str(y).isdigit() and int(y) or 0
         w = w and str(w).isdigit() and int(w) or 0
         h = h and str(h).isdigit() and int(h) or 0
         type = req.get_form_var('type', None)
         dismiss = req.get_form_var('dismiss', None)
         to_page_id = req.get_form_var('to_page', 0)
         if req.get_method() == "GET":
             rect = Rect(0, x, y, w, h)
             return stf('/app.html', 'action_form', page=page, rect=rect, type=type)
         elif req.get_method() == "POST":
             if req.get_form_var("output", None) == 'json':
                 req.response.set_content_type('application/json; charset=utf-8')
                 rect = Rect.get(Rect.new(x, y, w, h))
                 Action.new(page.id, rect, type, dismiss, to_page_id)
                 ret = { 'err': 'ok' }
                 ret['html'] = stf('/app.html', 'page_worktable', p=page, req=req)
                 return json.dumps(ret)
     return AccessError("need owner")
Beispiel #2
0
 def remove_action(self, req):
     page = self.page
     app = page.app
     if req.get_method() == "POST" and app.can_admin(req.user):
         if req.get_form_var("output", None) == 'json':
             req.response.set_content_type('application/json; charset=utf-8')
             action_id = req.get_form_var("action_id", None)
             action = action_id and Action.get(action_id)
             if action:
                 action.remove()
             ret = { 'err': 'ok' }
             return json.dumps(ret)
     return AccessError("need owner")