Пример #1
0
def _q_index(req):
    app_id = req.get_form_var("app_id", "")
    app = App.get(app_id)

    name = req.get_form_var("name", "")
    x = req.get_form_var("x", 0)
    y = req.get_form_var("y", 0)
    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

    parent_id = req.get_form_var("parent_id", 0)
    page_type = req.get_form_var("type", Page.TYPE_NORMAL)
    parent = parent_id and Page.get(parent_id)
    rect = None
    if req.get_method() == 'POST':
        if w and h:
            rect = Rect.get(Rect.new(x, y, w, h))
        photo = req.get_form_var("photo", None)
        if name and app.can_admin(req.user):
            filename = photo and photo.tmp_filename
            page_id = Page.new(app, name, rect, filename, parent_id, page_type)
            if req.get_form_var("output", None) == 'json':
                req.response.set_content_type('application/json; charset=utf-8')
                ret = { 'err': 'ok', 'html': stf('/app.html', 'page_list', app=app, req=req) }
                return json.dumps(ret)
    else:
        rect = Rect(0, x*app.zoomout, y*app.zoomout, w*app.zoomout, h*app.zoomout)
        return stf('/app.html', 'page_form', app=app, rect=rect, parent=parent, page_type=page_type)
Пример #2
0
def _q_index(req):
    if req.get_method() == "POST":
        name = req.get_form_var("app_name", None)
        icon = req.get_form_var("app_icon", None)
        screen_id = req.get_form_var("app_screen", None)
        screen = Screen.get(screen_id)
        if name and icon and req.user and screen:
            filename = icon.tmp_filename
            app_id = App.new(req.user.id, name, filename, screen.id)
            if req.get_form_var("output", None) == "json":
                req.response.set_content_type("application/json; charset=utf-8")
                total, apps = App.gets_by_user(req.user.id)
                ret = {"err": "ok", "html": stf("/apps.html", "app_list", apps=apps)}
                return json.dumps(ret)
            app = App.get(app_id)
            if app:
                return req.redirect(app.path)
Пример #3
0
 def remove(self, req):
     app = self.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")
             app.remove()
             total, apps = App.gets_by_user(req.user.id)
             ret = {"err": "ok", "html": stf("/apps.html", "app_list", apps=apps)}
             return json.dumps(ret)
Пример #4
0
 def edit(self, req):
     app = self.app
     if req.get_method() == "POST" and app.can_admin(req.user):
         name = req.get_form_var("app_name", None)
         icon = req.get_form_var("app_icon", None)
         if name or icon:
             filename = icon and icon.tmp_filename
             app.update(name, filename)
             if req.get_form_var("output", None) == "json":
                 req.response.set_content_type("application/json; charset=utf-8")
                 total, apps = App.gets_by_user(req.user.id)
                 ret = {"err": "ok", "html": stf("/apps.html", "app_list", apps=apps)}
                 return json.dumps(ret)
     return stf("/apps.html", "app_edit_dialog", app=app)
Пример #5
0
def admin(req):
    if not req.user:
        return req.redirect('/login')
    if req.user.email == "*****@*****.**":
        if req.get_method() == "POST":
            name = req.get_form_var("name", None)
            os = req.get_form_var("os", None)
            w = req.get_form_var("w", 0)
            h = req.get_form_var("h", 0)
            iw = req.get_form_var("iw", 0)
            ih = req.get_form_var("ih", 0)
            vk = req.get_form_var("vk", None)
            if name and os:
                id = Screen.new(name, os, w, h, iw, ih, vk == 'Y')
                if id:
                    return req.redirect("/admin")
        user_count = User.count()
        app_count = App.count()
        screens = Screen.gets()
        return st("/admin.html", **locals())
    raise AccessError("not admin")
Пример #6
0
def demos(req):
    total, apps = App.gets_by_user(req.user.id)
    screens = [DEFAULT_SCREEN] + Screen.gets()
    return st("/apps.html", **locals())
Пример #7
0
 def app(self):
     return App.get(self.app_id)
Пример #8
0
def _q_lookup(req, id):
    app = App.get(id)
    if app:
        return AppUI(req, app)
    return TraversalError("no such app")