def edit_page(self, name): task = Backend("task").find(name) if not task: raise exc.HTTPNotFound("Not found") if not task.data: task.data = "" else: task.data = json_encode(task.data) return render_template("task.edit.html", task=task, statuses=TASK_STATUSES)
def login(self, username='', password=''): LOGGER.error('username=%s', username) username = username.strip() password = password.strip() user = Backend('user').find_by_username(username) if user and user.check(password): set_secure_cookie('auth', str(user.uid)) LOGGER.info('success') raise exc.HTTPFound(location='/task') return render_template('login.html')
def _decorator(*args, **kw): if request.user == _guest and request.path_info !='/login': raise exc.HTTPSeeOther(location='/login') user = request.user _role = user.role if user.is_banned() and (role and _role != 'root' and _role != role): raise render_template('403.html', role=role, banned=user.is_banned()) return f(*args, **kw)
def index(self, page=1): user = ctx.request.user if user.role != 'root': raise exc.HTTPFound(location='/user/%d/edit' % (user.uid)) page = int(page) users = Backend('user').paginate(page, 10) return render_template('user.index.html', users=users)
def index(self, status="all", name="", page=1): # process page , keep it within range(1, 2000) try: page = int(page) except TypeError: page = 1 if page > 2000: page = 2000 _status = TASK_STATUSES.get(status, 0) name = name.strip() tasks = Backend("task").take(name, _status, page) count = Backend("task").count(name, _status) glue = "?page=" if not name else "?name=%s&page=" % (name) tasks = Paginator(tasks, count, page, 20, "/task/status/%s" % (status), glue) return render_template( "task.index.html", name=name, status=status, statuses=TASK_STATUS_LIST, key_statuses=TASK_KEY_STATUSES, tasks=tasks, )
def add_page(self): return render_template('user.add.html', statuses=USER_STATUSES, roles=ROLES)
def login_page(self): if ctx.request.user.uid != 0: raise exc.HTTPFound('/task') return render_template('login.html')
def edit_page(self, uid): uid = int(uid) user = Backend('user').find(uid) if not user: raise exc.HTTPNotFound('Not Found') return render_template('user.edit.html', statuses=USER_STATUSES, roles=ROLES, user=user)
def index(self): return render_template('index.html')
def _404_page(self, *args, **kw): return render_template('404.html')
def add_page(self): return render_template("task.add.html")