Helpers

Connectors

class results.connectors.suomisport.Suomisport

Connector for updating athlete and licence information from Suomisport API description: https://info.suomisport.fi/wp-content/uploads/2020/01/suomisport-API.html

__init__()

Initialize connection and set setting values.

get_licence_types(date=None)

Get licence types.

Parameters

date (date) – Include only licence types active during this date

Returns

licence types

Return type

list

get_licences(licence_period_id, licence_type_id, ts=None)

Get licences

Parameters
  • licence_period_id – licence period id

  • licence_type_id – licence type id

  • ts – fetch only results updates since ts

  • licence_period_id – int

  • licence_type_id – int

  • ts – datetime

Returns

licences

Return type

list

update_licences(update_only_latest=True, print_to_stdout=False)

Fetch licences and update athletes

Parameters
  • update_only_latest (bool) – update only licences added since last modification time

  • print_to_stdout (bool) – print messages to stdout

Management commands

Approve records

Approve all records from oldest to newest

usage: ./manage.py approverecords

class results.management.commands.approverecords.Command(stdout=None, stderr=None, no_color=False, force_color=False)

Approve records

handle(*args, **options)

The actual logic of the command. Subclasses must implement this method.

Check records

Check all results for records from oldest to newest

usage: ./manage.py checkrecords

class results.management.commands.checkrecords.Command(stdout=None, stderr=None, no_color=False, force_color=False)

Approve records

handle(*args, **options)

The actual logic of the command. Subclasses must implement this method.

Create event

Generate a event, competition and results Only for the test and demo use

usage: ./manage.py createevent <number of athletes>

class results.management.commands.createevent.Command(stdout=None, stderr=None, no_color=False, force_color=False)

Creates an event with competitions and results.

number: Number of athletes in the event. -b: Create base data needed for results.

Creates athletes, categories and competition types if they do not exist.

add_arguments(parser)

Entry point for subclassed commands to add custom arguments.

handle(*args, **options)

The actual logic of the command. Subclasses must implement this method.

Suomisport import

Update athletes and licences from Suomisport

usage: ./manage.py suomisportimport

class results.management.commands.suomisportimport.Command(stdout=None, stderr=None, no_color=False, force_color=False)

Approve records

add_arguments(parser)

Entry point for subclassed commands to add custom arguments.

handle(*args, **options)

The actual logic of the command. Subclasses must implement this method.

Middleware

CurrentUSer

class results.middleware.current_user.CurrentUserMiddleware(get_response)

Middleware for getting a request user value.

Used in writing change log.

__init__(get_response)

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

Mixins

LogChanges

class results.mixins.change_log.LogChangesMixing(*args, **kwargs)

Logging mixing which writes changes to Django’s admin log.

Logs add, delete and modified fields for all models using a mixin and values for the fields defined in the LOG_VALUE_FIELDS setting.

__init__(*args, **kwargs)

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

property changed_fields
Returns

changed field keys

Return type

list

delete(*args, **kwargs)

Save log entry for data deletion

property diff
Returns

changed data

Return type

dict

save(*args, **kwargs)

Create a log entry for add or change messages

EagerLoading

class results.mixins.eager_loading.EagerLoadingMixin

Mixin to select_related and prefetch_related queries From the comments of http://ses4j.github.io/2015/11/23/optimizing-slow-django-rest-framework-performance/

classmethod setup_eager_loading(queryset)

Sets select_related and prefetch_related attributes to queryset if specified in serializer

Parameters

queryset

Returns

queryset including select_related and prefetch_related attributes

Return type

QuerySet

Utils

CustomPagePagination

class results.utils.pagination.CustomPagePagination

Custom pagination class to use with Vue Bootstrap pagination.

Records

results.utils.records.check_records(result)

Checks possible records for the result and creates them if found.

Parameters

result (result object) –

results.utils.records.check_records_partial(partial)

Checks possible records for the partial result and creates them if found.

Parameters

partial (partial result object) –

results.utils.records.get_categories(result)

Returns the list of possible record categories for the result.

Parameters

result (result object) –

Returns

categories

Return type

QuerySet