Add a migration to create a Licence if none exists
This commit is contained in:
parent
3c32377c42
commit
8b3d8c5ece
2 changed files with 25 additions and 9 deletions
|
@ -95,15 +95,6 @@ remember to rerun this command if you open a new terminal window.*
|
|||
|
||||
umap runserver 0.0.0.0:8000
|
||||
|
||||
## Add at least one license
|
||||
|
||||
Go to [http://localhost:8000/admin/leaflet_storage/licence/add/](http://localhost:8000/admin/leaflet_storage/licence/add/) and create
|
||||
a new Licence object.
|
||||
For example:
|
||||
|
||||
- name: `ODbL`
|
||||
- URL: `http://opendatacommons.org/licenses/odbl/`
|
||||
|
||||
You can now go to [http://localhost:8000/](http://localhost:8000/) and try to create a map for testing.
|
||||
|
||||
When you're done with testing, quit the demo server (type Ctrl-C).
|
||||
|
|
25
umap/migrations/0002_add_licence.py
Normal file
25
umap/migrations/0002_add_licence.py
Normal file
|
@ -0,0 +1,25 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# 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('leaflet_storage', 'Licence')
|
||||
if Licence.objects.count():
|
||||
return
|
||||
Licence(
|
||||
name='ODbL',
|
||||
details='http://opendatacommons.org/licenses/odbl/').save()
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('umap', '0001_add_tilelayer'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(add_licence),
|
||||
]
|
Loading…
Reference in a new issue