From 705d0cbb731031fe45063494e7238c347a6d8253 Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Sat, 7 Jul 2018 14:42:25 +0200 Subject: [PATCH] Add back TileLayer and Licence creation migration Lost during merge with django-leaflet-storage --- umap/migrations/0003_add_tilelayer.py | 28 +++++++++++++++++++++++++++ umap/migrations/0004_add_licence.py | 24 +++++++++++++++++++++++ umap/tests/conftest.py | 9 +++++---- 3 files changed, 57 insertions(+), 4 deletions(-) create mode 100644 umap/migrations/0003_add_tilelayer.py create mode 100644 umap/migrations/0004_add_licence.py diff --git a/umap/migrations/0003_add_tilelayer.py b/umap/migrations/0003_add_tilelayer.py new file mode 100644 index 00000000..c1e35be9 --- /dev/null +++ b/umap/migrations/0003_add_tilelayer.py @@ -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), + ] diff --git a/umap/migrations/0004_add_licence.py b/umap/migrations/0004_add_licence.py new file mode 100644 index 00000000..c5e7bff7 --- /dev/null +++ b/umap/migrations/0004_add_licence.py @@ -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), + ] diff --git a/umap/tests/conftest.py b/umap/tests/conftest.py index 1ac6664f..fe8cbe68 100644 --- a/umap/tests/conftest.py +++ b/umap/tests/conftest.py @@ -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()