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.
 
 
 
 
 
 

55 lines
2.2 KiB

# -*- coding: utf-8 -*-
from django.db import models
from hvad.models import TranslatableModel, TranslatedFields
from django.contrib.contenttypes import generic
#models
from directories.models import Language, Currency
from city.models import City
#func
from functions.custom_fields import EnumField
class Country(TranslatableModel):
"""
Create Country model
Uses hvad.TranslatableModel which is child of django.db.models class
"""
REGIONS =('europa', 'asia', 'america', 'africa')
url = models.SlugField(unique=True)
capital = models.ForeignKey(City, null=True, related_name='capital')
population = models.PositiveIntegerField(blank=True, null=True)
teritory = models.PositiveIntegerField(blank=True, null=True)
timezone = models.FloatField(blank=True, null=True)
phone_code = models.PositiveIntegerField(blank=True, null=True)
big_cities = models.ManyToManyField(City, null=True, related_name='cities')
language = models.ManyToManyField(Language, null=True)
currency = models.ManyToManyField(Currency, null=True)
time_delivery = models.PositiveSmallIntegerField(blank=True, null=True)
#
region = EnumField(values=REGIONS)
#fields saves information about creating and changing model
created = models.DateTimeField(auto_now_add=True)
modified = models.DateTimeField(auto_now=True)
#connection with FileModel by ContentType
files = generic.GenericRelation('file.FileModel',content_type_field='content_type', object_id_field='object_id')
#translated fields
translations = TranslatedFields(
name = models.CharField(max_length=30),
description = models.TextField(blank=True),
transport = models.TextField(blank=True),
#------visa inf
rules = models.TextField(blank=True),
documents = models.TextField(blank=True),#pdf?
consulate = models.TextField(blank=True),
#-----meta data
title = models.CharField(max_length=250),
descriptions = models.CharField(max_length=250),
keywords = models.CharField(max_length=250),
)
def __unicode__(self):
return self.lazy_translation_getter('name', unicode(self.pk))