<commit_before># -*- coding: utf-8 -*-
from django.db import models
from location.models import GlobalRegion, Country, StateProvince, RegionDistrict, Locality
import string
from smart_selects.db_fields import ChainedForeignKey


class DataDictionary(models.Model):
    definition = models.TextField(blank=True)

    class Meta:
        abstract = True


class AcquisitionMethod(DataDictionary):
    method = models.CharField(max_length=50, unique=True)
    preposition = models.CharField(help_text="Preposition to use with this "
        "acquisition method, usually 'by' or 'from'.", max_length=30)

    def __unicode__(self):
        return self.method


class LoanStatus(DataDictionary):
    status = models.CharField(max_length=50, unique=True)

    def __unicode__(self):
        return self.status

    class Meta:
        verbose_name_plural = "Loan statuses"


class AccessStatus(DataDictionary):
    status = models.CharField(max_length=50, unique=True)

    def __unicode__(self):
        return self.status

    class Meta:
        verbose_name_plural = "Access statuses"


class Obtained(DataDictionary):
    how = models.CharField(max_length=50, unique=True)

    def __unicode__(self):
        return self.how

    class Meta:
        verbose_name_plural = "Source acquisition methods"


class MuseumObject(models.Model):
    """
    An object held by the museum, typically a physical object or photo
    """
    registration_number = models.IntegerField(db_index=True, unique=True)
    old_registration_number = models.CharField(max_length=50, blank=True)
    other_number = models.CharField(max_length=50, blank=True)
    reg_counter = models.CharField(max_length=50, blank=True)

    functional_category = models.ForeignKey('FunctionalCategory',
            null=True, blank=True,
            verbose_name='previous category name',
            help_text='Functional Category from the old database')
    artefact_type = models.ForeignKey('ArtefactType', verbose_name='item name')
    category = models.ManyToManyField('Category', blank=True,
            help_text='New style categories')

    storage_section = models.CharField(max_length=4, blank=True)
    storage_unit = models.CharField(max_length=4, blank=True)
    storage_bay = models.CharField(max_length=4, blank=True)
    storage_shelf_box_drawer = models.CharField(max_length=4, blank=True,
        verbose_name="Storage shelf/box/drawer")

    acquisition_date = models.DateField("date acquired by museum",
            null=True, blank=True)
    acquisition_method = models.ForeignKey(AcquisitionMethod, null=True)
    loan_status = models.ForeignKey(LoanStatus, null=True,
            help_text='Is object on outwards/inwards loan')
    access_status = models.ForeignKey(AccessStatus, null=True)
    reg_info = models.TextField("registration information", blank=True)

    registered_by = models.ForeignKey('parties.MuseumStaff', null=True)
    registration_date = models.DateField(null=True)

    cultural_bloc = models.ForeignKey('CulturalBloc', null=True,
            blank=True,
            help_text='Old region classification')
    place = models.ForeignKey('location.Place', null=True, db_index=True,
            help_text='Where the object is from')

