def test_user_basics(): for n in range(20): assert l.add_user(u"{}@example.com".format(n), u"Name {}".format(n), u"pw{}".format(n)) email = u"*****@*****.**" name = u"Ned Jackson Lovely" pw = u"password" assert not l.check_pw(email, pw) uid = l.add_user(email, name, pw) assert len(l.list_users()) == 21 for user in l.list_users(): assert not user.approved_on l.approve_user(uid) for user in l.list_users(): assert not user.approved_on if user.id != uid else user.approved_on assert l.get_user(uid).display_name == name assert l.check_pw(email, pw) assert l.check_pw(email.upper(), pw) assert not l.check_pw(email, pw.upper()) pw2 = u"\u2603" l.change_pw(uid, pw2) assert not l.check_pw(email, pw) assert l.check_pw(email, pw2)
def test_user_basics(): for n in range(20): assert l.add_user(u'{}@example.com'.format(n), u'Name {}'.format(n), u'pw{}'.format(n)) email = u'*****@*****.**' name = u'Ned Jackson Lovely' pw = u'password' assert not l.check_pw(email, pw) uid = l.add_user(email, name, pw) assert len(l.list_users()) == 21 for user in l.list_users(): assert not user.approved_on l.approve_user(uid) for user in l.list_users(): assert not user.approved_on if user.id != uid else user.approved_on assert l.get_user(uid).display_name == name assert l.check_pw(email, pw) assert l.check_pw(email.upper(), pw) assert not l.check_pw(email, pw.upper()) pw2 = u'\u2603' l.change_pw(uid, pw2) assert not l.check_pw(email, pw) assert l.check_pw(email, pw2)
def main(): actions = parse_log(sys.argv[1]) print '\nScreening' q = 'SELECT count(*) FROM proposals' proposal_count = l.scalar(q) print 'There were {} proposals.'.format(proposal_count) q = 'SELECT count(*), voter FROM votes group by voter' print '{} voters did '.format(len(l.fetchall(q))) q = 'SELECT count(*) FROM votes' print '{:,} reviews'.format(actions['vote']) q = 'SELECT COUNT(*) FROM votes WHERE nominate' print 'and gave {} nominations.'.format(l.scalar(q)) q = 'SELECT id from discussion' print '{:,} messages were written,'.format(len(l.fetchall(q))) q = 'SELECT id from discussion WHERE feedback' print '{:,} of them feedback to proposal authors.'.format( len(l.fetchall(q))) q = 'SELECT count(*), proposal from VOTES group by proposal order by count' votes = l.fetchall(q) print 'Every proposal received at least {} reviews,'.format(votes[0].count) full_coverage = sum(1 for x in l.list_users() if (x.votes + x.proposals_made) == proposal_count) print 'and {} voters performed the incredible task of reviewing all of the proposals.'.format( full_coverage) print '\n\n' q = 'SELECT COUNT(*) FROM proposals WHERE batchgroup is not null' print '{} talks made it into the second round,'.format(l.scalar(q)) q = '''SELECT COUNT(*), batchgroup FROM proposals WHERE batchgroup is not null group by batchgroup''' print 'where they were grouped into {} batches.'.format(len(l.fetchall(q))) q = 'SELECT count(*) FROM batchvotes' batch_vote_count = l.scalar(q) print '{:,} reviews happened,'.format(actions['vote_group'], batch_vote_count) q = 'SELECT id from batchmessages' print '{} more messages were sent, and'.format(len(l.fetchall(q))) q = 'SELECT count(*), voter from batchvotes group by voter' print '{} voters participated.'.format(len(l.fetchall(q))) q = '''SELECT count(*), batchgroup from batchvotes group by batchgroup order by count''' batch_count = l.fetchall(q) print 'Every batch got at least {} reviews'.format(batch_count[0].count) print 'to arrive at our final 95 accepted talks!'
def list_all_users(): try: users = logic.list_users() except InternalError: template = redirect(url_for('internal_error', error=500)) else: template = render_template('users.html', users=users) return template
def main(): lt.transact() emails = ['user{}@example.com'.format(n) for n in range(50)] for e in emails[:25]: uid = l.add_user(e, '{} Person'.format(e.split('@')[0]), 'abc123') l.approve_user(uid) for n in range(6): l.add_standard(words(3, 10)[:50]) user_ids = [x.id for x in l.list_users()] standards = [x.id for x in l.get_standards()] proposal_ids = [] for n in range(200): prop_id = n*2 data = {'id': prop_id, 'authors': [{'email': random.choice(emails), 'name': 'Speaker Name Here'}], 'title': words(3,8).title(), 'category': words(1,2), 'duration': '30 minutes', 'description': ipsum(4), 'audience': ipsum(1), 'audience_level': 'Novice', 'notes': ipsum(2), 'objective': ipsum(1), 'recording_release': bool(random.random() > 0.05), 'abstract': ipsum(1), 'outline': ipsum(5)+"\n[test](http://www.google.com/)\n", 'additional_notes': ipsum(1), 'additional_requirements': ipsum(1)} l.add_proposal(data) proposal_ids.append(prop_id) if random.randint(0, 3) == 0: for n in range(random.randint(1, 10)): l.add_to_discussion(random.choice(user_ids), prop_id, ipsum(1)) if random.randint(0, 2) == 0: for n in range(random.randint(1, 5)): vote = {k:random.randint(0, 2) for k in standards} l.vote(random.choice(user_ids), prop_id, vote) if random.randint(0, 3) == 0: data['description'] = 'UPDATED ' + ipsum(4) l.add_proposal(data) random.shuffle(proposal_ids) proposal_ids = proposal_ids[:70] for n in range(0, len(proposal_ids), 5): l.create_group(words(2,4).title(), proposal_ids[n:n+5])
def main(): lt.transact() emails = ["user{}@example.com".format(n) for n in range(50)] for e in emails[:25]: uid = l.add_user(e, "{} Person".format(e.split("@")[0]), "abc123") l.approve_user(uid) for n in range(6): l.add_standard(words(3, 10)[:50]) user_ids = [x.id for x in l.list_users()] standards = [x.id for x in l.get_standards()] proposal_ids = [] for n in range(200): prop_id = n * 2 data = { "id": prop_id, "authors": [{"email": random.choice(emails), "name": "Speaker Name Here"}], "title": words(3, 8).title(), "category": words(1, 2), "duration": "30 minutes", "description": ipsum(4), "audience": ipsum(1), "audience_level": "Novice", "notes": ipsum(2), "objective": ipsum(1), "recording_release": bool(random.random() > 0.05), "abstract": ipsum(1), "outline": ipsum(5) + "\n[test](http://www.google.com/)\n", "additional_notes": ipsum(1), "additional_requirements": ipsum(1), } l.add_proposal(data) proposal_ids.append(prop_id) if random.randint(0, 3) == 0: for n in range(random.randint(1, 10)): l.add_to_discussion(random.choice(user_ids), prop_id, ipsum(1)) if random.randint(0, 2) == 0: for n in range(random.randint(1, 5)): vote = {k: random.randint(0, 2) for k in standards} l.vote(random.choice(user_ids), prop_id, vote) if random.randint(0, 3) == 0: data["notes"] = "UPDATED" + ipsum(2) l.add_proposal(data) random.shuffle(proposal_ids) proposal_ids = proposal_ids[:70] for n in range(0, len(proposal_ids), 5): l.create_group(words(2, 4).title(), proposal_ids[n : n + 5])
def question(question_id): if request.method == 'GET': logic.update_view_number(question_id) if request.method == 'POST': if request.form.get('answer_id', '') and request.form.get( 'user_id', ''): logic.accepted_answer(request.form['answer_id'], request.form['user_id']) users = logic.list_users() return render_template("question.html", data=logic.get_one_question(question_id, answers=True), question_id=question_id, users=users)
def screening_stats(): users = [x for x in l.list_users() if x.votes] users.sort(key=lambda x:-x.votes) progress = l.screening_progress() votes_when = l.get_votes_by_day() coverage_by_age = l.coverage_by_age() active_discussions = l.active_discussions() nomination_density = l.nomination_density() return render_template('screening_stats.html', users=users, progress=progress, nomination_density=nomination_density, coverage_by_age=coverage_by_age, total_votes=sum(u.votes for u in users), total_proposals=sum(p.quantity for p in progress), active_discussions=active_discussions, votes_when=votes_when)
def show_answer_form(answer_id=None, question_id=None): typeID = 2 users = logic.list_users() if answer_id: # update answer modID = answer_id data = logic.select_edit_data(answer_id, 'answer')[0] else: # insert new answer modID = -1 data = None return render_template('form.html', typeID=typeID, modID=modID, data=data, question_id=question_id, users=users)
def show_form(question_id=None): ''' modID -1 in case of insert, otherwise the id of the question to be edited typeID what will be changed: question 1, answer 2, comment 3 ''' typeID = 1 users = logic.list_users() if question_id: # update question modID = question_id data = logic.select_edit_data(question_id, 'question')[0] else: # insert new question modID = -1 data = None return render_template('form.html', data=data, typeID=typeID, modID=modID, users=users)
def show_comment_form(comment_id=None, answer_id=None, question_id=None): typeID = 3 users = logic.list_users() if comment_id: # update comment modID = comment_id data = logic.select_edit_data(comment_id, 'comment')[0] question_id = data['question_id'] else: # insert new comment modID = -1 data = None if question_id is None: question_id = logic.get_question_by_answer_id(answer_id) return render_template('form.html', typeID=typeID, modID=modID, data=data, question_id=question_id, answer_id=answer_id, users=users)
def main(): lt.transact() emails = ['user{}@example.com'.format(n) for n in range(50)] for e in emails[:25]: uid = l.add_user(e, '{} Person'.format(e.split('@')[0]), 'abc123') l.approve_user(uid) """ for n in range(6): l.add_standard(words(3, 10)[:50]) """ standards = ["follows PyCon's Code of Conduct", "is complete, clearly written, and articulate", "has a thorough and achievable outline", "has a coherent and primarily technical subject", "is about the Python ecosystem", "has a sufficient audience among attendees"] for s in standards: l.add_standard(s) user_ids = [x.id for x in l.list_users()] standards = [x.id for x in l.get_standards()] proposal_ids = [] for n in range(200): prop_id = n*2 data = {'id': prop_id, 'authors': [{'email': random.choice(emails), 'name': 'Speaker Name Here'}], 'title': words(3,8).title(), 'category': words(1,2), 'duration': '30 minutes', 'description': ipsum(4), 'audience': ipsum(1), 'audience_level': 'Novice', 'notes': ipsum(2), 'objective': ipsum(1), 'recording_release': bool(random.random() > 0.05), 'abstract': ipsum(1), 'outline': ipsum(5)+"\n[test](http://www.google.com/)\n", 'additional_notes': ipsum(1), 'additional_requirements': ipsum(1)} l.add_proposal(data) proposal_ids.append(prop_id) if random.randint(0, 3) == 0: for n in range(random.randint(1, 10)): l.add_to_discussion(random.choice(user_ids), prop_id, ipsum(1)) if random.randint(0, 2) == 0: for n in range(random.randint(1, 5)): vote = {k:random.randint(0, 2) for k in standards} l.vote(random.choice(user_ids), prop_id, vote) if random.randint(0, 3) == 0: data['notes'] = 'UPDATED' + ipsum(2) l.add_proposal(data) random.shuffle(proposal_ids) proposal_ids = proposal_ids[:70] for n in range(0, len(proposal_ids), 5): l.create_group(words(2,4).title(), proposal_ids[n:n+5])
def list_users(): return render_template('user_list.html', users=l.list_users())
def main(): actions = parse_log(sys.argv[1]) print '\nScreening' q = 'SELECT count(*) FROM proposals' proposal_count = l.scalar(q) print 'There were {} proposals.'.format(proposal_count) q = 'SELECT count(*), voter FROM votes group by voter' print '{} voters did '.format(len(l.fetchall(q))) q = 'SELECT count(*) FROM votes' print '{:,} reviews'.format(actions['vote']) q = 'SELECT COUNT(*) FROM votes WHERE nominate' print 'and gave {} nominations.'.format(l.scalar(q)) q = 'SELECT id from discussion' print '{:,} messages were written,'.format(len(l.fetchall(q))) q = 'SELECT id from discussion WHERE feedback' print '{:,} of them feedback to proposal authors.'.format(len(l.fetchall(q))) q = 'SELECT count(*), proposal from VOTES group by proposal order by count' votes = l.fetchall(q) print 'Every proposal received at least {} reviews,'.format(votes[0].count) full_coverage = sum(1 for x in l.list_users() if (x.votes + x.proposals_made) == proposal_count) print 'and {} voters performed the incredible task of reviewing all of the proposals.'.format(full_coverage) print '\n\n' q = 'SELECT COUNT(*) FROM proposals WHERE batchgroup is not null' print '{} talks made it into the second round,'.format(l.scalar(q)) q = '''SELECT COUNT(*), batchgroup FROM proposals WHERE batchgroup is not null group by batchgroup''' print 'where they were grouped into {} batches.'.format(len(l.fetchall(q))) q = 'SELECT count(*) FROM batchvotes' batch_vote_count = l.scalar(q) print '{:,} reviews happened,'.format(actions['vote_group'], batch_vote_count) q= 'SELECT id from batchmessages' print '{} more messages were sent, and'.format(len(l.fetchall(q))) q = 'SELECT count(*), voter from batchvotes group by voter' print '{} voters participated.'.format(len(l.fetchall(q))) q = '''SELECT count(*), batchgroup from batchvotes group by batchgroup order by count''' batch_count = l.fetchall(q) print 'Every batch got at least {} reviews'.format(batch_count[0].count) print 'to arrive at our final 95 accepted talks!'