Esempio n. 1
0
    def common_data_setup(self):
        self.c = conference.Conference()
        self.c.name = "TestConf"
        self.c.put()

        # Set up the scenario
        t1 = talk.Talk()
        t1.title = "Talk1 - No duplicate votes"
        t1.put()

        subs_key1 = submissionrecord.make_submission(t1.key, self.c.key,
                                                     "track", "format")
        self.assertEquals(
            len(submissionrecord.retrieve_conference_submissions(self.c.key)),
            1)

        t2 = talk.Talk()
        t2.title = "Talk2 - Allan duplicate votes"
        t2.put()

        subs_key2 = submissionrecord.make_submission(t2.key, self.c.key,
                                                     "track", "format")
        self.assertEquals(
            len(submissionrecord.retrieve_conference_submissions(self.c.key)),
            2)

        return [subs_key1, subs_key2]
Esempio n. 2
0
    def test_change_all_expenses(self):
        self.create_conference()

        sub_key1 = submissionrecord.make_submission_plus(self.t.key, self.c.key, "track", "format", "duration", "Option1")
        sub_key2 = submissionrecord.make_submission_plus(self.t.key, self.c.key, "track", "format", "duration", "Option2")
        sub_key3 = submissionrecord.make_submission_plus(self.t.key, self.c.key, "track", "format", "duration", "Option3")
        sub_key4 = submissionrecord.make_submission_plus(self.t.key, self.c.key, "track", "format", "duration", "Option2")

        self.assertEquals(len(submissionrecord.retrieve_conference_submissions(self.c.key)), 4)
        submissions_aux.change_all_expenses(self.c.key, "Option2", "NewOption")
        self.assertEquals(len(submissionrecord.retrieve_conference_submissions(self.c.key)), 4)

        self.assertEquals("Option1", sub_key1.get().expenses)
        self.assertEquals("NewOption", sub_key2.get().expenses)
        self.assertEquals("Option3", sub_key3.get().expenses)
        self.assertEquals("NewOption", sub_key4.get().expenses)
Esempio n. 3
0
    def get(self):
        conf = ndb.Key(urlsafe=self.request.get("conf")).get()

        if self.request.params.has_key("f"):
            submissions = self.retrieve_submissions(conf.key, self.request.get("f"))
            msg = self.request.get("f")
        else:
            submissions = submissionrecord.retrieve_conference_submissions(conf.key)
            msg = "All"

        if submissions is not None:
            submission_keys = map(lambda sub: sub.key, submissions)
            submission_cospeakers = speaker_lib.cospeaker.filter_for_cospeakers(submission_keys)
            all_speakers = speaker_lib.cospeaker.count_all_speakers(submission_keys)
        else:
            # deal with null to avoid nasty error message
            submission_cospeakers = {}
            all_speakers = speaker_lib.cospeaker.SpeakerTotals()

        template_values = {
            "conference": conf,
            "speakers_map": submission_cospeakers,
            "conf_tracks": conf.track_options(),
            "speaker_total": all_speakers,
            "sorted_speakers": sorted(all_speakers.speaker_totals),
            "filter_msg": messages[msg],
            "expand_pictures": self.request.params.has_key("expand"),
        }

        self.write_page('reports/speakrptpage.html', template_values)
Esempio n. 4
0
def get_commented_votes(conf_key):
    report = CommentReport(parent=conf_key)
    for sub in submissionrecord.retrieve_conference_submissions(conf_key):
        for v in VoteRecord.query(ancestor=sub.key).fetch():
            if len(v.comment):
                report.add(sub.key, v.key)

    return report
Esempio n. 5
0
def find_duplicate_votes(conf_key, round):
    duplicates = {}
    for sub in submissionrecord.retrieve_conference_submissions(conf_key):
        votes = voterecord.find_existing_votes(sub.key, round)
        for reviewer in extract_reviewers(votes):
            votes_cast = reviewer_votes(reviewer, votes)
            if len(votes_cast) > 1:
                duplicates[reviewer] = votes_cast

    return duplicates
Esempio n. 6
0
def close_round1_and_open_round2(conf):
    for sub in submissionrecord.retrieve_conference_submissions(conf.key):
        if sub.last_review_round < 2:
            if (sub.review_decision(1) == "Round2"):
                sub.last_review_round = 2
                sub.set_review_decision(2, "No decision")
                sub.put()

    conf.start_round2_reviews()
    conf.put()
