You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
56 lines
1.7 KiB
56 lines
1.7 KiB
# -*- coding: utf-8 -*-
|
|
from django.db import models
|
|
from hvad.models import TranslatableModel, TranslatedFields
|
|
from bitfield import BitField
|
|
# my models
|
|
from directories.models import Iata
|
|
from service.models import Service
|
|
|
|
|
|
class City(TranslatableModel):
|
|
"""
|
|
Create City model
|
|
|
|
Uses hvad.TranslatableModel which is child of django.db.models class
|
|
|
|
"""
|
|
|
|
try:
|
|
flags = [str(item.id) for item in Service.objects.all()]
|
|
except:
|
|
flags = []
|
|
|
|
"""
|
|
ids = [item.id for item in Service.objects.all() ]
|
|
if len(ids):
|
|
max = sorted(ids)[-1]
|
|
for i in range(max):
|
|
flags.append(str(i))
|
|
"""
|
|
|
|
|
|
services = BitField(flags=flags)
|
|
|
|
url = models.SlugField(unique=True)
|
|
country = models.ForeignKey('country.Country', null=True, on_delete=models.PROTECT)
|
|
population = models.PositiveIntegerField(blank=True, null=True)
|
|
phone_code = models.PositiveIntegerField(blank=True, null=True)
|
|
code_IATA = models.ForeignKey(Iata, null=True)
|
|
#translated fields
|
|
translations = TranslatedFields(
|
|
name = models.CharField(max_length=50),
|
|
transport = models.TextField(blank=True),
|
|
description = models.TextField(blank=True),
|
|
famous_places = models.TextField(blank=True),
|
|
shoping = models.TextField(blank=True),
|
|
#-----meta
|
|
title = models.CharField(max_length=255),
|
|
descriptions = models.CharField(max_length=255),
|
|
keywords = models.CharField(max_length=255),
|
|
)
|
|
#fields saves information about creating and changing model
|
|
created = models.DateTimeField(auto_now_add=True)
|
|
modified = models.DateTimeField(auto_now=True)
|
|
|
|
def __unicode__(self):
|
|
return self.lazy_translation_getter('name', self.pk) |