summaryrefslogtreecommitdiff
path: root/app/planner/models.py
diff options
context:
space:
mode:
Diffstat (limited to 'app/planner/models.py')
-rw-r--r--app/planner/models.py23
1 files changed, 15 insertions, 8 deletions
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)