summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/planner/migrations/0003_trip.py22
-rw-r--r--app/planner/migrations/0004_auto_20210815_1856.py24
-rw-r--r--app/planner/models.py23
-rw-r--r--app/planner/templates/planner/list.html20
4 files changed, 79 insertions, 10 deletions
diff --git a/app/planner/migrations/0003_trip.py b/app/planner/migrations/0003_trip.py
new file mode 100644
index 0000000..41d410c
--- /dev/null
+++ b/app/planner/migrations/0003_trip.py
@@ -0,0 +1,22 @@
+# Generated by Django 3.2.5 on 2021-08-15 18:55
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('planner', '0002_auto_20210725_1548'),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name='Trip',
+ fields=[
+ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+ ('name', models.CharField(max_length=200)),
+ ('date', models.DateField()),
+ ('slug', models.SlugField(unique_for_date='pub_date')),
+ ],
+ ),
+ ]
diff --git a/app/planner/migrations/0004_auto_20210815_1856.py b/app/planner/migrations/0004_auto_20210815_1856.py
new file mode 100644
index 0000000..c896a60
--- /dev/null
+++ b/app/planner/migrations/0004_auto_20210815_1856.py
@@ -0,0 +1,24 @@
+# Generated by Django 3.2.5 on 2021-08-15 18:56
+
+from django.db import migrations, models
+import django.db.models.deletion
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('planner', '0003_trip'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='camp',
+ name='slug',
+ field=models.SlugField(blank=True, null=True, unique_for_date='pub_date'),
+ ),
+ migrations.AddField(
+ model_name='camp',
+ name='trip',
+ field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='planner.trip'),
+ ),
+ ]
diff --git a/app/planner/models.py b/app/planner/models.py
index f5bb042..3c527be 100644
--- a/app/planner/models.py
+++ b/app/planner/models.py
@@ -13,13 +13,26 @@ from django.apps import apps
from django.conf import settings
from django.contrib.sitemaps import Sitemap
from django import forms
+from django.template.defaultfilters import slugify
from locations.models import Location
from utils.util import render_images, render_products, parse_video, markdown_to_html, extract_main_image
+
+class Trip(models.Model):
+ name = models.CharField(max_length=200)
+ date = models.DateField()
+ slug = models.SlugField(unique_for_date='pub_date')
+
+ def __str__(self):
+ return self.name
+
+
class Camp(models.Model):
+ trip = models.ForeignKey(Trip, on_delete=models.SET_NULL, null=True, blank=True)
name = models.CharField(max_length=200)
+ slug = models.SlugField(unique_for_date='pub_date', blank=True, null=True)
date_arrive = models.DateField('Arrival Date')
date_depart = models.DateField('Departure Date', blank=True, null=True)
distance_from_previous = models.FloatField(null=True, blank=True)
@@ -73,14 +86,6 @@ class Camp(models.Model):
def get_content_type(self):
return ContentType.objects.get(app_label="posts", model="post")
- def get_issue_str(self):
- issue = self.issue
- if self.issue < 100:
- issue = "0%s" % self.issue
- if self.issue < 10:
- issue = "00%s" % self.issue
- return issue
-
@property
def get_previous_published(self):
return self.get_previous_by_date_arrive()
@@ -104,5 +109,7 @@ class Camp(models.Model):
def save(self, *args, **kwargs):
created = self.pk is None
+ if not self.slug:
+ self.slug = slugify(self.name)
self.notes_html = markdown_to_html(self.notes)
super(Camp, self).save(*args, **kwargs)
diff --git a/app/planner/templates/planner/list.html b/app/planner/templates/planner/list.html
index 8575d4a..12b72a3 100644
--- a/app/planner/templates/planner/list.html
+++ b/app/planner/templates/planner/list.html
@@ -16,7 +16,23 @@
{% if object.has_electric %}<li class="water">electric</li>{% endif %}
</article>{% endfor %}
</div>
-<div class="map">
- <iframe src="https://www.google.com/maps" width="100%" height="90%" frameborder="0" style="border:0" allowfullscreen></iframe>
+<div id="map">
</div>
{% endblock %}
+
+ {% block js %}
+ <link rel="stylesheet" src="/media/js/leaflet-1.7.1/leaflet.css" integrity="sha512-xodZBNTC5n17Xt2atTPuE1HxjVMSvLVW9ocqUKLsCC5CXdbqCmblAshOMAS6/keqq/sMZMZ19scR4PsZChSR7A==" />
+<script src="/media/js/leaflet-1.7.1/leaflet.js" integrity="sha512-XQoYMqMTK8LvdxXYG3nZ448hOEQiglfqkJs1NOQV44cWnUrBc8PkAOcXy20w0vlaXaVUearIOBhiXZ5V3ynxwA=="></script>
+ <script>
+// initialize the map on the "map" div with a given center and zoom
+var map = new L.Map('map', {
+ center: new L.LatLng(51.46, -0.205),
+ zoom: 15
+});
+// create a new tile layer
+var tileUrl = 'https://tile.thunderforest.com/cycle/{z}/{x}/{y}.png?apikey=c9a9f0c5edfd4ce2948f49b51f533ad2',
+layer = new L.TileLayer(tileUrl, {maxZoom: 18});
+// add the layer to the map
+map.addLayer(layer);
+</script>
+{% endblock %}