Beispiel #1
0
def get_latest_submits_for_task(task):
    description_submits = (
        task.submit_set.filter(
            submit_type=submit_constants.SUBMIT_TYPE_DESCRIPTION, time__lte=task.round.end_time
        )
        .exclude(testing_status=submit_constants.SUBMIT_STATUS_REVIEWED)
        .select_related("user")
    )

    source_submits = (
        task.submit_set.filter(
            submit_type=submit_constants.SUBMIT_TYPE_SOURCE, time__lte=task.round.end_time
        )
        .exclude(testing_status=submit_constants.SUBMIT_STATUS_REVIEWED)
        .select_related("user")
    )

    review_submits = task.submit_set.filter(
        submit_type=submit_constants.SUBMIT_TYPE_DESCRIPTION,
        testing_status=submit_constants.SUBMIT_STATUS_REVIEWED,
    ).select_related("user")

    submits_by_user = {}
    for submit in description_submits:
        if submit.user not in submits_by_user:
            submits_by_user[submit.user] = {"description": submit}
        elif submits_by_user[submit.user]["description"].time < submit.time:
            submits_by_user[submit.user]["description"] = submit

    for submit in source_submits:
        if submit.user in submits_by_user:
            if "sources" not in submits_by_user[submit.user]:
                submits_by_user[submit.user]["sources"] = [submit]
            else:
                submits_by_user[submit.user]["sources"].append(submit)

    for submit in review_submits:
        if submit.user not in submits_by_user:
            submits_by_user[submit.user] = {"review": submit}
        elif "review" not in submits_by_user[submit.user]:
            submits_by_user[submit.user]["review"] = submit
        elif submits_by_user[submit.user]["review"].time < submit.time:
            submits_by_user[submit.user]["review"] = submit

    return OrderedDict(
        sorted(
            submits_by_user.items(),
            key=lambda x: (czech_sort.key(x[0].last_name), czech_sort.key(x[0].first_name)),
        )
    )
Beispiel #2
0
def test_pair(a, b):
    ka = key(a)
    kb = key(b)
    assert ka <= kb
    assert not ka > kb
    if a == b:
        assert ka == kb
        assert ka >= kb
        assert not ka < kb
        assert not ka != kb
    else:
        assert not ka == kb
        assert not ka >= kb
        assert ka < kb
        assert ka != kb
Beispiel #3
0
 def get_sort_key(self):
     return [czech_sort.key(c)
             for c in self.categories] + [czech_sort.key(self.title)]
Beispiel #4
0
 def item_key(item):
     return czech_sort.key(item[key])
Beispiel #5
0
 def item_key(item):
     return czech_sort.key(item[key])
Beispiel #6
0
def sort_key(supporter):
    return czech_sort.key(supporter.last_name)