<commit_before>"""Database persistence for Publican.

"""
from django.contrib.auth.models import User
from django.db import models
from . import company
from . import filings
from . import types
from .kit import Date

# Associate each Django user with a company that they manage.

class CompanyUser(models.Model):
    user = models.ForeignKey(User)
    company = models.ForeignKey('Account')

# Persistent versions of each of our objects.

class Account(types.Account, models.Model):
    type = models.CharField(max_length=12)


class Filing(filings.Filing, models.Model):
    region = models.CharField(max_length=12)
    name = models.CharField(max_length=12)
    period = models.CharField(max_length=12)
    date = models.DateField()


class Transaction(types.Transaction, models.Model):
    date = models.DateField()
    debit_account = models.ForeignKey('Account', related_name='debits')
    credit_account = models.ForeignKey('Account', related_name='credits')
    amount = models.DecimalField(max_digits=20, decimal_places=2)
    comment = models.TextField(blank=True)


class Company(company.Company):
    ein='38-0218963'
    name='<NAME>'
    incorporation_date=Date(2011, 8, 1)
    account = None
    today = None

    def transactions(self, **kwargs):
        # TODO
        return []

    def filings(self, **kwargs):
        # TODO
        return []<commit_msg>Implemented the filings filter in Django<commit_after>"""Database persistence for Publican.

"""
from django.contrib.auth.models import User
from django.db import models
from . import company
from . import filings
from . import types
from .kit import Date

# Associate each Django user with a company that they manage.

class CompanyUser(models.Model):
    user = models.ForeignKey(User)
    company = models.ForeignKey('Account')

# Persistent versions of each of our objects.

class Account(types.Account, models.Model):
    type = models.CharField(max_length=12)


class Filing(filings.Filing, models.Model):
    region = models.CharField(max_length=12)
    name = models.CharField(max_length=12)
    period = models.CharField(max_length=12)
    date = models.DateField()


class Transaction(types.Transaction, models.Model):
    date = models.DateField()
    debit_account = models.ForeignKey('Account', related_name='debits')
    credit_account = models.ForeignKey('Account', related_name='credits')
    amount = models.DecimalField(max_digits=20, decimal_places=2)
    comment = models.TextField(blank=True)


class Company(company.Company):
    ein='38-0218963'
    name='Crazy R Software'
    incorporation_date=Date(2011, 8, 1)
    account = None
    today = None

    def filings(self, form=None, period=None):
        """Implement the standard transactions filter, as a Django query."""
        q = Filing.objects

        if form is not None:
            q = q.filter(region=form.region, name=form.name)

        if period is not None:
            q = q.filter(period=unicode(period))

        return q.all()

    def transactions(self, **kwargs):
        # TODO
        return []
{'fraction_non_alphanumeric': 0.10795825179386823, 'fraction_numerical': 0.016960208741030658, 'mean_word_length': 3.7330246913580245, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, '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': '208255', 'n_tokens_mistral': 938, 'n_tokens_neox': 883, 'n_words': 236}