Allow only one location per friend

This commit is contained in:
Gabriel Augendre 2019-03-02 15:56:46 +01:00
parent 22ac627f17
commit e50bf025f9
3 changed files with 41 additions and 1 deletions

View file

@ -0,0 +1,20 @@
# Generated by Django 2.1.7 on 2019-03-02 14:55
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('map', '0003_friendlocation_friend'),
]
operations = [
migrations.AlterField(
model_name='friendlocation',
name='friend',
field=models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL),
),
]

View file

@ -0,0 +1,20 @@
# Generated by Django 2.1.7 on 2019-03-02 14:57
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('map', '0004_auto_20190302_1455'),
]
operations = [
migrations.AlterField(
model_name='friendlocation',
name='friend',
field=models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='location', to=settings.AUTH_USER_MODEL),
),
]

View file

@ -26,7 +26,7 @@ class FriendLocation(BaseModel):
longitude = CoordinateField() longitude = CoordinateField()
start_date = models.DateField('from', blank=True, null=True) start_date = models.DateField('from', blank=True, null=True)
end_date = models.DateField('until', blank=True, null=True) end_date = models.DateField('until', blank=True, null=True)
friend = models.ForeignKey(Friend, on_delete=models.CASCADE) friend = models.OneToOneField(Friend, on_delete=models.CASCADE, related_name='location')
@property @property
def latitude_str(self): def latitude_str(self):