Update map app (location, migrations and templates)
This commit is contained in:
parent
c235779631
commit
f1d8f00af0
4
apps/map/admin.py
Normal file
4
apps/map/admin.py
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
from django.contrib import admin
|
||||||
|
from apps.map.models import CaseStudy
|
||||||
|
|
||||||
|
admin.site.register(CaseStudy)
|
47
apps/map/migrations/0001_initial.py
Normal file
47
apps/map/migrations/0001_initial.py
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Generated by Django 1.11.1 on 2017-05-19 21:42
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.conf import settings
|
||||||
|
import django.contrib.gis.db.models.fields
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
import django_countries.fields
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
initial = True
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='CaseStudy',
|
||||||
|
fields=[
|
||||||
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('location', django.contrib.gis.db.models.fields.PointField(srid=4326)),
|
||||||
|
('project_name', models.CharField(max_length=128)),
|
||||||
|
('supply_chain', models.CharField(choices=[('A', 'Option A'), ('B', 'Option B')], max_length=1)),
|
||||||
|
('generation_type', models.CharField(choices=[('W', 'Wind'), ('S', 'Solar')], max_length=1)),
|
||||||
|
('associated_companies', models.CharField(max_length=128)),
|
||||||
|
('financiers', models.CharField(max_length=128)),
|
||||||
|
('important_lenders', models.CharField(max_length=128)),
|
||||||
|
('country', django_countries.fields.CountryField(max_length=2)),
|
||||||
|
('affects_indigenous', models.BooleanField()),
|
||||||
|
('affects_indigenous_reason', models.TextField()),
|
||||||
|
('proposed_start', models.DateField()),
|
||||||
|
('proposed_completion', models.DateField()),
|
||||||
|
('description', models.TextField()),
|
||||||
|
('link_to_forum', models.URLField()),
|
||||||
|
('image', models.ImageField(upload_to='')),
|
||||||
|
('references', models.TextField()),
|
||||||
|
('commodities', models.CharField(max_length=128)),
|
||||||
|
('like_to_engage_developer', models.BooleanField()),
|
||||||
|
('like_to_engage_investors', models.BooleanField()),
|
||||||
|
('author', models.ForeignKey(blank=True, editable=False, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
]
|
20
apps/map/migrations/0002_auto_20170520_0139.py
Normal file
20
apps/map/migrations/0002_auto_20170520_0139.py
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Generated by Django 1.11.1 on 2017-05-20 01:39
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import migrations
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('map', '0001_initial'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RenameField(
|
||||||
|
model_name='casestudy',
|
||||||
|
old_name='location',
|
||||||
|
new_name='geom',
|
||||||
|
),
|
||||||
|
]
|
57
apps/map/models.py
Normal file
57
apps/map/models.py
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
from django.contrib.gis.db import models
|
||||||
|
from django.contrib.auth.models import User
|
||||||
|
from django_countries.fields import CountryField
|
||||||
|
|
||||||
|
|
||||||
|
class CaseStudy(models.Model):
|
||||||
|
"""Model for case studies submitted to the Ojuso Platform"""
|
||||||
|
|
||||||
|
# Choice lists for dropdowns
|
||||||
|
SUPPLY_CHAIN_CHOICES = (
|
||||||
|
('A', 'Option A'),
|
||||||
|
('B', 'Option B'),
|
||||||
|
)
|
||||||
|
GENERATION_TYPE_CHOICES = (
|
||||||
|
('W', 'Wind'),
|
||||||
|
('S', 'Solar'),
|
||||||
|
)
|
||||||
|
|
||||||
|
# User who submitted case study
|
||||||
|
author = models.ForeignKey(
|
||||||
|
User,
|
||||||
|
models.SET_NULL,
|
||||||
|
blank=True,
|
||||||
|
null=True,
|
||||||
|
editable=False
|
||||||
|
)
|
||||||
|
|
||||||
|
# Location of map pin
|
||||||
|
geom = models.PointField()
|
||||||
|
|
||||||
|
project_name = models.CharField(max_length=128)
|
||||||
|
supply_chain = models.CharField(
|
||||||
|
max_length=1,
|
||||||
|
choices=SUPPLY_CHAIN_CHOICES
|
||||||
|
)
|
||||||
|
generation_type = models.CharField(
|
||||||
|
max_length=1,
|
||||||
|
choices=GENERATION_TYPE_CHOICES
|
||||||
|
)
|
||||||
|
associated_companies = models.CharField(max_length=128)
|
||||||
|
financiers = models.CharField(max_length=128)
|
||||||
|
important_lenders = models.CharField(max_length=128)
|
||||||
|
country = CountryField()
|
||||||
|
affects_indigenous = models.BooleanField()
|
||||||
|
affects_indigenous_reason = models.TextField()
|
||||||
|
proposed_start = models.DateField()
|
||||||
|
proposed_completion = models.DateField()
|
||||||
|
description = models.TextField()
|
||||||
|
link_to_forum = models.URLField()
|
||||||
|
image = models.ImageField()
|
||||||
|
references = models.TextField()
|
||||||
|
commodities = models.CharField(max_length=128)
|
||||||
|
like_to_engage_developer = models.BooleanField()
|
||||||
|
like_to_engage_investors = models.BooleanField()
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return "%s in %s" % (self.project_name, self.country.name)
|
11
apps/map/requirements.txt
Normal file
11
apps/map/requirements.txt
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
appdirs==1.4.3
|
||||||
|
Django==1.11.1
|
||||||
|
django-countries==4.5
|
||||||
|
django-crispy-forms==1.6.1
|
||||||
|
django-leaflet==0.22.0
|
||||||
|
gunicorn==19.7.1
|
||||||
|
packaging==16.8
|
||||||
|
psycopg2==2.7.1
|
||||||
|
pyparsing==2.2.0
|
||||||
|
pytz==2017.2
|
||||||
|
six==1.10.0
|
29
apps/map/templates/map/index.html
Normal file
29
apps/map/templates/map/index.html
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
{% load i18n %}
|
||||||
|
{% load leaflet_tags %}
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>{% trans "Ojuso Platform Map" %}</title>
|
||||||
|
{% leaflet_js %}
|
||||||
|
{% leaflet_css %}
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Ojuso Platform Map</h1>
|
||||||
|
{% leaflet_map "main" callback="main_app_init" %}
|
||||||
|
<script src="https://code.jquery.com/jquery-3.2.1.min.js"
|
||||||
|
integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4="
|
||||||
|
crossorigin="anonymous">
|
||||||
|
</script>
|
||||||
|
<script type="text/javascript">
|
||||||
|
function main_app_init(map, options) {
|
||||||
|
var dataurl = '{% url "data" %}';
|
||||||
|
// Download GeoJSON
|
||||||
|
$.getJSON(dataurl, function (data) {
|
||||||
|
L.geoJson(data).addTo(map);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
10
apps/map/urls.py
Normal file
10
apps/map/urls.py
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
from django.conf.urls import url
|
||||||
|
from djgeojson.views import GeoJSONLayerView
|
||||||
|
|
||||||
|
from .models import CaseStudy
|
||||||
|
from . import views
|
||||||
|
|
||||||
|
urlpatterns = [
|
||||||
|
url(r'^$', views.index, name='index'),
|
||||||
|
url(r'^data.geojson$', GeoJSONLayerView.as_view(model=CaseStudy), name='data')
|
||||||
|
]
|
5
apps/map/views.py
Normal file
5
apps/map/views.py
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
from django.shortcuts import render
|
||||||
|
|
||||||
|
|
||||||
|
def index(request):
|
||||||
|
return render(request, 'map/index.html')
|
@ -1,3 +0,0 @@
|
|||||||
from django.contrib import admin
|
|
||||||
|
|
||||||
# Register your models here.
|
|
@ -1,3 +0,0 @@
|
|||||||
from django.db import models
|
|
||||||
|
|
||||||
# Create your models here.
|
|
@ -1,3 +0,0 @@
|
|||||||
from django.shortcuts import render
|
|
||||||
|
|
||||||
# Create your views here.
|
|
Loading…
Reference in New Issue
Block a user