Add back TileLayer and Licence creation migration

Lost during merge with django-leaflet-storage
This commit is contained in:
Yohan Boniface 2018-07-07 14:42:25 +02:00
parent 52fa732f8a
commit 705d0cbb73
3 changed files with 57 additions and 4 deletions

View file

@ -0,0 +1,28 @@
# Generated by Django 1.10.3 on 2016-11-26 16:02
from __future__ import unicode_literals
from django.db import migrations
def add_tilelayer(apps, *args):
TileLayer = apps.get_model('umap', 'TileLayer')
if TileLayer.objects.count():
return
TileLayer(
name='Positron',
url_template=('https://cartodb-basemaps-{s}.global.ssl.fastly.net/'
'light_all/{z}/{x}/{y}.png'),
attribution=('© [[http://www.openstreetmap.org/copyright|'
'OpenStreetMap]] contributors, © '
'[[https://carto.com/attributions|CARTO]]')).save()
class Migration(migrations.Migration):
dependencies = [
('umap', '0002_tilelayer_tms'),
]
operations = [
migrations.RunPython(add_tilelayer),
]

View file

@ -0,0 +1,24 @@
# Generated by Django 1.10.3 on 2016-11-26 16:11
from __future__ import unicode_literals
from django.db import migrations
def add_licence(apps, *args):
Licence = apps.get_model('umap', 'Licence')
if Licence.objects.count():
return
Licence(
name='ODbL',
details='http://opendatacommons.org/licenses/odbl/').save()
class Migration(migrations.Migration):
dependencies = [
('umap', '0003_add_tilelayer'),
]
operations = [
migrations.RunPython(add_licence),
]

View file

@ -4,8 +4,8 @@ import tempfile
import pytest
from django.core.signing import get_cookie_signer
from .base import (DataLayerFactory, LicenceFactory, MapFactory,
TileLayerFactory, UserFactory)
from .base import DataLayerFactory, MapFactory, UserFactory
from umap.models import Licence, TileLayer
TMP_ROOT = tempfile.mkdtemp()
@ -26,7 +26,8 @@ def user():
@pytest.fixture
def licence():
return LicenceFactory()
# Should be created by the migrations.
return Licence.objects.last()
@pytest.fixture
@ -61,4 +62,4 @@ def datalayer(map):
@pytest.fixture
def tilelayer():
return TileLayerFactory()
return TileLayer.objects.last()