# New Geo-locations data
    global_region = models.ForeignKey(GlobalRegion, blank=True, null=True,
        on_delete=models.SET_NULL)
    country = ChainedForeignKey(Country, blank=True, null=True,
        chained_field='global_region', chained_model_field='parent',
        show_all=False, auto_choose=True, on_delete=models.SET_NULL)
    state_province = ChainedForeignKey(StateProvince, blank=True, null=True,
        chained_field='country', chained_model_field='parent',
        show_all=False, auto_choose=True, on_delete=models.SET_NULL)
    region_district = ChainedForeignKey(RegionDistrict, blank=True, null=True,
        chained_field='state_province', chained_model_field='parent',
        show_all=False, auto_choose=True, on_delete=models.SET_NULL)
    locality = ChainedForeignKey(Locality, blank=True, null=True,
        chained_field='region_district', chained_model_field='parent',
        show_all=False, auto_choose=True, on_delete=models.SET_NULL)

    donor = models.ForeignKey(
            'parties.Person',
            null=True,
            blank=True,
            db_index=True,
            related_name="donated_objects",
            help_text='Main donor record')
    donor_2 = models.ForeignKey(
            'parties.Person',
            null=True,
            blank=True,
            related_name="donated_objects_2",
            verbose_name="2nd recorded donor (historic/wrong)",
            help_text='2nd Imported donor record, possibly historic')
    how_donor_obtained = models.ForeignKey(Obtained, null=True,
            related_name='donor_obtained')
    ## TODO: when_donor_obtained should be DateField
    ### But contains some imprecise dates
    when_donor_obtained = models.CharField(max_length=50, blank=True,
        help_text="Please use the following format: <em>YYYY-MM-DD</em>.")

    photographer = models.CharField(max_length=100)
    collector = models.ForeignKey(
            'parties.Person',
            null=True,
            blank=True,
            db_index=True,
            related_name="collected_objects")
    collector_2 = models.ForeignKey(
            'parties.Person',
            null=True,
            blank=True,
            verbose_name="2nd recorded collector (historic/wrong)",
            related_name="collected_objects_2")
    how_collector_obtained = models.ForeignKey(Obtained, null=True,
            related_name="collector_obtained")
    when_collector_obtained = models.CharField(max_length=50, blank=True,
            help_text="Please use the following format: <em>YYYY-MM-DD</em>.")

    source = models.CharField(max_length=50)
    how_source_obtained = models.ForeignKey(Obtained, null=True,
            related_name='source_obtained')

    maker = models.ForeignKey('parties.Maker', null=True, blank=True)
    manufacture_technique = models.CharField(max_length=200, blank=True)
    creation_date = models.DateField(null=True, blank=True)
    site_name_number = models.CharField(max_length=150, blank=True)
    raw_material = models.CharField(max_length=150, blank=True)
    indigenous_name = models.CharField(max_length=100, blank=True)
    recorded_use = models.CharField(max_length=300, blank=True)
    assoc_cultural_group = models.CharField(max_length=100, blank=True)
    exhibition_history = models.TextField(blank=True)

    category_illustrated = models.CharField(max_length=100, blank=True)
    artefact_illustrated = models.CharField(max_length=100, blank=True)

    description = models.TextField(blank=True)

    is_public_comment = models.BooleanField(default=False,
            help_text='Is comment allowed to be shown publicly')
    comment = models.TextField(blank=True)
    private_comment = models.TextField(
            blank=True,
            help_text="Only visible to staff")
    significance = models.TextField("statement of significance",
            blank=True)

    width = models.IntegerField(null=True, blank=True,
            help_text="millimeters")
    length = models.IntegerField(null=True, blank=True,
            help_text="millimeters")
    height = models.IntegerField(null=True, blank=True,
            help_text="millimeters")<commit_msg>show registered by, and registration date in admin, and rename 'is public comment' to 'public comment'<commit_after># -*- coding: utf-8 -*-
from django.db import models
from location.models import GlobalRegion, Country, StateProvince, RegionDistrict, Locality
import string
from smart_selects.db_fields import ChainedForeignKey


class DataDictionary(models.Model):
    definition = models.TextField(blank=True)

    class Meta:
        abstract = True


class AcquisitionMethod(DataDictionary):
    method = models.CharField(max_length=50, unique=True)
    preposition = models.CharField(help_text="Preposition to use with this "
        "acquisition method, usually 'by' or 'from'.", max_length=30)

    def __unicode__(self):
        return self.method


class LoanStatus(DataDictionary):
    status = models.CharField(max_length=50, unique=True)

    def __unicode__(self):
        return self.status

    class Meta:
        verbose_name_plural = "Loan statuses"


class AccessStatus(DataDictionary):
    status = models.CharField(max_length=50, unique=True)

    def __unicode__(self):
        return self.status

    class Meta:
        verbose_name_plural = "Access statuses"


class Obtained(DataDictionary):
    how = models.CharField(max_length=50, unique=True)

    def __unicode__(self):
        return self.how

    class Meta:
        verbose_name_plural = "Source acquisition methods"


class MuseumObject(models.Model):
    """
    An object held by the museum, typically a physical object or photo
    """
    registration_number = models.IntegerField(db_index=True, unique=True)
    old_registration_number = models.CharField(max_length=50, blank=True)
    other_number = models.CharField(max_length=50, blank=True)
    reg_counter = models.CharField(max_length=50, blank=True)

    functional_category = models.ForeignKey('FunctionalCategory',
            null=True, blank=True,
            verbose_name='previous category name',
            help_text='Functional Category from the old database')
    artefact_type = models.ForeignKey('ArtefactType', verbose_name='item name')
    category = models.ManyToManyField('Category', blank=True,
            help_text='New style categories')

    storage_section = models.CharField(max_length=4, blank=True)
    storage_unit = models.CharField(max_length=4, blank=True)
    storage_bay = models.CharField(max_length=4, blank=True)
    storage_shelf_box_drawer = models.CharField(max_length=4, blank=True,
        verbose_name="Storage shelf/box/drawer")

    acquisition_date = models.DateField("date acquired by museum",
            null=True, blank=True)
    acquisition_method = models.ForeignKey(AcquisitionMethod, null=True)
    loan_status = models.ForeignKey(LoanStatus, null=True,
            help_text='Is object on outwards/inwards loan')
    access_status = models.ForeignKey(AccessStatus, null=True)
    reg_info = models.TextField("registration information", blank=True)

    registered_by = models.ForeignKey('parties.MuseumStaff', null=True, blank=True)
    registration_date = models.DateField(null=True, blank=True)

    cultural_bloc = models.ForeignKey('CulturalBloc', null=True,
            blank=True,
            help_text='Old region classification')
    place = models.ForeignKey('location.Place', null=True, db_index=True,
            help_text='Where the object is from')

