def perform_edit(): data = flask.request.form # Check we are logged in access_token = flask.session.get('access_token', None) if not access_token: return flask.redirect(flask.url_for('login')) page_name = data.get('name') summary = data.get('summary') if not summary: raise InvalidUsage('No edit summary provided') # Get the page text = main.get_page_over_api(page_name) # Perform each edit new_text, change_made = make_new_wikicode(text, data, page_name) # Remove the cache cache_fname = "cache/" + to_cache_name(page_name) if os.path.isfile(cache_fname): os.remove(cache_fname) # Save the page if change_made: access_token = flask.session.get('access_token', None) edit_wiki_page(page_name, new_text, access_token, summary) UserStats.increment_user('en', flask.session.get('username', None), 1, 1) return flask.redirect(flask.url_for('get_random_edit')) else: return flask.redirect(flask.url_for('index', success='nothing'))
def stats(): leaderboard = list(UserStats.get_leaderboard()) total_edits = sum(rec.nb_edits for rec in leaderboard) context = { 'username' : flask.session.get('username', None), 'enumerated_leaderboard': enumerate(UserStats.get_leaderboard()), 'total_edits': total_edits, } return flask.render_template("stats.html", **context)
def stats(): leaderboard = list(UserStats.get_leaderboard()) total_edits = sum(rec.nb_edits for rec in leaderboard) context = { 'username': flask.session.get('username', None), 'enumerated_leaderboard': enumerate(UserStats.get_leaderboard()), 'total_edits': total_edits, } return flask.render_template("stats.html", **context)
def review_one_edit(): page_name = flask.request.args.get('name') orig_hash = flask.request.args.get('edit') context = get_one_proposed_edit(page_name, orig_hash) username = flask.session.get('username', None) nb_edits = 0 if username: nb_edits = UserStats.get('en', username).nb_edits context['username'] = username context['nb_edits'] = nb_edits return flask.render_template('one-edit.html', **context)
def process(): page_name = flask.request.args.get('name') if not page_name: raise InvalidUsage('Page title is required') force = flask.request.args.get('refresh') == 'true' context = get_proposed_edits(page_name, force) username = flask.session.get('username', None) nb_edits = 0 if username: nb_edits = UserStats.get('en', username).nb_edits context['username'] = username context['nb_edits'] = nb_edits return flask.render_template('change.html', **context)
def process(): page_name = flask.request.args.get('name') if not page_name: raise InvalidUsage('Page title is required') force = flask.request.args.get('refresh') == 'true' context = get_proposed_edits(page_name, force) username = flask.session.get('username', None) nb_edits = 0 if username: nb_edits = UserStats.get('en', username).nb_edits context['username'] = username context['nb_edits'] = nb_edits context['proposed_edits'] = [template_edit for template_edit in context['proposed_edits'] if (template_edit['classification'] != 'rejected')] return flask.render_template('change.html', **context)
def perform_edit(): data = flask.request.form # Check we are logged in access_token =flask.session.get('access_token', None) if not access_token: return flask.redirect(flask.url_for('login')) page_name = data.get('name') summary = data.get('summary') if not summary: raise InvalidUsage('No edit summary provided') # Get the page text = main.get_page_over_api(page_name) # Perform each edit new_text, change_made = make_new_wikicode(text, data, page_name) # Save the page if change_made: access_token = flask.session.get('access_token', None) edit_wiki_page(page_name, new_text, access_token, summary) UserStats.increment_user( 'en', flask.session.get('username', None), 1, 1) # Remove the cache cache_fname = "cache/"+to_cache_name(page_name) if os.path.isfile(cache_fname): os.remove(cache_fname) return flask.redirect(flask.url_for('get_random_edit')) else: return flask.redirect(flask.url_for('index', success='nothing'))
def process(): page_name = flask.request.args.get('name') if not page_name: raise InvalidUsage('Page title is required') force = flask.request.args.get('refresh') == 'true' context = get_proposed_edits(page_name, force) context['cache_size'] = len(list_cache_contents()) username = flask.session.get('username', None) nb_edits = 0 if username: nb_edits = UserStats.get('en', username).nb_edits context['username'] = username context['nb_edits'] = nb_edits context['proposed_edits'] = [ template_edit for template_edit in context['proposed_edits'] if (template_edit['classification'] != 'rejected') ] return flask.render_template('change.html', **context)