kata package

kata.admin module

kata.apps module

class kata.apps.KataConfig(app_name, app_module)[source]

Bases: django.apps.config.AppConfig

name = 'kata'

kata.forms module

class kata.forms.KataBracketAddPersonForm(division=None, **kwargs)[source]

Bases: django.forms.models.ModelForm

__init__(division=None, **kwargs)[source]

Initialize self. See help(type(self)) for accurate signature.

clean()[source]

Hook for doing any extra form-wide cleaning after Field.clean() has been called on every field. Any ValidationError raised by this method will not be associated with a particular field; it will have a special-case association with the field named ‘__all__’.

media
class kata.forms.KataBracketAddTeamForm(division=None, **kwargs)[source]

Bases: django.forms.models.ModelForm

__init__(division=None, **kwargs)[source]

Initialize self. See help(type(self)) for accurate signature.

clean()[source]

Hook for doing any extra form-wide cleaning after Field.clean() has been called on every field. Any ValidationError raised by this method will not be associated with a particular field; it will have a special-case association with the field named ‘__all__’.

media
class kata.forms.KataMatchForm(**kwargs)[source]

Bases: django.forms.models.ModelForm

__init__(**kwargs)[source]

Initialize self. See help(type(self)) for accurate signature.

clean()[source]

Hook for doing any extra form-wide cleaning after Field.clean() has been called on every field. Any ValidationError raised by this method will not be associated with a particular field; it will have a special-case association with the field named ‘__all__’.

media

kata.models module

class kata.models.KataBracket(id, division)[source]

Bases: django.db.models.base.Model

Parameters
  • id (AutoField) – Id

  • division (ForeignKey to Division) – Division

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

add_person(p)[source]
build(people)[source]
division

Model field: division, accesses the Division model.

division_id

Model field: division

get_absolute_url()[source]
get_next_match()[source]
get_people()[source]
get_winners()[source]
id

Model field: ID

kataround_set

Model field: bracket, accesses the M2M KataRound model.

n_round
objects = <django.db.models.manager.Manager object>
rounds
class kata.models.KataMatch(id, eventlink, round, done, score1, score2, score3, score4, score5, combined_score, tie_score)[source]

Bases: django.db.models.base.Model

Parameters
  • id (AutoField) – Id

  • eventlink (ForeignKey to EventLink) – Eventlink

  • round (ForeignKey to KataRound) – Round

  • done (BooleanField) – Done

  • score1 (DecimalField) – Score1

  • score2 (DecimalField) – Score2

  • score3 (DecimalField) – Score3

  • score4 (DecimalField) – Score4

  • score5 (DecimalField) – Score5

  • combined_score (DecimalField) – Combined score

  • tie_score (DecimalField) – Tie score

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

combined_score

Model field: combined score

diff(other)[source]
done

Model field: done

Model field: eventlink, accesses the EventLink model.

Model field: eventlink

id

Model field: ID

objects = <django.db.models.manager.Manager object>
round

Model field: round, accesses the KataRound model.

round_id

Model field: round

save(*args, **kwargs)[source]

Save the current instance. Override this in a subclass if you want to control the saving process.

The ‘force_insert’ and ‘force_update’ parameters can be used to insist that the “save” must be an SQL insert or update (or equivalent for non-SQL backends), respectively. Normally, they should not be set.

score1

Model field: score1

score2

Model field: score2

score3

Model field: score3

score4

Model field: score4

score5

Model field: score5

scores
tie_score

Model field: tie score

class kata.models.KataRound(id, bracket, round, order, prev_round, locked, n_winner_needed)[source]

Bases: django.db.models.base.Model

Parameters
  • id (AutoField) – Id

  • bracket (ForeignKey to KataBracket) – Bracket

  • round (SmallIntegerField) – Round

  • order (SmallIntegerField) – Order

  • prev_round (ForeignKey to KataRound) – Prev round

  • locked (BooleanField) – Locked

  • n_winner_needed (PositiveSmallIntegerField) – N winner needed

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

bracket

Model field: bracket, accesses the KataBracket model.

bracket_id

Model field: bracket

done
get_next_match()[source]
id

Model field: ID

katamatch_set

Model field: round, accesses the M2M KataMatch model.

kataround_set

Model field: prev round, accesses the M2M KataRound model.

locked

Model field: locked

match_callback(match=None)[source]
matches
n_winner_needed

