Add phone number field to profiles and establishments

This commit is contained in:
Kumi 2021-04-14 07:38:52 +02:00
parent 0a16b8ed7d
commit c5604bd255
3 changed files with 11 additions and 3 deletions

View file

@ -5,6 +5,7 @@ from django.contrib.auth import get_user_model
from django.utils import timezone
from django_countries.fields import CountryField
from phonenumber_field.modelfields import PhoneNumberField
from .helpers import profile_to_coords, upload_path
@ -95,7 +96,13 @@ class ImageMixin(models.Model):
class Meta:
abstract = True
class Profile(AddressMixin):
class PhoneMixin(models.Model):
phone = PhoneNumberField()
class Meta:
abstract = True
class Profile(AddressMixin, PhoneMixin):
user = models.OneToOneField(User, models.CASCADE)
company = models.CharField(max_length=64, null=True, blank=True)
vat_id = models.CharField(max_length=32, null=True, blank=True)

View file

@ -1,13 +1,13 @@
from django.contrib.gis.db import models
from localauth.models import User, Profile, LocationMixin, ImageMixin
from localauth.models import User, Profile, LocationMixin, ImageMixin, PhoneMixin
from django_countries.fields import CountryField
class PartnerProfile(Profile):
pass
class Establishment(LocationMixin, ImageMixin):
class Establishment(LocationMixin, ImageMixin, PhoneMixin):
owner = models.ForeignKey(PartnerProfile, models.CASCADE)
name = models.CharField(max_length=64)
stars = models.IntegerField(null=True, blank=True)

View file

@ -14,6 +14,7 @@ INSTALLED_APPS = [
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'phonenumber_field',
'localauth',
'public',
'partners',