<commit_before>from __future__ import unicode_literals
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
import datetime

from imagekit.models import ImageSpecField
from imagekit.processors import ResizeToFit


def create_uid():
    import uuid
    return str(uuid.uuid4())


@python_2_unicode_compatible
class CompanyType(models.Model):

    type_name = models.CharField('Company Type', max_length=200)
    is_valid = models.BooleanField('Is Valid', default=True)
    creation_date = models.DateTimeField('Creation Date', default=datetime.datetime.now)

    def __str__(self):
        return self.type_name

    class Meta:
        ordering = ('type_name',)


@python_2_unicode_compatible
class ContactType(models.Model):
    type_name = models.CharField('Contact Type', max_length=200, unique=True)
    is_valid = models.BooleanField('Is Valid', default=True)
    creation_date = models.DateTimeField('Creation Date', default=datetime.datetime.now)

    def __str__(self):
        return self.type_name

    class Meta:
        ordering = ('type_name',)


@python_2_unicode_compatible
class Company(models.Model):

    company_custom_id = models.IntegerField('Custom External ID', null=True, blank=True, help_text="ID of this Company in external systems (eg. ESolver)")
    company_name = models.CharField('Company Name', max_length=200, null=False, blank=False)
    company_short_name = models.CharField('Company Short Name', max_length=200, null=True, blank=True)
    company_business_name = models.CharField('Company Business Name', max_length=200, null=True, blank=True)
    company_vat_number = models.CharField('VAT Number', null=True, blank=True, unique=True, max_length=30, help_text="international VAT number (eg. partita IVA)")
    company_tax_code = models.CharField('Tax Code', null=True, blank=True, unique=True, max_length=30, help_text="(eg. codice fiscale)")
    company_address = models.CharField('Company Address', max_length=200, null=True, blank=True)
    company_cap = models.CharField('CAP', max_length=10, null=True, blank=True)
    company_city = models.CharField('City', max_length=200, null=True, blank=True)
    company_province = models.CharField('Province', max_length=200, null=True, blank=True)
    company_country = models.CharField('Country', max_length=200, null=True, blank=True)
    company_phone_number = models.CharField('Phone Number', max_length=100, null=True, blank=True)
    company_fax = models.CharField('FAX', max_length=200, null=True, blank=True)
    company_website = models.CharField('WebSite', max_length=200, null=True, blank=True)
    company_notes = models.TextField('Notes', null=True, blank=True)
    company_is_valid = models.BooleanField('Is Valid', default=True, null=False, blank=False)
    
    company_logo = models.ImageField(upload_to='logos/', default='None', help_text="Company logo")
    company_logo_thumbnail = ImageSpecField(source='company_logo',
                                      processors=[ResizeToFit(80, 80)],
                                      format='PNG')

    creation_date = models.DateTimeField('Creation Date', default=datetime.datetime.now)
    # Company Type relation
    company_type = models.ManyToManyField(CompanyType)

    def __str__(self):
        return self.company_name
        
    def image_field(self):
        if self.company_logo:
            return self.company_logo_thumbnail
        else:<commit_msg>logo in admin edit form<commit_after>from __future__ import unicode_literals
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
import datetime

from imagekit.models import ImageSpecField
from imagekit.processors import ResizeToFit


def create_uid():
    import uuid
    return str(uuid.uuid4())


@python_2_unicode_compatible
class CompanyType(models.Model):

    type_name = models.CharField('Company Type', max_length=200)
    is_valid = models.BooleanField('Is Valid', default=True)
    creation_date = models.DateTimeField('Creation Date', default=datetime.datetime.now)

    def __str__(self):
        return self.type_name

    class Meta:
        ordering = ('type_name',)


@python_2_unicode_compatible
class ContactType(models.Model):
    type_name = models.CharField('Contact Type', max_length=200, unique=True)
    is_valid = models.BooleanField('Is Valid', default=True)
    creation_date = models.DateTimeField('Creation Date', default=datetime.datetime.now)

    def __str__(self):
        return self.type_name

    class Meta:
        ordering = ('type_name',)


@python_2_unicode_compatible
class Company(models.Model):

    company_custom_id = models.IntegerField('Custom External ID', null=True, blank=True, help_text="ID of this Company in external systems (eg. ESolver)")
    company_name = models.CharField('Company Name', max_length=200, null=False, blank=False)
    company_short_name = models.CharField('Company Short Name', max_length=200, null=True, blank=True)
    company_business_name = models.CharField('Company Business Name', max_length=200, null=True, blank=True)
    company_vat_number = models.CharField('VAT Number', null=True, blank=True, unique=True, max_length=30, help_text="international VAT number (eg. partita IVA)")
    company_tax_code = models.CharField('Tax Code', null=True, blank=True, unique=True, max_length=30, help_text="(eg. codice fiscale)")
    company_address = models.CharField('Company Address', max_length=200, null=True, blank=True)
    company_cap = models.CharField('CAP', max_length=10, null=True, blank=True)
    company_city = models.CharField('City', max_length=200, null=True, blank=True)
    company_province = models.CharField('Province', max_length=200, null=True, blank=True)
    company_country = models.CharField('Country', max_length=200, null=True, blank=True)
    company_phone_number = models.CharField('Phone Number', max_length=100, null=True, blank=True)
    company_fax = models.CharField('FAX', max_length=200, null=True, blank=True)
    company_website = models.CharField('WebSite', max_length=200, null=True, blank=True)
    company_notes = models.TextField('Notes', null=True, blank=True)
    company_is_valid = models.BooleanField('Is Valid', default=True, null=False, blank=False)
    
    company_logo = models.ImageField(upload_to='logos/', default='None', help_text="Company logo")
    company_logo_thumbnail = ImageSpecField(source='company_logo',
                                      processors=[ResizeToFit(80, 80)],
                                      format='PNG')

    creation_date = models.DateTimeField('Creation Date', default=datetime.datetime.now)
    # Company Type relation
    company_type = models.ManyToManyField(CompanyType)

    def __str__(self):
        return self.company_name
        
    def get_logo_or_default(self):
        if self.company_logo:
            return self.company_logo_thumbnail
        else:
{'fraction_non_alphanumeric': 0.10947429231658001, 'fraction_numerical': 0.014731369150779897, 'mean_word_length': 4.653061224489796, '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': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '187156', 'n_tokens_mistral': 2127, 'n_tokens_neox': 2012, 'n_words': 439}