<commit_before>from django.db import models
from djorm_pgarray.fields import ArrayField

from .base import (OCDBase, LinkBase, OCDIDField, RelatedBase, RelatedEntityBase, MimetypeLinkBase,
                   IdentifierBase)
from .people_orgs import Organization
from .jurisdiction import LegislativeSession
from .. import common


class Bill(OCDBase):
    id = OCDIDField(ocd_type='bill')
    legislative_session = models.ForeignKey(LegislativeSession, related_name='bills')
    identifier = models.CharField(max_length=100)

    title = models.TextField()

    from_organization = models.ForeignKey(Organization, related_name='bills', null=True)
    classification = ArrayField(dbtype="text")      # check that array values are in enum?
    subject = ArrayField(dbtype="text")

    def __str__(self):
        return '{} in {}'.format(self.identifier, self.legislative_session)

    class Meta:
        index_together = [
            ['from_organization', 'legislative_session', 'identifier'],
        ]

    # ------------------------------------------------------------------------
    # Display methods used in the admin.
    # ------------------------------------------------------------------------
    def get_jurisdiction_name(self):
        return self.legislative_session.jurisdiction.name

    def get_session_name(self):
        return self.legislative_session.name

    def get_truncated_sponsors(self):
        spons = ', '.join(s.name for s in self.sponsorships.all()[:5])
        return defaultfilters.truncatewords(spons, 10)

    def get_truncated_title(self):
        return defaultfilters.truncatewords(self.title, 25)

    get_jurisdiction_name.short_description = 'Jurisdiction'
    get_session_name.short_description = 'Session'
    get_truncated_sponsors.short_description = 'Sponsors'
    get_truncated_title.short_description = 'Title'


class BillAbstract(RelatedBase):
    bill = models.ForeignKey(Bill, related_name='abstracts')
    abstract = models.TextField()
    note = models.TextField(blank=True)
    date = models.TextField(max_length=10, blank=True)  # YYYY[-MM[-DD]]


class BillTitle(RelatedBase):
    bill = models.ForeignKey(Bill, related_name='other_titles')
    title = models.TextField()
    note = models.TextField(blank=True)


class BillIdentifier(IdentifierBase):
    bill = models.ForeignKey(Bill, related_name='other_identifiers')
    note = models.TextField(blank=True)


class BillAction(RelatedBase):
    bill = models.ForeignKey(Bill, related_name='actions')
    organization = models.ForeignKey(Organization, related_name='actions')
    description = models.TextField()
    date = models.CharField(max_length=10)    # YYYY[-MM[-DD]]
    classification = ArrayField(dbtype="text")      # enum
    order = models.PositiveIntegerField()

    class Meta:
        ordering = ['order']<commit_msg>removed some methods on Bill that weren't needed<commit_after>from django.db import models
from djorm_pgarray.fields import ArrayField

from .base import (OCDBase, LinkBase, OCDIDField, RelatedBase, RelatedEntityBase, MimetypeLinkBase,
                   IdentifierBase)
from .people_orgs import Organization
from .jurisdiction import LegislativeSession
from .. import common


class Bill(OCDBase):
    id = OCDIDField(ocd_type='bill')
    legislative_session = models.ForeignKey(LegislativeSession, related_name='bills')
    identifier = models.CharField(max_length=100)

    title = models.TextField()

    from_organization = models.ForeignKey(Organization, related_name='bills', null=True)
    classification = ArrayField(dbtype="text")      # check that array values are in enum?
    subject = ArrayField(dbtype="text")

    def __str__(self):
        return '{} in {}'.format(self.identifier, self.legislative_session)

    class Meta:
        index_together = [
            ['from_organization', 'legislative_session', 'identifier'],
        ]


class BillAbstract(RelatedBase):
    bill = models.ForeignKey(Bill, related_name='abstracts')
    abstract = models.TextField()
    note = models.TextField(blank=True)
    date = models.TextField(max_length=10, blank=True)  # YYYY[-MM[-DD]]


class BillTitle(RelatedBase):
    bill = models.ForeignKey(Bill, related_name='other_titles')
    title = models.TextField()
    note = models.TextField(blank=True)


class BillIdentifier(IdentifierBase):
    bill = models.ForeignKey(Bill, related_name='other_identifiers')
    note = models.TextField(blank=True)


class BillAction(RelatedBase):
    bill = models.ForeignKey(Bill, related_name='actions')
    organization = models.ForeignKey(Organization, related_name='actions')
    description = models.TextField()
    date = models.CharField(max_length=10)    # YYYY[-MM[-DD]]
    classification = ArrayField(dbtype="text")      # enum
    order = models.PositiveIntegerField()

    class Meta:
        ordering = ['order']
{'fraction_non_alphanumeric': 0.13270336894001644, 'fraction_numerical': 0.0039030402629416597, 'mean_word_length': 3.615165876777251, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7292686', 'n_tokens_mistral': 1422, 'n_tokens_neox': 1338, 'n_words': 280}