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): """ 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 = None 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 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 _show_own_profile(user, form, can_update): user_dict = cached_users.get_user_summary(user.name) rank_and_score = cached_users.rank_and_score(user.id) user.rank = rank_and_score['rank'] user.score = rank_and_score['score'] user.total = cached_users.get_total_users() projects_contributed = cached_users.public_projects_contributed_cached( user.id) projects_published, projects_draft = _get_user_projects(user.id) cached_users.get_user_summary(user.name) response = dict(template='account/profile.html', title=gettext("Profile"), projects_contrib=projects_contributed, projects_published=projects_published, projects_draft=projects_draft, user=user_dict, form=form, can_update=can_update, private_instance=bool(data_access_levels), upref_mdata_enabled=bool(app_settings.upref_mdata)) response = make_response(handle_content_type(response)) response.headers['Cache-Control'] = 'no-store' response.headers['Pragma'] = 'no-cache' return response
def test_get_total_users_returns_number_of_users(self): expected_number_of_users = 3 UserFactory.create_batch(expected_number_of_users) total_users = cached_users.get_total_users() assert total_users == expected_number_of_users, total_users
def index(page): 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 _show_own_profile(user): rank_and_score = cached_users.rank_and_score(user.id) user.rank = rank_and_score['rank'] user.score = rank_and_score['score'] user.total = cached_users.get_total_users() apps_contrib = cached_users.apps_contributed(user.id) apps_published, apps_draft = _get_user_apps(user.id) apps_published.extend(cached_users.hidden_apps(user.id)) return render_template('account/profile.html', title=gettext("Profile"), apps_contrib=apps_contrib, apps_published=apps_published, apps_draft=apps_draft)#,
def _show_own_profile(user): rank_and_score = cached_users.rank_and_score(user.id) user.rank = rank_and_score['rank'] user.score = rank_and_score['score'] user.total = cached_users.get_total_users() apps_contrib = cached_users.apps_contributed(user.id) apps_published, apps_draft = _get_user_apps(user.id) apps_published.extend(cached_users.hidden_apps(user.id)) return render_template('account/profile.html', title=gettext("Profile"), apps_contrib=apps_contrib, apps_published=apps_published, apps_draft=apps_draft) #,
def _show_own_profile(user): rank_and_score = cached_users.rank_and_score(user.id) user.rank = rank_and_score['rank'] user.score = rank_and_score['score'] user.total = cached_users.get_total_users() projects_contributed = cached_users.projects_contributed_cached(user.id) projects_published, projects_draft = _get_user_projects(user.id) cached_users.get_user_summary(user.name) return render_template('account/profile.html', title=gettext("Profile"), projects_contrib=projects_contributed, projects_published=projects_published, projects_draft=projects_draft, user=user)
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 _show_own_profile(user): user_dict = cached_users.get_user_summary(user.name) rank_and_score = cached_users.rank_and_score(user.id) user.rank = rank_and_score['rank'] user.score = rank_and_score['score'] user.total = cached_users.get_total_users() projects_contributed = cached_users.public_projects_contributed_cached(user.id) projects_published, projects_draft = _get_user_projects(user.id) cached_users.get_user_summary(user.name) response = dict(template='account/profile.html', title=gettext("Profile"), projects_contrib=projects_contributed, projects_published=projects_published, projects_draft=projects_draft, user=user_dict) return handle_content_type(response)
def _show_own_profile(user): rank_and_score = cached_users.rank_and_score(user.id) user.rank = rank_and_score['rank'] user.score = rank_and_score['score'] user.total = cached_users.get_total_users() user.valid_email = user.valid_email user.confirmation_email_sent = user.confirmation_email_sent apps_contributed = cached_users.apps_contributed_cached(user.id) apps_published, apps_draft = _get_user_apps(user.id) apps_published.extend(cached_users.hidden_apps(user.id)) cached_users.get_user_summary(user.name) return render_template('account/profile.html', title=gettext("Profile"), apps_contrib=apps_contributed, apps_published=apps_published, apps_draft=apps_draft, user=user)
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() 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 = 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 test_get_total_users_returns_0_if_no_users(self): total_users = cached_users.get_total_users() assert total_users == 0, total_users