def approve_vacation(v_id): if not current_user.is_superuser(): abort(401) vacation = models.VacationItem.query.filter_by(id=v_id).first_or_404() vacation.approved = True db.session.commit() return redirect(url_for('dashboard'))
def delete_vacation(v_id): if not current_user.is_superuser(): vacation = models.VacationItem.query.filter_by(user=current_user, id=v_id).first_or_404() else: vacation = models.VacationItem.query.filter_by(id=v_id).first_or_404() db.session.delete(vacation) db.session.commit() return redirect(url_for('dashboard'))
def dashboard(): vacations_bulk = models.VacationItem.query.filter_by(approved=True).order_by( models.VacationItem.approved) data = [] for vacation in vacations_bulk: start = datetime.strftime(vacation.start, "%Y-%m-%dT%H:%M:%S") end = datetime.strftime(vacation.end + timedelta(days=1), "%Y-%m-%dT%H:%M:%S") v = { 'start': start, 'end': end, 'title': vacation.user.email.split('@')[0] } data.append(v) if not current_user.is_superuser(): user_vacations = models.VacationItem.query.filter_by(user=current_user).order_by(models.VacationItem.approved).all() else: user_vacations = models.VacationItem.query.all() return render_template('dashboard.html', events=json.dumps(data), u_v=user_vacations)
def is_accessible(self): return ( not AUTHENTICATE or (not current_user.is_anonymous() and current_user.is_superuser()) )
def get_navigation(): is_superuser = current_user.is_superuser() is_admin = current_user.is_administrator() is_manager = current_user.is_manager() is_operator = current_user.is_operator() items = [] app_menu = current_user.app_menu def _item(key): return key, '/%s' % key if current_user.is_authenticated and app_menu in ('bankperso', 'default'): if is_superuser: items.append({ 'link': '%s/admin/index' % request.script_root, 'title': 'Администратор', 'class': '/admin' in request.url and 'selected' or '' }) key, link = _item('bankperso') if (USE_FULL_MENU or link not in request.url) and not is_limited(key): items.append({ 'link': '%s/bankperso' % request.script_root, 'title': 'БанкПерсо', 'class': (link in request.url or request.url_rule.rule == '/') and 'selected' or '' }) key, link = _item('cards') if (is_admin or is_operator) and ( USE_FULL_MENU or link not in request.url) and not is_limited(key): items.append({ 'link': '%s/cards' % request.script_root, 'title': 'Персонализация', 'class': link in request.url and 'selected' or '' }) """ if USE_FULL_MENU or ('/preload' not in request.url and is_admin): items.append({'link' : '%s/preload' % request.script_root, 'title': 'Предоработка', 'class': '/preload' in request.url and 'selected' or ''}) if is_superuser: items.append({'link' : '%s/orderstate' % request.script_root, 'title': 'Менеджер заказов', 'class': '/orderstate' in request.url and 'selected' or ''}) if IsFuture: items.append({'link' : '%s/stock' % request.script_root, 'title': 'Склад', 'class': '/stock' in request.url and 'selected' or ''}) """ key, link = _item('configurator') if (USE_FULL_MENU or (link not in request.url and is_admin)) and not is_limited(key): items.append({ 'link': '%s/%s' % (request.script_root, key), 'title': 'Конфигуратор', 'class': link in request.url and 'selected' or '' }) if current_user.is_authenticated and app_menu in ( 'calculator', 'demo', 'headoffice', 'default', ): if is_manager and (USE_FULL_MENU or '/show' not in request.url): items.append({ 'link': '%s/show' % request.script_root, 'title': 'Калькулятор', 'class': '/show' in request.url and 'selected' or '' }) if current_user.is_authenticated and app_menu in ( 'diamond', 'demo', 'headoffice', 'default', ): if is_manager and (USE_FULL_MENU or '/catalog' not in request.url): items.append({ 'link': '%s/catalog' % request.script_root, 'title': 'Продукция', 'class': '/catalog' in request.url and 'selected' or '' }) if current_user.is_authenticated and app_menu in ( 'persostation', 'demo', 'headoffice', 'default', ): if is_superuser and (USE_FULL_MENU or '/persostation' not in request.url): items.append({ 'link': '%s/persostation' % request.script_root, 'title': 'Инкассация', 'class': '/persostation' in request.url and 'selected' or '' }) if current_user.is_authenticated and app_menu in ('provision', 'demo', 'headoffice', 'default'): if is_manager and (USE_FULL_MENU or '/provision' not in request.url): items.append({ 'link': '%s/provision' % request.script_root, 'title': 'Снабжение', 'class': '/provision' in request.url and 'selected' or '' }) if not current_user.is_authenticated: items.append({ 'link': '%s/auth/login' % request.script_root, 'title': 'Вход', 'class': '' }) else: items.append({ 'link': '%s/auth/logout' % request.script_root, 'title': 'Выход', 'class': '' }) return items
def is_accessible(self): return current_user.is_authenticated() and current_user.is_superuser()
def is_accessible(self): return (not AUTHENTICATE or (not current_user.is_anonymous() and current_user.is_superuser()))
def decorated_function(*args, **kwargs): #print('current_user.is_administrator: %s' % current_user.is_administrator()) if not current_user.is_superuser(): abort(403) return f(*args, **kwargs)