dumuzid/datastore/models/places.py
2022-08-09 06:27:55 +00:00

38 lines
1.2 KiB
Python

from django.db import models
from base64 import b64encode
from ..helpers.uploads import get_upload_path
"""
These models are used by Adonis to return tens of thousands of
lines of unneeded data.
"""
class Airport(models.Model):
city_code = models.CharField(max_length=256, null=True, blank=True)
code = models.CharField(max_length=256, null=True, blank=True, unique=True)
country_name = models.CharField(max_length=256, null=True, blank=True)
name = models.CharField(max_length=256, null=True, blank=True)
class ZipPlaces(models.Model):
postcode = models.CharField(max_length=64)
postplace = models.CharField(max_length=256)
country = models.ForeignKey(Nationality, models.PROTECT)
class Nationality(models.Model):
country = models.ForeignKey(Country, models.PROTECT)
class Country(models.Model):
code = models.CharField(max_length=16)
text = models.CharField(max_length=128)
class PhoneCode(models.Model):
code = models.CharField(max_length=16)
flag = models.ImageField(null=True, upload_to=get_upload_path)
text = models.CharField(max_length=128)
@property
def flag_base64(self):
return b64encode(self.flag.read())