summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/planner/admin.py6
-rw-r--r--app/planner/models.py36
-rw-r--r--app/planner/templates/planner/list.html9
3 files changed, 27 insertions, 24 deletions
diff --git a/app/planner/admin.py b/app/planner/admin.py
index 3b24ec2..5d533c8 100644
--- a/app/planner/admin.py
+++ b/app/planner/admin.py
@@ -4,7 +4,7 @@ from django.contrib.gis.admin import OSMGeoAdmin
from django.contrib.contenttypes.admin import GenericStackedInline
from utils.widgets import AdminImageWidget, LGEntryForm
-from .models import Camp
+from .models import Camp, Trip
from media.models import LuxImage
from utils.util import get_latlon
@@ -34,4 +34,6 @@ class PlannerAdmin(OSMGeoAdmin):
}
-
+@admin.register(Trip)
+class TripAdmin(OSMGeoAdmin):
+ pass
diff --git a/app/planner/models.py b/app/planner/models.py
index 3c527be..df162c7 100644
--- a/app/planner/models.py
+++ b/app/planner/models.py
@@ -19,11 +19,10 @@ 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')
+ slug = models.SlugField(unique_for_date='date')
def __str__(self):
return self.name
@@ -32,7 +31,7 @@ class Trip(models.Model):
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)
+ slug = models.SlugField(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)
@@ -63,36 +62,31 @@ class Camp(models.Model):
def __str__(self):
return self.name
- def get_absolute_url(self):
- if self.post_type == PostType.ESSAY:
- return reverse('essays:detail', kwargs={"slug": self.slug})
- if self.post_type == PostType.SRC:
- return reverse('src:detail', kwargs={"slug": self.slug})
- if self.post_type == PostType.FIELD_NOTE:
- return reverse('fieldnote:detail', kwargs={"year": self.pub_date.year, "month": self.pub_date.strftime("%m"), "slug": self.slug})
- if self.post_type == PostType.JRNL:
- return reverse('jrnl:detail', kwargs={"year": self.pub_date.year, "month": self.pub_date.strftime("%m"), "slug": self.slug})
- if self.post_type == PostType.RANGE:
- return reverse('range:range-detail', kwargs={"issue": self.get_issue_str(), "slug": self.slug})
- if self.post_type == PostType.FRIENDS:
- return reverse('friends:friends-detail', kwargs={"issue": self.get_issue_str(), "slug": self.slug})
-
- def comment_period_open(self):
- return self.enable_comments and datetime.datetime.today() - datetime.timedelta(30) <= self.pub_date
-
def get_featured_image_thumb(self):
return self.featured_image.get_image_url_by_size("thumbnail")
def get_content_type(self):
return ContentType.objects.get(app_label="posts", model="post")
+
+ @property
+ def longitude(self):
+ '''Get the site's longitude.'''
+ if self.point:
+ return self.point.x
+
+ @property
+ def latitude(self):
+ '''Get the site's latitude.'''
+ if self.point:
+ return self.point.y
@property
def get_previous_published(self):
return self.get_previous_by_date_arrive()
@property
def get_previous_admin_url(self):
- n = self.get_previous_by_pub_date()
+ n = self.get_previous_by_date_arrive()
return reverse('admin:%s_%s_change' %(self._meta.app_label, self._meta.model_name), args=[n.id] )
@property
diff --git a/app/planner/templates/planner/list.html b/app/planner/templates/planner/list.html
index b426c57..ce7650e 100644
--- a/app/planner/templates/planner/list.html
+++ b/app/planner/templates/planner/list.html
@@ -32,7 +32,14 @@
attribution: 'Map data &copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors, ' +
'Imagery © <a href="https://www.mapbox.com/">Mapbox</a>',
}).addTo(mymap);
-
+ {% for object in object_list %}
+ {% if forloop.counter == 1 %}
+ centerCoord = new L.LatLng({{object.latitude}}, {{object.longitude}});
+ //Set center
+ mymap.setView(centerCoord, 7);
+ {% endif %}
+ L.marker([{{object.latitude}}, {{object.longitude}}]).bindPopup('<div class="infowin"><h4>{{object.name}}<\/h4><p class="date">Arrive: Afternoon, {{object.date_arrive|date:"M j, Y"}}<\/p><p class="date">Depart: Afternoon, {{object.date_depart|date:"M j, Y"}}<\/p><\/div>').addTo(mymap);
+ {%endfor%}
</script>
{% endblock %}