Esempio n. 7
0
    def change_submission_communication(self):
        conf_key = self.get_crrt_conference_key()
        submissions = submissionrecord.retrieve_conference_submissions(
            conf_key)
        for sub in submissions:
            logging.info("Change subs comms:" + sub.communication + ";" +
                         submissionnotifynames.SUBMISSION_ACCEPT_ACKNOWLEDGED +
                         ".")
            if sub.communication == submissionnotifynames.SUBMISSION_ACCEPT_ACKNOWLEDGED:
                sub.acknowledge_receipt()

        self.response.write("Done: submission comms updated")
Esempio n. 8
0
    def retrieve_submissions(self, conference_key, filter):
        submissions = submissionrecord.retrieve_conference_submissions(
            conference_key)

        if (filter == "NoDecision"):
            return submissions_aux.filter_by_final_decision(
                "No decision", submissions)
        if (filter == "AcceptAll"):
            return submissions_aux.filter_by_final_decision(
                "Accept", submissions)

        return submissions
Esempio n. 9
0
    def test_change_expenses(self):
        self.create_conference()

        sub_key = submissionrecord.make_submission_plus(self.t.key, self.c.key, "track", "format", "duration", "Option1")
        self.assertEquals(len(submissionrecord.retrieve_conference_submissions(self.c.key)), 1)

        sub = sub_key.get()
        self.assertEquals("Option1", sub.expenses)
        submissions_aux.change_expenses(sub_key, "NotTheOption", "NewOption")
        self.assertEquals("Option1", sub.expenses)

        submissions_aux.change_expenses(sub_key, "Option1", "NewOption")
        self.assertEquals("NewOption", sub.expenses)
Esempio n. 10
0
    def test_delete_conference(self):
        conf1_key, sub1_key = self.mk_test_data("WorldConf 1000")
        conf2_key, sub2_key = self.mk_test_data("WorldConf 2000")

        self.assertEquals(
            1,
            len(submissionrecord.retrieve_conference_submissions(conf1_key)))
        self.assertEquals(
            1,
            len(submissionrecord.retrieve_conference_submissions(conf2_key)))
        self.assertEquals(1, len(voterecord.find_existing_votes(sub1_key, 1)))
        self.assertEquals(1, len(voterecord.find_existing_votes(sub2_key, 1)))
        self.assertEquals(1, len(cospeaker.get_cospeakers(sub1_key)))
        self.assertEquals(1, len(cospeaker.get_cospeakers(sub2_key)))
        self.assertEquals(2, confoptions.get_next_counter(conf1_key))
        self.assertEquals(2, confoptions.get_next_counter(conf2_key))
        self.assertEquals(6, len(ndb.Query(ancestor=conf1_key).fetch()))
        self.assertEquals(6, len(ndb.Query(ancestor=conf2_key).fetch()))

        confdb.delete_conference(conf2_key)
        self.assertEquals(None, conf2_key.get())

        self.assertEquals(
            1,
            len(submissionrecord.retrieve_conference_submissions(conf1_key)))
        self.assertEquals(
            0,
            len(submissionrecord.retrieve_conference_submissions(conf2_key)))
        self.assertEquals(1, len(voterecord.find_existing_votes(sub1_key, 1)))
        self.assertEquals(None, voterecord.find_existing_votes(sub2_key, 1))
        self.assertEquals(1, len(cospeaker.get_cospeakers(sub1_key)))
        self.assertEquals(0, len(cospeaker.get_cospeakers(sub2_key)))
        self.assertEquals(3, confoptions.get_next_counter(conf1_key))

        self.assertEquals(0, len(ndb.Query(ancestor=conf2_key).fetch()))
        self.assertEquals(None, conf2_key.get())
        self.assertEquals(None, confdb.get_conf_by_name("WorldConf 2000"))
