def tasks(short_name, page): application = db.session.query(model.App).\ filter(model.App.short_name == short_name).\ first() if application: try: require.app.read(application) require.app.update(application) per_page = 10 count = db.session.query(model.Task)\ .filter_by(app_id=application.id)\ .count() tasks = db.session.query(model.Task)\ .filter_by(app_id=application.id)\ .limit(per_page)\ .offset((page - 1) * per_page)\ .all() if not tasks and page != 1: abort(404) pagination = Pagination(page, per_page, count) return render_template('/applications/tasks.html', app=application, tasks=tasks, title="Application: %s tasks" % application.name, pagination=pagination) except HTTPException: if not application.hidden: per_page = 10 count = db.session.query(model.Task)\ .filter_by(app_id=application.id)\ .count() tasks = db.session.query(model.Task)\ .filter_by(app_id=application.id)\ .limit(per_page)\ .offset((page - 1) * per_page)\ .all() if not tasks and page != 1: abort(404) pagination = Pagination(page, per_page, count) return render_template('/applications/tasks.html', app=application, tasks=tasks, title="Application: %s tasks" % application.name, pagination=pagination) else: return render_template('/applications/tasks.html', app=None) else: abort(404)
def index(page): """ Index page for all PyBossa registered users. Returns a Jinja2 rendered template with the users. """ update_feed = get_update_feed() per_page = 24 count = cached_users.get_total_users() accounts = cached_users.get_users_page(page, per_page) if not accounts and page != 1: abort(404) pagination = Pagination(page, per_page, count) if current_user.is_authenticated(): user_id = current_user.id else: user_id = 'anonymous' top_users = cached_users.get_leaderboard(current_app.config['LEADERBOARD'], user_id) return render_template('account/index.html', accounts=accounts, total=count, top_users=top_users, title="Community", pagination=pagination, update_feed=update_feed)
def teams_show(page, lookup, team_type, fallback, use_count, title): '''Show team list by type ''' if not require.team.read(): abort(403) per_page = 5 teams, count = lookup(page, per_page) team_owner = [] if not current_user.is_anonymous(): team_owner = Team.query.filter( Team.owner_id == current_user.id).first() for team in teams: team['belong'] = cached_teams.user_belong_team(team['id']) pagination = Pagination(page, per_page, count) template_args = { "teams": teams, "team_owner": team_owner, "title": title, "pagination": pagination, "team_type": team_type } if use_count: template_args.update({"count": count}) return render_template('/team/teams.html', **template_args)
def respond(): per_page = 100 offset = (page - 1) * per_page count = ps.n_tasks page_tasks = cached_projects.browse_tasks_validation(project.get('id'), per_page, offset, min_n_answers=3) pagination = Pagination(page, per_page, count) project_sanitized, owner_sanitized = sanitize_project_owner( project, owner, current_user, ps) data = dict(template='admin/validation.html', project=project_sanitized, owner=owner_sanitized, tasks=page_tasks, title=title, pagination=pagination, n_tasks=ps.n_tasks, overall_progress=ps.overall_progress, n_volunteers=ps.n_volunteers, n_completed_tasks=ps.n_completed_tasks, pro_features=pro) return handle_content_type(data)
def index(page=1): """Index page for all PYBOSSA registered users.""" update_feed = get_update_feed() per_page = 24 count = cached_users.get_total_users() print(count) accounts = cached_users.get_users_page(page, per_page) print(accounts) if not accounts and page != 1: abort(404) pagination = Pagination(page, per_page, count) if current_user.is_authenticated: user_id = current_user.id else: user_id = None top_users = cached_users.get_leaderboard(current_app.config['LEADERBOARD'], user_id) tmp = dict(template='account/index.html', accounts=accounts, total=count, top_users=top_users, title="Community", pagination=pagination, update_feed=update_feed) return handle_content_type(tmp)
def index(page): per_page = 24 count = db.session.query(model.User).count() accounts = db.session.query(model.User)\ .limit(per_page)\ .offset((page - 1) * per_page).all() if not accounts and page != 1: abort(404) pagination = Pagination(page, per_page, count) return render_template('account/index.html', accounts=accounts, title="Community", pagination=pagination)
def index(page): ''' Show all teams in a grid''' per_page = 24 count = cached_teams.get_teams_count() teams = cached_teams.get_teams_page(page, per_page) pagination = Pagination(page, per_page, count) if not teams and page != 1: abort(404) return render_template('team/index.html', teams=teams, total=count, title="Teams", pagination=pagination)
def app_index(page, lookup, category, fallback, use_count): """Show apps of app_type""" per_page = 5 apps, count = lookup(category, page, per_page) data = [] for app in apps: data.append( dict(app=app, n_tasks=cached_apps.n_tasks(app['id']), overall_progress=cached_apps.overall_progress(app['id']), last_activity=app['last_activity'], last_activity_raw=app['last_activity_raw'])) if fallback and not apps: # pragma: no cover return redirect(url_for('.index')) pagination = Pagination(page, per_page, count) categories = cached_cat.get_all() # Check for pre-defined categories featured and draft featured_cat = model.Category(name='Featured', short_name='featured', description='Featured applications') if category == 'featured': active_cat = featured_cat elif category == 'draft': active_cat = model.Category(name='Draft', short_name='draft', description='Draft applications') else: active_cat = db.session.query(model.Category)\ .filter_by(short_name=category).first() # Check if we have to add the section Featured to local nav if cached_apps.n_featured() > 0: categories.insert(0, featured_cat) template_args = { "apps": data, "title": gettext("Applications"), "pagination": pagination, "active_cat": active_cat, "categories": categories } if use_count: template_args.update({"count": count}) return render_template('/applications/index.html', **template_args)
def index(page): """ Index page for all PyBossa registered users. Returns a Jinja2 rendered template with the users. """ per_page = 24 count = cached_users.get_total_users() accounts = cached_users.get_users_page(page, per_page) if not accounts and page != 1: abort(404) pagination = Pagination(page, per_page, count) return render_template('account/index.html', accounts=accounts, total=count, title="Community", pagination=pagination)
def index(page): if require.app.read(): per_page = 10 count = db.session.query(model.App)\ .filter(model.App.hidden == 0)\ .order_by(model.App.tasks.any().desc())\ .count() apps = db.session.query(model.App)\ .filter(model.App.hidden == 0)\ .order_by(model.App.tasks.any().desc())\ .limit(per_page)\ .offset((page-1)*per_page)\ .all() featured = db.session.query(model.Featured)\ .all() apps_featured = [] apps_with_tasks = [] apps_without_tasks = [] for f in featured: apps_featured.append(db.session.query(model.App).get(f.app_id)) for a in apps: app_featured = False if (len(a.tasks) > 0) and (a.info.get("task_presenter")): for f in featured: if f.app_id == a.id: app_featured = True break if not app_featured: apps_with_tasks.append(a) else: apps_without_tasks.append(a) pagination = Pagination(page, per_page, count) return render_template('/applications/index.html', title="Applications", apps_featured=apps_featured, apps_with_tasks=apps_with_tasks, apps_without_tasks=apps_without_tasks, pagination=pagination) else: abort(403)
def app_index(page, lookup, category, fallback, use_count): """Show apps of app_type""" if not require.app.read(): abort(403) per_page = 5 apps, count = lookup(category, page, per_page) if fallback and not apps: return redirect(url_for('.published')) pagination = Pagination(page, per_page, count) categories = cached_cat.get_all() # Check for pre-defined categories featured and draft featured_cat = model.Category(name='Featured', short_name='featured', description='Featured applications') if category == 'featured': active_cat = featured_cat elif category == 'draft': active_cat = model.Category(name='Draft', short_name='draft', description='Draft applications') else: active_cat = db.session.query(model.Category)\ .filter_by(short_name=category).first() # Check if we have to add the section Featured to local nav if cached_apps.n_featured() > 0: categories.insert(0, featured_cat) template_args = { "apps": apps, "title": lazy_gettext("Applications"), "pagination": pagination, "active_cat": active_cat, "categories": categories } if use_count: template_args.update({"count": count}) return render_template('/applications/index.html', **template_args)
def respond(): per_page = 10 count = db.session.query(model.Task)\ .filter_by(app_id=app.id)\ .count() app_tasks = db.session.query(model.Task)\ .filter_by(app_id=app.id)\ .order_by(model.Task.id)\ .limit(per_page)\ .offset((page - 1) * per_page)\ .all() if not app_tasks and page != 1: abort(404) pagination = Pagination(page, per_page, count) return render_template('/applications/tasks.html', app=app, tasks=app_tasks, title=title, pagination=pagination)
def app_index(page, lookup, app_type, fallback, use_count): """Show apps of app_type""" if not require.app.read(): abort(403) per_page = 5 apps, count = lookup(page, per_page) if fallback and not apps: return redirect(url_for('.published')) pagination = Pagination(page, per_page, count) template_args = { "apps": apps, "title": lazy_gettext("Applications"), "pagination": pagination, "app_type": app_type} if use_count: template_args.update({"count": count}) return render_template('/applications/index.html', **template_args)