<commit_before>from django.db.models import Q
from django.db import models
from django_countries.fields import CountryField

from taggit.managers import TaggableManager
from multiselectfield import MultiSelectField

from people.models import User, Organization


class Place(models.Model):
    """
    Some place belonging to an organization
    """
    name = models.CharField(max_length=255)
    description = models.TextField(null=True)

    address = models.CharField(max_length=255, null=True)
    zipcode = models.CharField(
        max_length=10, blank=True, help_text="Code postal / Zipcode")
    city = models.CharField(max_length=50, blank=True)
    country = CountryField(default="")

    latitude = models.DecimalField(
        max_digits=9, decimal_places=6, null=True, blank=True)
    longitude = models.DecimalField(
        max_digits=9, decimal_places=6, null=True, blank=True)

    organization = models.ForeignKey(
        Organization, blank=True, null=True, related_name='places', on_delete=models.CASCADE)

    def __str__(self):
        extra_info = self.organization if self.organization else self.country
        address = self.address[0:20] + "..." if self.address else self.city
        return '{0} - {1} ({2})'.format(self.name, address, extra_info)


def main_event_true():
    from production.models import Event
    return {'pk__in': Event.objects.filter(Q(main_event=True))
                                   .values_list('id', flat=True)}


def main_event_false():
    from production.models import Event
    return {'pk__in': Event.objects.filter(Q(main_event=False))
                                   .values_list('id', flat=True)}


class MetaAward(models.Model):
    """
    Award from main event
    """
    TYPE_CHOICES = (<commit_msg>Update Place model : improve representation + TODO<commit_after>from django.db.models import Q
from django.db import models
from django_countries.fields import CountryField

from taggit.managers import TaggableManager
from multiselectfield import MultiSelectField

from people.models import User, Organization

# TODO: Add field is_city - is_country 

class Place(models.Model):
    """
    Some place belonging to an organization
    """
    name = models.CharField(max_length=255)
    description = models.TextField(null=True)

    address = models.CharField(max_length=255, null=True)
    zipcode = models.CharField(
        max_length=10, blank=True, help_text="Code postal / Zipcode")
    city = models.CharField(max_length=50, blank=True)
    country = CountryField(default="")

    latitude = models.DecimalField(
        max_digits=9, decimal_places=6, null=True, blank=True)
    longitude = models.DecimalField(
        max_digits=9, decimal_places=6, null=True, blank=True)

    organization = models.ForeignKey(
        Organization, blank=True, null=True, related_name='places', on_delete=models.CASCADE)

    def __str__(self):
        extra_info = self.organization if self.organization else self.country
        address = self.address[0:20] + "..." if self.address else self.city
        if self.name == address :
            return f'{self.name} ({extra_info})' 
        else :
            return f'{self.name} - {address} ({extra_info})'

def main_event_true():
    from production.models import Event
    return {'pk__in': Event.objects.filter(Q(main_event=True))
                                   .values_list('id', flat=True)}


def main_event_false():
    from production.models import Event
    return {'pk__in': Event.objects.filter(Q(main_event=False))
                                   .values_list('id', flat=True)}


class MetaAward(models.Model):
    """
    Award from main event
    """
    TYPE_CHOICES = (
{'fraction_non_alphanumeric': 0.10823909531502424, 'fraction_numerical': 0.00996230479267636, 'mean_word_length': 3.3097447795823665, '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': '2534003', 'n_tokens_mistral': 1119, 'n_tokens_neox': 1069, 'n_words': 255}