Esempio n. 11
0
    def test_retrieve_all_reviews(self):
        c = conference.Conference()
        c.name = "TestConf"
        c.put()

        t = talk.Talk()
        t.title = "A testing talk"
        t.put()

        sub_key = submissionrecord.make_submission(t.key, c.key, "track",
                                                   "format")
        self.assertEquals(
            len(submissionrecord.retrieve_conference_submissions(c.key)), 1)

        self.assertEquals(
            len(roundreviews.retrieve_all_reviews(sub_key.get())), 0)

        voterecord.cast_new_vote(sub_key, "Fred", -2, "I hate this talk", 1)
        reviews = roundreviews.retrieve_all_reviews(sub_key.get())
        self.assertEquals(
            len(roundreviews.retrieve_all_reviews(sub_key.get())), 1)
        voterecord.cast_new_vote(sub_key, "Jim", 1, "I sort of like this talk",
                                 1)

        t2 = talk.Talk()
        t2.title = "Another talk"
        t2.put()
        sub_key2 = submissionrecord.make_submission(t2.key, c.key, "track",
                                                    "format")
        voterecord.cast_new_vote(sub_key2, "Barney", 1, "Yo ho ho", 1)

        reviews = roundreviews.retrieve_all_reviews(sub_key.get())
        self.assertEquals(len(reviews), 2)
        self.assertEquals(reviews[0].reviewer, "Fred")
        self.assertEquals(reviews[1].reviewer, "Jim")

        sub_key.get().set_review_decision(1, "Round2")
        sub_key2.get().set_review_decision(1, "Decline")
        confstate.close_round1_and_open_round2(c)

        voterecord.cast_new_vote(sub_key, "Sheila", 1, "Yes please", 2)

        reviews = roundreviews.retrieve_all_reviews(sub_key.get())
        self.assertEquals(len(reviews), 3)
        self.assertEquals(reviews[0].reviewer, "Fred")
        self.assertEquals(reviews[1].reviewer, "Jim")
        self.assertEquals(reviews[2].reviewer, "Sheila")
Esempio n. 12
0
    def get(self):
        conference = self.get_crrt_conference_key().get()
        review_round = int(self.request.get("round", "1"))

        submissions = submissionrecord.retrieve_conference_submissions(conference.key)
        submission_keys = map(lambda s: s.key, submissions)

        template_values = {
            "submissions": submissions,
            "assignment_count": dict(reviewer.count_submission_reviewers(submission_keys, review_round)),
            "tracks": conference.track_options(),
            "vote_count": voterecord.count_votes_for_submissions(submission_keys, review_round),
            "crrt_conf": conference,
            "review_round": review_round,
        }

        self.write_page('subreview_lib/subsassignmentpage.html', template_values)
Esempio n. 13
0
    def test_summary(self):
        c, t = self.data_setup()
        round = 1

        sub_key = submissionrecord.make_submission(t.key, c.key, "track",
                                                   "format")
        self.assertEquals(
            len(submissionrecord.retrieve_conference_submissions(c.key)), 1)

        summary = votesummary.retrieve_vote_summary("Reviewer1", round)
        self.assertEquals(len(summary), 0)

        voterecord.cast_new_vote(sub_key, "Reviewer1", 2, "No comment", 1)
        summary = votesummary.retrieve_vote_summary("Reviewer1", round)

        self.assertEquals(len(summary), 1)
        self.assertTrue(summary.has_key(sub_key.urlsafe()))
        self.assertTrue(summary[sub_key.urlsafe()].score, 2)
        self.assertTrue(summary[sub_key.urlsafe()].shared_comment,
                        "Yes comment")
        self.assertTrue(summary[sub_key.urlsafe()].shared_comment, "")

        t2 = talk.Talk()
        t2.title = "Another talk"
        t2.put()

        sub_key2 = submissionrecord.make_submission(t2.key, c.key, "track",
                                                    "format")
        voterecord.cast_new_vote(sub_key2, "Reviewer1", 2, "Comments", 1)
        summary = votesummary.retrieve_vote_summary("Reviewer1", round)

        self.assertEquals(len(summary), 2)
        self.assertTrue(summary.has_key(sub_key2.urlsafe()))
        self.assertTrue(summary[sub_key2.urlsafe()].score, 1)
        self.assertTrue(summary[sub_key2.urlsafe()].shared_comment, "Comment2")
        self.assertTrue(summary[sub_key2.urlsafe()].shared_comment, "PRIVATE")

        voterecord.cast_new_vote(sub_key2, "Reviewer2", 2, "Comments", 1)
        self.assertEquals(
            len(votesummary.retrieve_vote_summary("Reviewer1", round)), 2)
        self.assertEquals(
            len(votesummary.retrieve_vote_summary("Reviewer2", round)), 1)
        self.assertEquals(
            len(votesummary.retrieve_vote_summary("Reviewer3", round)), 0)