# New Geo-locations data
    global_region = models.ForeignKey(GlobalRegion, blank=True, null=True,
        on_delete=models.SET_NULL)
    country = ChainedForeignKey(Country, blank=True, null=True,
        chained_field='global_region', chained_model_field='parent',
        show_all=False, auto_choose=True, on_delete=models.SET_NULL)
    state_province = ChainedForeignKey(StateProvince, blank=True, null=True,
        chained_field='country', chained_model_field='parent',
        show_all=False, auto_choose=True, on_delete=models.SET_NULL)
    region_district = ChainedForeignKey(RegionDistrict, blank=True, null=True,
        chained_field='state_province', chained_model_field='parent',
        show_all=False, auto_choose=True, on_delete=models.SET_NULL)
    locality = ChainedForeignKey(Locality, blank=True, null=True,
        chained_field='region_district', chained_model_field='parent',
        show_all=False, auto_choose=True, on_delete=models.SET_NULL)

    donor = models.ForeignKey(
            'parties.Person',
            null=True,
            blank=True,
            db_index=True,
            related_name="donated_objects",
            help_text='Main donor record')
    donor_2 = models.ForeignKey(
            'parties.Person',
            null=True,
            blank=True,
            related_name="donated_objects_2",
            verbose_name="2nd recorded donor (historic/wrong)",
            help_text='2nd Imported donor record, possibly historic')
    how_donor_obtained = models.ForeignKey(Obtained, null=True,
            related_name='donor_obtained')
    ## TODO: when_donor_obtained should be DateField
    ### But contains some imprecise dates
    when_donor_obtained = models.CharField(max_length=50, blank=True,
        help_text="Please use the following format: <em>YYYY-MM-DD</em>.")

    photographer = models.CharField(max_length=100)
    collector = models.ForeignKey(
            'parties.Person',
            null=True,
            blank=True,
            db_index=True,
            related_name="collected_objects")
    collector_2 = models.ForeignKey(
            'parties.Person',
            null=True,
            blank=True,
            verbose_name="2nd recorded collector (historic/wrong)",
            related_name="collected_objects_2")
    how_collector_obtained = models.ForeignKey(Obtained, null=True,
            related_name="collector_obtained")
    when_collector_obtained = models.CharField(max_length=50, blank=True,
            help_text="Please use the following format: <em>YYYY-MM-DD</em>.")

    source = models.CharField(max_length=50)
    how_source_obtained = models.ForeignKey(Obtained, null=True,
            related_name='source_obtained')

    maker = models.ForeignKey('parties.Maker', null=True, blank=True)
    manufacture_technique = models.CharField(max_length=200, blank=True)
    creation_date = models.DateField(null=True, blank=True)
    site_name_number = models.CharField(max_length=150, blank=True)
    raw_material = models.CharField(max_length=150, blank=True)
    indigenous_name = models.CharField(max_length=100, blank=True)
    recorded_use = models.CharField(max_length=300, blank=True)
    assoc_cultural_group = models.CharField(max_length=100, blank=True)
    exhibition_history = models.TextField(blank=True)

    category_illustrated = models.CharField(max_length=100, blank=True)
    artefact_illustrated = models.CharField(max_length=100, blank=True)

    description = models.TextField(blank=True)

    is_public_comment = models.BooleanField(default=False,
            verbose_name='public comment',
            help_text='Is comment allowed to be shown publicly')
    comment = models.TextField(blank=True)
    private_comment = models.TextField(
            blank=True,
            help_text="Only visible to staff")
    significance = models.TextField("statement of significance",
            blank=True)

    width = models.IntegerField(null=True, blank=True,
            help_text="millimeters")
    length = models.IntegerField(null=True, blank=True,
            help_text="millimeters")
    height = models.IntegerField(null=True, blank=True,
            help_text="millimeters")
{'fraction_non_alphanumeric': 0.09906417112299465, 'fraction_numerical': 0.008155080213903744, 'mean_word_length': 3.722537878787879, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '1620879', 'n_tokens_mistral': 4517, 'n_tokens_neox': 4312, 'n_words': 826}