Code documentation

Core models

class tausi.models.decision.Abbreviation(id, decision, abbreviation, in_full, nature)
exception DoesNotExist
exception MultipleObjectsReturned
class Nature(value)

An enumeration.

property title
class tausi.models.decision.Annotation(*args, **kwargs)

An annotation is a short comment on the text of a decision.

It is loosely modelled on the W3C’s Annotation model (see https://www.w3.org/TR/annotation-model/). An annotation is associated with the text in the HTML of a decision through the target property, which has two attributes:

anchor_id: the id of the closest element to contain the annotation selectors: an array of selectors from the annotation model standard. Only TextPositionSelector and

TextQuoteSelector are supported.

exception DoesNotExist
exception MultipleObjectsReturned
class tausi.models.decision.AreaOfLaw(id, name, description)
exception DoesNotExist
exception MultipleObjectsReturned
class tausi.models.decision.Attachment(id, decision, file, size, filename, nature, mime_type, created_at, updated_at)
exception DoesNotExist
exception MultipleObjectsReturned
class tausi.models.decision.AttachmentNature(id, name, description)
exception DoesNotExist
exception MultipleObjectsReturned
class tausi.models.decision.CaseHistory(id, decision, case_number, court, delivered_date, outcome, ordering, historical_decision)
exception DoesNotExist
exception MultipleObjectsReturned
class tausi.models.decision.CaseType(id, name, description)
exception DoesNotExist
exception MultipleObjectsReturned
class tausi.models.decision.CasebackSkipReason(id, name, description)
exception DoesNotExist
exception MultipleObjectsReturned
class tausi.models.decision.Decision(*args, **kwargs)

This model represents a decision made on a case.

exception DoesNotExist
exception MultipleObjectsReturned
property akn_doc

A cobalt.akn.judgment.JudgmentStructure object for this decision.

assign_mnc(permissive=True)

Assign an MNC to this decision, if one hasn’t already been assigned.

build_parties_for_citation()

Returns a string consisting of the first party in each group’s surname, plus ‘& another’ / ‘& others’ as appropriate, with proponents and opponents separated by ‘v’ and interested parties prefaced by ‘;’. Arbitrary text per party group is added in brackets at the end of each group, using only the primary docket’s related DecisionPartyGroupText.

The ‘interesteds’ group is separated further by role, e.g.

‘Name of body (Interested party); Name of other body (Amicus curiae)’.

Use mnc_parties_override instead if there is one (single-party cases).

build_parties_for_running_header()

Returns a string consisting of the first party in each group’s surname, plus ‘& another’ / ‘& others’ as appropriate, with proponents and opponents separated by ‘v’. Doesn’t include interested parties or arbitrary text.

Use mnc_parties_override instead if there is one (single-party cases).

frbr_expression_uri

Expression FRBR URI corresponding to the MNC.

frbr_uri

Returns a cobalt.FrbrUri instance for this decision.

This will always return a value, even if the decision is missing information, as it is necessary for the Akoma Ntoso XML.

frbr_work_uri

FRBR URI corresponding to the MNC.

full_mnc

Full MNC: parties, case number, short MNC, delivery date.

generate_frbr_work_uri(permissive=True)

Generate a FRBR Work URI string for this document. If permissive is False, raise ValueError if required details are missing.

generate_full_mnc()

Generate a (candidate) full MNC string: {parties} ({case number}) [{year}] {court code} {number} (KLR) ({division}) ({date}) ({action}), e.g. Foo Bar v Bar Foo (Civil Case No. 674 of 2014) [2018] KEHC 500 (KLR) (Civ) (August 3, 2018) (Order) (The division is only included for certain courts, which have include_division_in_mnc = True.)

generate_header()

Generates a header element and inserts it into the decision XML. Includes the introductory text that follows the summary.

generate_index_mnc()

Generate an MNC string for use in indexes: {parties} [{year}] {short MNC}, e.g. Ouma v Spectre International Ltd [2013] KEIC 2 (KLR)

generate_serial_number()

Generate a candidate serial number for this decision, based on the delivery year and court.

generate_short_mnc()

Generate a (candidate) short MNC string: [{year}] {court code} {number} (KLR), e.g. [2018] KEHC 500 (KLR)

generate_summary_citations()

Generates text for the summary of the decision.

get_citations_by_nature()

Returns a quadruple of pairs of citations (‘cases’, ‘legislation’, ‘texts’, ‘instruments’) in order of ‘ordering’. If there are no citations in a group, that group’s list will be empty.

get_parties_by_group()

Returns a triple of lists of parties on a decision for all dockets (‘proponent’, ‘opponent’, ‘interested’) in order of ‘ordering’. If there are no parties in a group, that group’s list will be empty.

property listing_title

Title to be used in listings. Includes parties and case_number_string. e.g. Party A v Party B (Civil Appeal 12 of 2021)

property long_title

A long title to complement the short title.

publish()

Mark this decision as published.

publish_catalog()

Mark this decision’s core fields as published

publish_summary()

Mark this decision’s summary as published.

save(*args, **kwargs)

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.

serial_number

Serial number for MNC. Unique for a year and court code.

short_mnc

Short MNC, eg. ‘[2019] KEHC 123 (KLR)’

property short_title

A short title, useful in views.

soft_delete()

Soft-delete this decision.

start_datacapture_workflow()

Start the DataCapture workflow for this decision.

strip_empty_summary_fields()

During save, clean out any empty summary fields

to_html()

Render this decision as the default webpage HTML. Will include summary if the decision is reportable.

to_html_without_summary()

Render this decision as the default webpage HTML. Will not include summary, even if the decision is reportable.

update_ref_hrefs(old_frbr_uri, new_frbr_uri)

Re-write ref targets from old_frbr_uri to new_frbr_uri.

update_xml(xml=None)

Updates the XML for the decision, also ensuring it has all the correct metadata from the object. This is the preferred way to change the XML for the decision.

versions()

Return a queryset of reversion.models.Version objects for revisions for this decision, most recent first.

class tausi.models.decision.DecisionAction(id, name, description)
exception DoesNotExist
exception MultipleObjectsReturned
class tausi.models.decision.DecisionAdvocate(id, name, decision, ordering, for_party)
exception DoesNotExist
exception MultipleObjectsReturned
class tausi.models.decision.DecisionAlternativeCitation(*args, **kwargs)

This model stores alternative Medium Neutral Citations (MNCs) of a decision. e.g. ABC v XYZ (Civil Case 1 of 2022) [2022] KECA 1 (KLR)

exception DoesNotExist
exception MultipleObjectsReturned
class tausi.models.decision.DecisionCharge(id, name, description, sections, statute, recommended_sentence)
exception DoesNotExist
exception MultipleObjectsReturned
class tausi.models.decision.DecisionChargeSentence(id, decision, charge, recommended_sentence, sentence_meted)
exception DoesNotExist
exception MultipleObjectsReturned
class tausi.models.decision.DecisionDocket(id, decision, case_number_string, case_type, case_number_numeric, filing_year, filing_county, created_at, updated_at, created_by_user, updated_by_user, ordering)
exception DoesNotExist
exception MultipleObjectsReturned
get_arbitrary_text()

Returns a dictionary of aribtrary text per party group on a docket (‘proponent’, ‘opponent’, ‘interested’). If there is no arbitrary text for a group a group, it doesn’t appear in the list.

get_parties_by_group()

Returns a triple of lists of parties on a docket (‘proponent’, ‘opponent’, ‘interested’) in order of ‘ordering’. If there are no parties in a group, that group’s list will be empty.

save(*args, **kwargs)

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.

class tausi.models.decision.DecisionFlag(id, label, color, description)
exception DoesNotExist
exception MultipleObjectsReturned
class tausi.models.decision.DecisionOutcome(id, name, description)
exception DoesNotExist
exception MultipleObjectsReturned
class tausi.models.decision.DecisionParty(id, name, name_for_citation, role, ordering, docket, party_group)
exception DoesNotExist
exception MultipleObjectsReturned
class PartyGroup(value)

An enumeration.

save(*args, **kwargs)

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.

class tausi.models.decision.DecisionPartyGroupText(id, docket, proponents, opponents, interesteds)
exception DoesNotExist
exception MultipleObjectsReturned
class tausi.models.decision.DecisionQuerySet(model=None, query=None, using=None, hints=None)
class tausi.models.decision.DecisionReportableReason(id, name, description)
exception DoesNotExist
exception MultipleObjectsReturned
class tausi.models.decision.DecisionSentence(id, name, description)
exception DoesNotExist
exception MultipleObjectsReturned
class tausi.models.decision.DecisionUnlistedParties(id, docket, proponents, opponents, interesteds)
exception DoesNotExist
exception MultipleObjectsReturned
class tausi.models.decision.DecisionWarning(id, decision, code, created_at, description)
exception DoesNotExist
exception MultipleObjectsReturned
class tausi.models.decision.DifferenceInJudicialReasoning(id, decision, legal_issue, target, text)
exception DoesNotExist
exception MultipleObjectsReturned
class tausi.models.decision.LawReformIssue(id, decision, target, text, nature, legislation, provisions, notes)
exception DoesNotExist
exception MultipleObjectsReturned
class tausi.models.decision.LawReformIssueNature(id, name, description)
exception DoesNotExist
exception MultipleObjectsReturned
class tausi.models.decision.LegacyDetails(*args, **kwargs)

This model represents the legacy details for a decision imported from a legacy case.

Once the decision has gone past the “published” stage in the workflow, the processed attribute is set to True, and the details on the Decision object (including content_html) can be used in favour of the information on this object.

Note that at the end of the Catalog stage, when catalog_published is set to True, while the key metadata is then captured, the content hasn’t been marked up yet. So for a legacy decision, the legacy content_html field must still be used until published is set to True.

exception DoesNotExist
exception MultipleObjectsReturned
class tausi.models.decision.NonEnglishTerm(id, decision, term, in_english)
exception DoesNotExist
exception MultipleObjectsReturned
class tausi.models.decision.PartyProfile(id, name, description)
exception DoesNotExist
exception MultipleObjectsReturned
class tausi.models.decision.PartyRole(id, name, plural)
exception DoesNotExist
exception MultipleObjectsReturned
tausi.models.decision.attachment_filename(instance, filename)

Make S3 attachment filenames relative to the document, this may be modified to ensure it’s unique by the storage system.

tausi.models.decision.check_decision(decision)

Queue up the decision and any related decisions to be checked for duplication and other warnings.

tausi.models.decision.decision_document_filename(decision, filename)

Make the filename relative to the decision object

tausi.models.decision.generate_consolidated_case_number_string(dockets)

Generate a case number string for consolidated decisions based on all related dockets. e.g. Petition 12 of 2020 & 13 of 2021 & Civil Suit 1 & 32 of 2020 (Consolidated)

  1. Generate the dict of consolidated cases with the case_type PK as the key

  2. For each case_type, create a nested dictionary with the filing year as the key,

    and the value will be a list of all case_number_numeric values for that year

  3. If a docket has the same case_type and a different filing_year, the filing_year will be added

    as a new key on the nested dictionary of the same case type and case_number_numeric added to that new key

  4. Sample consolidated_dict:
    example_consolidated_dict = {
    1: {

    2020: [12], 2021: [13]

    }, 2: {

    2020: [1, 32]

    }

    }

  5. Generate substrings for each filing_year for each case_type and fold them into the consolidated case_number_string

  6. Dockets with missing details are skipped

tausi.models.decision.perform_checks(decision)

This method takes in a decision and checks it for duplicates. If any are found, a DecisionWarning object is created with the details. Duplicates are identified using the list of parties, delivery date and case numbers. If decisions share any two, a duplicate warning is saved. If the delivery date is in the future or on a weekend, a warning is created.

tausi.models.decision.post_save_decision(sender, instance, **kwargs)

Check a new decision for duplicates or any inconsistencies and raise appropriate warnings.