Esempio n. 14
0
    def test_multiple_submissions_with_duplicate_votes(self):
        VotingRound = 1
        submission_keys = self.common_data_setup()

        existing_vote = voterecord.find_existing_vote_by_reviewer(
            submission_keys[0], "Allan", VotingRound)
        self.assertTrue(existing_vote is None)

        voterecord.cast_new_vote(submission_keys[0], "Allan", 1, "One",
                                 VotingRound)
        voterecord.cast_new_vote(submission_keys[0], "Grisha", 2, "Two",
                                 VotingRound)
        voterecord.cast_new_vote(submission_keys[0], "Anton", -1, "Minus 1",
                                 VotingRound)
        self.assertEquals(
            len(voterecord.find_existing_votes(submission_keys[0], 1)), 3)

        existing_vote = voterecord.find_existing_vote_by_reviewer(
            submission_keys[1], "Allan", VotingRound)
        self.assertTrue(existing_vote is None)

        # Set up the bug
        voterecord.cast_new_vote(submission_keys[1], "Allan", 1, "One",
                                 VotingRound)
        voterecord.cast_new_vote(submission_keys[1], "Allan", 1, "One",
                                 VotingRound)
        voterecord.cast_new_vote(submission_keys[1], "Allan", 1, "One",
                                 VotingRound)
        voterecord.cast_new_vote(submission_keys[1], "Grisha", 2, "Two",
                                 VotingRound)
        voterecord.cast_new_vote(submission_keys[1], "Anton", -1, "Minus 1",
                                 VotingRound)
        self.assertEquals(
            len(voterecord.find_existing_votes(submission_keys[1],
                                               VotingRound)), 5)

        # This is the bug
        # Because of extra vote the total is wrong
        self.assertEqual(
            submission_keys[1].get().get_scores(VotingRound).total_score, 4)

        # Another submission with duplicae votes
        t3 = talk.Talk()
        t3.title = "Talk3 - Another submission with duplicates"
        t3.put()

        subs_key3 = submissionrecord.make_submission(t3.key, self.c.key,
                                                     "track", "format")
        submission_keys.append(subs_key3)
        self.assertEquals(
            len(submissionrecord.retrieve_conference_submissions(self.c.key)),
            3)
        voterecord.cast_new_vote(submission_keys[2], "Harry", 2, "One",
                                 VotingRound)
        voterecord.cast_new_vote(submission_keys[2], "Ron", 2, "One",
                                 VotingRound)
        voterecord.cast_new_vote(submission_keys[2], "Draco", 1, "One",
                                 VotingRound)
        voterecord.cast_new_vote(submission_keys[2], "Draco", 1, "One",
                                 VotingRound)
        voterecord.cast_new_vote(submission_keys[2], "Draco", 1, "One",
                                 VotingRound)
        voterecord.cast_new_vote(submission_keys[2], "Percy", 3, "Three",
                                 VotingRound)
        # check the bug is in place
        self.assertEquals(
            len(voterecord.find_existing_votes(submission_keys[2],
                                               VotingRound)), 6)
        self.assertEqual(
            submission_keys[2].get().get_scores(VotingRound).total_score, 10)

        duplicates_list = dedupvotes.find_duplicate_votes(
            self.c.key, VotingRound)
        self.assertEquals(len(duplicates_list), 2)

        dedupvotes.remove_duplicates(duplicates_list)

        # Check it was all done
        self.assertEquals(
            len(voterecord.find_existing_votes(submission_keys[0],
                                               VotingRound)), 3)
        self.assertEquals(
            len(voterecord.find_existing_votes(submission_keys[1],
                                               VotingRound)), 3)
        self.assertEquals(
            len(voterecord.find_existing_votes(submission_keys[2],
                                               VotingRound)), 4)

        # And the total score is now correct
        self.assertEqual(
            submission_keys[0].get().get_scores(VotingRound).total_score, 2)
        self.assertEqual(
            submission_keys[1].get().get_scores(VotingRound).total_score, 2)
        self.assertEqual(
            submission_keys[2].get().get_scores(VotingRound).total_score, 8)
Esempio n. 15
0
def find_blank_bio_submissions(conf_key):
    submissions = submissionrecord.retrieve_conference_submissions(conf_key)
    speakers = map(lambda sub: sub.talk.parent().get(), submissions)
    return filter_for_blank_bios(speakers)