Model field: n winner needed

objects = <django.db.models.manager.Manager object>
order

Model field: order

prev_round

Model field: prev round, accesses the KataRound model.

prev_round_id

Model field: prev round

round

Model field: round

started
kata.models.validate_score(score)[source]

kata.test_views module

class kata.test_views.KataDetailTestCase(methodName='runTest')[source]

Bases: django_webtest.WebTest

setUp()[source]

Hook method for setting up the test fixture before exercising it.

test_add_team_form()[source]
test_person_form()[source]
test_set_score()[source]

kata.tests module

class kata.tests.TestKataBracket(methodName='runTest')[source]

Bases: django.test.testcases.TestCase

test_ignorable_tie()[source]
test_rounding_error()[source]

Test for an issue where storing scores as floats has round off error and the wrong person wins.

a and d should have the same combined_score but a wins on the tie break. There can be round off error in d’s favour.

test_rounding_error_postgres()[source]

Test for an issue where storing scores as floats has round off error and the wrong person wins. Only failed on PostgreSQL.

a and b should have the same combined_score but b wins on the tie break. With PostgreSQL, the sort was working incorrectly and Django was incorrectly finding a tie. Seems like they were using slightly different numbers. Fixed by switching to DecimalField.

test_six()[source]
test_two()[source]
class kata.tests.TestKataMatch(methodName='runTest')[source]

Bases: django.test.testcases.TestCase

test_cmp()[source]

Test that comparisson works properly.

kata.tests.get_person(bracket, name)[source]
kata.tests.make_bracket(n)[source]

kata.urls module

kata.views module

class kata.views.KataBracketAddMatch(**kwargs)[source]

Bases: kata.views.KataBracketDetails, django.views.generic.edit.FormView

form_class

alias of kata.forms.KataBracketAddPersonForm

form_valid(form, skip=False)[source]

If the form is valid, redirect to the supplied URL.

get_context_data(**kwargs)[source]

Insert the single object into the context dict.

get_form_kwargs()[source]

Return the keyword arguments for instantiating the form.

get_success_url()[source]

Return the URL to redirect to after processing a valid form.

permission_required = 'accounts.edit'
post(request, *args, **kwargs)[source]

Handle POST requests: instantiate a form instance with the passed POST variables and then check if it’s valid.

template_name = 'kata/katabracket_detail.html'
class kata.views.KataBracketAddTeamMatch(**kwargs)[source]

Bases: kata.views.KataBracketAddMatch

form_class

alias of kata.forms.KataBracketAddTeamForm

form_valid(form)[source]

If the form is valid, redirect to the supplied URL.

permission_required = 'accounts.edit'
class kata.views.KataBracketDeleteMatch(**kwargs)[source]

Bases: django.contrib.auth.mixins.PermissionRequiredMixin, django.views.generic.edit.DeleteView

delete(request, *args, **kwargs)[source]

Call the delete() method on the fetched object and then redirect to the success URL.

dispatch(request, *args, **kwargs)
get_object(queryset=None)[source]

Return the object the view is displaying.

Require self.queryset and a pk or slug argument in the URLconf. Subclasses can override this to return any object.

get_success_url()[source]
model

alias of kata.models.KataMatch

permission_required = 'accounts.edit'
template_name = 'kata/katabracket_detail.html'
class kata.views.KataBracketDetails(**kwargs)[source]

Bases: django.contrib.auth.mixins.PermissionRequiredMixin, django.views.generic.detail.DetailView

context_object_name = 'bracket'
get_context_data(**kwargs)[source]

Insert the single object into the context dict.

model

alias of kata.models.KataBracket

permission_required = 'accounts.view'
class kata.views.KataBracketEditMatch(**kwargs)[source]

Bases: django.contrib.auth.mixins.PermissionRequiredMixin, django.views.generic.edit.UpdateView

form_class

alias of kata.forms.KataMatchForm

get_context_data(**kwargs)[source]

Insert the form into the context dict.

get_object(queryset=None)[source]

Return the object the view is displaying.

Require self.queryset and a pk or slug argument in the URLconf. Subclasses can override this to return any object.

get_success_url()[source]

Return the URL to redirect to after processing a valid form.

model

alias of kata.models.KataMatch

permission_required = 'accounts.edit'
template_name = 'kata/katabracket_detail.html'
kata.views.check_match_bracket(view, obj)[source]

Module contents