feat: add views for Organisation model

Location picker on update view
This commit is contained in:
James Graham
2021-01-15 14:58:05 +00:00
parent 2d85ab4370
commit 9db870bcb0
10 changed files with 259 additions and 3 deletions

View File

@@ -0,0 +1,29 @@
{% extends 'base.html' %}
{% block content %}
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item">
<a href="{% url 'people:organisation.list' %}">Organisations</a>
</li>
<li class="breadcrumb-item active" aria-current="page">Create</li>
</ol>
</nav>
<h1>New Organisation</h1>
<hr>
<form class="form"
method="POST">
{% csrf_token %}
{% load bootstrap4 %}
{% bootstrap_form form %}
{% buttons %}
<button class="btn btn-success" type="submit">Submit</button>
{% endbuttons %}
</form>
{% endblock %}

View File

@@ -0,0 +1,36 @@
{% extends 'base.html' %}
{% block extra_head %}
{{ map_markers|json_script:'map-markers' }}
{% load staticfiles %}
<script src="{% static 'js/map.js' %}"></script>
<script async defer src="https://maps.googleapis.com/maps/api/js?key={{ settings.GOOGLE_MAPS_API_KEY }}&callback=initMap"
type="text/javascript"></script>
{% endblock %}
{% block content %}
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item">
<a href="{% url 'people:organisation.list' %}">Organisations</a>
</li>
<li class="breadcrumb-item active" aria-current="page">{{ object }}</li>
</ol>
</nav>
<h1>{{ organisation.name }}</h1>
<hr>
<a class="btn btn-success"
href="{% url 'people:organisation.update' pk=organisation.pk %}">Update</a>
<hr>
<div id="map" style="height: 800px; width: 100%"></div>
<hr>
{% endblock %}

View File

@@ -0,0 +1,42 @@
{% extends 'base.html' %}
{% block content %}
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item active" aria-current="page">Organisation</li>
</ol>
</nav>
<h1>People</h1>
<hr>
<a class="btn btn-success"
href="{% url 'people:organisation.create' %}">New Organisation</a>
<table class="table table-borderless">
<thead>
<tr>
<th>Name</th>
</tr>
</thead>
<tbody>
{% for organisation in organisation_list.all %}
<tr>
<td>{{ organisation }}</td>
<td>
<a class="btn btn-sm btn-info"
href="{% url 'people:organisation.detail' pk=organisation.pk %}">Details</a>
</td>
</tr>
{% empty %}
<tr>
<td>No records</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endblock %}

View File

@@ -0,0 +1,68 @@
{% extends 'base.html' %}
{% block extra_head %}
{% load staticfiles %}
<script type="application/javascript">
const data = [
{
name: '{{ organisation.name }}',
lat: '{{ organisation.latitude }}',
lng: '{{ organisation.longitude }}'
},
]
const settings = {
zoom: 2,
centre_lat: '{{ organisation.latitude }}',
centre_lng: '{{ organisation.longitude }}',
}
</script>
<!-- {{ map_markers|json_script:'map-markers' }} -->
<script src="{% static 'js/location_picker.js' %}"></script>
<script async defer src="https://maps.googleapis.com/maps/api/js?key={{ settings.GOOGLE_MAPS_API_KEY }}&callback=initMap&libraries=places"
type="text/javascript"></script>
{% endblock %}
{% block content %}
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item">
<a href="{% url 'people:organisation.list' %}">Organisations</a>
</li>
<li class="breadcrumb-item">
<a href="{% url 'people:organisation.detail' pk=organisation.pk %}">{{ organisation }}</a>
</li>
<li class="breadcrumb-item active" aria-current="page">Update</li>
</ol>
</nav>
<h1>{{ organisation.name }}</h1>
<hr>
<form class="form"
method="POST">
{% csrf_token %}
{% load bootstrap4 %}
{% bootstrap_form form exclude='latitude,longitude' %}
{% bootstrap_field form.latitude %}
{% bootstrap_field form.longitude %}
{% buttons %}
<button class="btn btn-success" type="submit">Submit</button>
{% endbuttons %}
</form>
<hr>
<input id="location-search" class="controls" type="text" placeholder="Location Search"/>
<div id="map" style="height: 800px; width: 100%"></div>
<hr>
{% endblock %}