<commit_before>from django.db import models


class PlaceManager(models.Manager):
    def get_continents(self):
        return self.filter(type=Place.CONTINENT)


class Place(models.Model):
    STATE = 1
    CITY = 2
    WORLD = 3
    CONTINENT = 4
    PLACE_TYPES = (
        (STATE, 'State'),
        (CITY, 'City'),
        (WORLD, 'World'),
        (CONTINENT, 'Continent'),
    )
    DIFFICULTY_CONVERSION = 1000000.0
    code = models.CharField(
        max_length=10,
        db_index=True,
        unique=True)  # TODO: change to SlugField
    name = models.CharField(max_length=100)
    difficulty = models.IntegerField(default=0)
    # TODO: change to PositiveSmallIntegerField
    type = models.IntegerField(choices=PLACE_TYPES)
    objects = PlaceManager()

    def __unicode__(self):
        return u'{0} ({1})'.format(self.name, self.code)

        self.save()

    def to_serializable(self):
        return {
            'code': self.code,
            'name': self.name
        }<commit_msg>get_states_with_map method added; RIVER and LAKE Place types added; Place.code max_lenght extended<commit_after>from django.db import models


class PlaceManager(models.Manager):
    def get_continents(self):
        return self.filter(type=Place.CONTINENT)

    def get_states_with_map(self):
        return [pr.place for pr in PlaceRelation.objects.filter(
            place__type=Place.STATE,
            type=PlaceRelation.IS_ON_MAP,
        ).select_related('place').order_by("place__name")]


class Place(models.Model):
    STATE = 1
    CITY = 2
    WORLD = 3
    CONTINENT = 4
    RIVER = 5
    LAKE = 6
    PLACE_TYPES = (
        (STATE, 'State'),
        (CITY, 'City'),
        (WORLD, 'World'),
        (CONTINENT, 'Continent'),
        (RIVER, 'River'),
        (LAKE, 'Lake'),
    )
    DIFFICULTY_CONVERSION = 1000000.0
    code = models.CharField(
        max_length=100,
        db_index=True,
        unique=True)  # TODO: change to SlugField
    name = models.CharField(max_length=100)
    difficulty = models.IntegerField(default=0)
    # TODO: change to PositiveSmallIntegerField
    type = models.IntegerField(choices=PLACE_TYPES)
    objects = PlaceManager()

    def __unicode__(self):
        return u'{0} ({1})'.format(self.name, self.code)

        self.save()

    def to_serializable(self):
        return {
            'code': self.code,
            'name': self.name
        }
{'fraction_non_alphanumeric': 0.1155758077879039, 'fraction_numerical': 0.017812758906379452, 'mean_word_length': 2.5, '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': '1052579', 'n_tokens_mistral': 824, 'n_tokens_neox': 774, 'n_words': 162}