summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/fieldnotes/templates/fieldnotes/fieldnote_archive_list_date.html (renamed from design/templates/fieldnotes/fieldnote_archive_list_date.html)0
-rw-r--r--app/fieldnotes/templates/fieldnotes/fieldnote_detail.html (renamed from design/templates/fieldnotes/fieldnote_detail.html)0
-rw-r--r--app/fieldnotes/templates/fieldnotes/fieldnote_list.html (renamed from design/templates/fieldnotes/fieldnote_list.html)0
-rw-r--r--app/guides/admin.py37
-rw-r--r--app/guides/guide_urls.py18
-rw-r--r--app/guides/migrations/0002_remove_guide_category.py17
-rw-r--r--app/guides/migrations/0003_guide_category.py21
-rw-r--r--app/guides/migrations/0004_auto_20190914_0646.py47
-rw-r--r--app/guides/migrations/0005_remove_guide_category.py17
-rw-r--r--app/guides/models.py80
-rw-r--r--app/guides/review_urls.py18
-rw-r--r--app/guides/templates/guides/guide_detail.html (renamed from design/templates/guides/guide_detail.html)0
-rw-r--r--app/guides/templates/guides/guide_detail.txt (renamed from design/templates/guides/guide_detail.txt)0
-rw-r--r--app/guides/templates/guides/guide_list.html (renamed from design/templates/guides/guide_list.html)8
-rw-r--r--app/guides/views.py11
-rw-r--r--app/taxonomy/admin.py28
-rw-r--r--config/base_urls.py7
-rw-r--r--design/templates/base.html8
18 files changed, 281 insertions, 36 deletions
diff --git a/design/templates/fieldnotes/fieldnote_archive_list_date.html b/app/fieldnotes/templates/fieldnotes/fieldnote_archive_list_date.html
index 57bbb69..57bbb69 100644
--- a/design/templates/fieldnotes/fieldnote_archive_list_date.html
+++ b/app/fieldnotes/templates/fieldnotes/fieldnote_archive_list_date.html
diff --git a/design/templates/fieldnotes/fieldnote_detail.html b/app/fieldnotes/templates/fieldnotes/fieldnote_detail.html
index dc90e16..dc90e16 100644
--- a/design/templates/fieldnotes/fieldnote_detail.html
+++ b/app/fieldnotes/templates/fieldnotes/fieldnote_detail.html
diff --git a/design/templates/fieldnotes/fieldnote_list.html b/app/fieldnotes/templates/fieldnotes/fieldnote_list.html
index c201382..c201382 100644
--- a/design/templates/fieldnotes/fieldnote_list.html
+++ b/app/fieldnotes/templates/fieldnotes/fieldnote_list.html
diff --git a/app/guides/admin.py b/app/guides/admin.py
index e424385..7895aba 100644
--- a/app/guides/admin.py
+++ b/app/guides/admin.py
@@ -1,29 +1,34 @@
from django.contrib import admin
+from django.contrib.gis.admin import OSMGeoAdmin
from utils.widgets import LGEntryForm
+from utils.util import get_latlon
from .models import Guide
+
@admin.register(Guide)
-class GuideAdmin(admin.ModelAdmin):
+class GuideAdmin(OSMGeoAdmin):
form = LGEntryForm
- list_display = ('title', 'pub_date', 'enable_comments', 'status')
+ list_display = ('title', 'pub_date', 'enable_comments', 'status', 'post_type')
list_filter = ('pub_date', 'enable_comments', 'status')
prepopulated_fields = {"slug": ('title',)}
fieldsets = (
('Entry', {
'fields': (
'title',
- ('sub_title', 'category'),
+ 'sub_title',
'body_markdown',
- ('pub_date', 'status'),
+ ('pub_date', 'status', 'post_type', 'disclaimer'),
'meta_description',
+ 'featured_image',
'dek',
'tags',
- 'preamble_markdown',
- 'featured_image',
+ 'prologue_markdown',
+ 'epilogue_markdown',
'has_video',
('slug', 'enable_comments'),
+ 'point',
),
'classes': (
'show',
@@ -33,10 +38,7 @@ class GuideAdmin(admin.ModelAdmin):
}),
('meta', {
'fields': (
- 'point',
- 'afterword',
- ('field_notes', 'books'),
- ('essays', 'jrnl'),
+ ('field_notes', 'books','jrnl'),
),
'classes': (
'hide',
@@ -46,5 +48,20 @@ class GuideAdmin(admin.ModelAdmin):
}),
)
+ # options for OSM map Using custom ESRI topo map
+ lat, lon = get_latlon()
+ default_lon = lon
+ default_lat = lat
+ default_zoom = 10
+ units = True
+ scrollable = False
+ map_width = 700
+ map_height = 425
+ map_template = 'gis/admin/osm.html'
+ openlayers_url = '/static/admin/js/OpenLayers.js'
+
class Media:
js = ('image-loader.js', 'next-prev-links.js')
+ css = {
+ "all": ("my_styles.css",)
+ }
diff --git a/app/guides/guide_urls.py b/app/guides/guide_urls.py
new file mode 100644
index 0000000..ad67061
--- /dev/null
+++ b/app/guides/guide_urls.py
@@ -0,0 +1,18 @@
+from django.urls import path, re_path
+
+from . import views
+
+app_name = "guide"
+
+urlpatterns = [
+ path(
+ r'<str:slug>',
+ views.GuideDetailView.as_view(),
+ name="guide-detail"
+ ),
+ path(
+ r'<str:slug>.txt',
+ views.GuideDetailViewTXT.as_view(),
+ name="guide-detail-txt"
+ ),
+]
diff --git a/app/guides/migrations/0002_remove_guide_category.py b/app/guides/migrations/0002_remove_guide_category.py
new file mode 100644
index 0000000..76eefa6
--- /dev/null
+++ b/app/guides/migrations/0002_remove_guide_category.py
@@ -0,0 +1,17 @@
+# Generated by Django 2.1.7 on 2019-07-04 12:05
+
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('guides', '0001_initial'),
+ ]
+
+ operations = [
+ migrations.RemoveField(
+ model_name='guide',
+ name='category',
+ ),
+ ]
diff --git a/app/guides/migrations/0003_guide_category.py b/app/guides/migrations/0003_guide_category.py
new file mode 100644
index 0000000..82d03ac
--- /dev/null
+++ b/app/guides/migrations/0003_guide_category.py
@@ -0,0 +1,21 @@
+# Generated by Django 2.1.7 on 2019-09-08 17:45
+
+from django.db import migrations, models
+import django.db.models.deletion
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('taxonomy', '0001_initial'),
+ ('guides', '0002_remove_guide_category'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='guide',
+ name='category',
+ field=models.ForeignKey(default=1, on_delete=django.db.models.deletion.CASCADE, to='taxonomy.Category'),
+ preserve_default=False,
+ ),
+ ]
diff --git a/app/guides/migrations/0004_auto_20190914_0646.py b/app/guides/migrations/0004_auto_20190914_0646.py
new file mode 100644
index 0000000..ccd79a5
--- /dev/null
+++ b/app/guides/migrations/0004_auto_20190914_0646.py
@@ -0,0 +1,47 @@
+# Generated by Django 2.1.7 on 2019-09-14 06:46
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('guides', '0003_guide_category'),
+ ]
+
+ operations = [
+ migrations.RenameField(
+ model_name='guide',
+ old_name='afterword',
+ new_name='epilogue_html',
+ ),
+ migrations.RenameField(
+ model_name='guide',
+ old_name='afterword_html',
+ new_name='epilogue_markdown',
+ ),
+ migrations.RenameField(
+ model_name='guide',
+ old_name='preamble_html',
+ new_name='prologue_html',
+ ),
+ migrations.RenameField(
+ model_name='guide',
+ old_name='preamble_markdown',
+ new_name='prologue_markdown',
+ ),
+ migrations.RemoveField(
+ model_name='guide',
+ name='essays',
+ ),
+ migrations.AddField(
+ model_name='guide',
+ name='disclaimer',
+ field=models.BooleanField(blank=True, default=False),
+ ),
+ migrations.AddField(
+ model_name='guide',
+ name='post_type',
+ field=models.IntegerField(choices=[(0, 'guide'), (1, 'review')], default=0),
+ ),
+ ]
diff --git a/app/guides/migrations/0005_remove_guide_category.py b/app/guides/migrations/0005_remove_guide_category.py
new file mode 100644
index 0000000..71d0280
--- /dev/null
+++ b/app/guides/migrations/0005_remove_guide_category.py
@@ -0,0 +1,17 @@
+# Generated by Django 2.1.7 on 2019-09-14 07:08
+
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('guides', '0004_auto_20190914_0646'),
+ ]
+
+ operations = [
+ migrations.RemoveField(
+ model_name='guide',
+ name='category',
+ ),
+ ]
diff --git a/app/guides/models.py b/app/guides/models.py
index 1583bee..8704887 100644
--- a/app/guides/models.py
+++ b/app/guides/models.py
@@ -20,11 +20,13 @@ class Guide(models.Model):
title = models.CharField(max_length=200)
sub_title = models.CharField(max_length=200, blank=True)
dek = models.TextField(blank=True)
- preamble_markdown = models.TextField(blank=True)
- preamble_html = models.TextField(blank=True)
- slug = models.SlugField(unique_for_date='pub_date')
- body_html = models.TextField(blank=True)
+ prologue_markdown = models.TextField(blank=True)
+ prologue_html = models.TextField(blank=True)
body_markdown = models.TextField()
+ body_html = models.TextField(blank=True)
+ epilogue_markdown = models.TextField(blank=True)
+ epilogue_html = models.TextField(blank=True)
+ slug = models.SlugField(unique_for_date='pub_date')
pub_date = models.DateTimeField('Date published')
last_updated = models.DateTimeField(auto_now=True)
enable_comments = models.BooleanField(default=False)
@@ -33,19 +35,21 @@ class Guide(models.Model):
(1, 'Published'),
)
status = models.IntegerField(choices=PUB_STATUS, default=0)
+ POST_TYPE = (
+ (0, 'guide'),
+ (1, 'review'),
+ )
+ post_type = models.IntegerField(choices=POST_TYPE, default=0)
meta_description = models.CharField(max_length=256, null=True, blank=True)
tags = TaggableManager(through=TaggedItems, blank=True, help_text='Topics Covered')
- category = models.ForeignKey(Category, on_delete=models.CASCADE)
featured_image = models.ForeignKey(LuxImage, on_delete=models.CASCADE, null=True, blank=True)
+ point = models.PointField(null=True, blank=True)
+ location = models.ForeignKey(Location, on_delete=models.CASCADE, null=True, blank=True)
has_video = models.BooleanField(blank=True, default=False)
+ disclaimer = models.BooleanField(blank=True, default=False)
field_notes = models.ManyToManyField(FieldNote, blank=True)
books = models.ManyToManyField(Book, blank=True)
- essays = models.ManyToManyField(Essay, blank=True)
jrnl = models.ManyToManyField(Entry, blank=True)
- point = models.PointField(null=True, blank=True)
- location = models.ForeignKey(Location, on_delete=models.CASCADE, null=True, blank=True)
- afterword = models.TextField(blank=True)
- afterword_html = models.TextField(blank=True)
class Meta:
ordering = ('-pub_date',)
@@ -56,7 +60,10 @@ class Guide(models.Model):
return self.title
def get_absolute_url(self):
- return reverse('guides:detail', kwargs={"category": self.category, "slug": self.slug})
+ if self.post_type == 0:
+ return reverse('guide:guide-detail', kwargs={"slug": self.slug})
+ if self.post_type == 1:
+ return reverse('review:review-detail', kwargs={"slug": self.slug})
def comment_period_open(self):
return self.enable_comments and datetime.datetime.today() - datetime.timedelta(30) <= self.pub_date
@@ -66,14 +73,55 @@ class Guide(models.Model):
return self.get_previous_by_pub_date(status__exact=1)
@property
+ def get_previous_admin_url(self):
+ n = self.get_previous_by_pub_date()
+ return reverse('admin:%s_%s_change' %(self._meta.app_label, self._meta.model_name), args=[n.id] )
+
+ @property
def get_next_published(self):
return self.get_next_by_pub_date(status__exact=1)
- def save(self):
- md = render_images(self.body_markdown)
- self.body_html = markdown_to_html(md)
- self.afterword_html = markdown_to_html(self.afterword)
- super(Guide, self).save()
+ @property
+ def get_next_admin_url(self):
+ model = apps.get_model(app_label=self._meta.app_label, model_name=self._meta.model_name)
+ try:
+ return reverse('admin:%s_%s_change' %(self._meta.app_label, self._meta.model_name), args=[self.get_next_by_pub_date().pk] )
+ except model.DoesNotExist:
+ return ''
+
+ @property
+ def longitude(self):
+ '''Get the site's longitude.'''
+ return self.point.x
+
+ @property
+ def latitude(self):
+ '''Get the site's latitude.'''
+ return self.point.y
+
+ def save(self, *args, **kwargs):
+ created = self.pk is None
+ if not created:
+ md = render_images(self.body_markdown)
+ self.body_html = markdown_to_html(md)
+ self.prologue_html = markdown_to_html(self.prologue_markdown)
+ self.epilogue_html = markdown_to_html(self.epilogue_markdown)
+ self.has_video = parse_video(self.body_html)
+ if self.point:
+ try:
+ self.location = Location.objects.filter(geometry__contains=self.point).get()
+ except Location.DoesNotExist:
+ raise forms.ValidationError("There is no location associated with that point, add it: %sadmin/locations/location/add/" % (settings.BASE_URL))
+ if created and not self.featured_image:
+ self.featured_image = LuxImage.objects.latest()
+ old = type(self).objects.get(pk=self.pk) if self.pk else None
+ if old and old.featured_image != self.featured_image: # Field has changed
+ s = LuxImageSize.objects.get(name="featured_jrnl")
+ ss = LuxImageSize.objects.get(name="picwide-med")
+ self.featured_image.sizes.add(s)
+ self.featured_image.sizes.add(ss)
+ self.featured_image.save()
+ super(Guide, self).save(*args, **kwargs)
class GuideSitemap(Sitemap):
diff --git a/app/guides/review_urls.py b/app/guides/review_urls.py
new file mode 100644
index 0000000..7048065
--- /dev/null
+++ b/app/guides/review_urls.py
@@ -0,0 +1,18 @@
+from django.urls import path, re_path
+
+from . import views
+
+app_name = "review"
+
+urlpatterns = [
+ path(
+ r'<str:slug>',
+ views.GuideDetailView.as_view(),
+ name="review-detail"
+ ),
+ path(
+ r'<str:slug>.txt',
+ views.GuideDetailViewTXT.as_view(),
+ name="review-detail-txt"
+ ),
+]
diff --git a/design/templates/guides/guide_detail.html b/app/guides/templates/guides/guide_detail.html
index 1ef602a..1ef602a 100644
--- a/design/templates/guides/guide_detail.html
+++ b/app/guides/templates/guides/guide_detail.html
diff --git a/design/templates/guides/guide_detail.txt b/app/guides/templates/guides/guide_detail.txt
index 547ce79..547ce79 100644
--- a/design/templates/guides/guide_detail.txt
+++ b/app/guides/templates/guides/guide_detail.txt
diff --git a/design/templates/guides/guide_list.html b/app/guides/templates/guides/guide_list.html
index 43f31b9..a264a11 100644
--- a/design/templates/guides/guide_list.html
+++ b/app/guides/templates/guides/guide_list.html
@@ -2,8 +2,8 @@
{% load typogrify_tags %}
{% load html5_datetime %}
{% load pagination_tags %}
-{% block pagetitle %}Guides for the perplexed{% endblock %}
-{% block metadescription %}Guides for fellow travelers: tools, tips, and tricks to make life on the road easier{% endblock %}
+{% block pagetitle %}Guides for the Perplexed{% endblock %}
+{% block metadescription %}Guides for fellow travelers: tools, tips, and tricks to make life on the road easier.{% endblock %}
{% block primary %}<ul class="bl" id="breadcrumbs" itemscope itemtype="http://data-vocabulary.org/Breadcrumb">
<li><a href="/" title="luxagraf homepage" itemprop="url"><span itemprop="title">Home</span></a> &rarr; </li>
@@ -12,7 +12,9 @@
<main role="main" id="essay-archive" class="essay-archive archive-list">
<div class="essay-intro">
<h2>Guides for fellow travelers</h2>
- <p>Topics include travel, cooking, photography, writing, simplicity, and once, coffee.</p>
+ <p>The less stuff you travel with the better off you will be, up to a point. But where is that point? What's enough? What's too much? That point is what I'm trying to discover here. </p>
+ <p>What do you really need? What's worth having? What's not?</p>
+ <p>Topics include {% for topic in topic_list %}{{topic}}, {% endfor %}travel, cooking, photography, writing, simplicity, and once, coffee.</p>
</div>
<h1 class="topic-hed">Guides</h1>
{% autopaginate object_list 30 %}
diff --git a/app/guides/views.py b/app/guides/views.py
index 8b5aeaa..01dc974 100644
--- a/app/guides/views.py
+++ b/app/guides/views.py
@@ -14,12 +14,19 @@ class GuideListView(PaginatedListView):
qs = Guide.objects.filter(status=1)
return qs
-class GuideCatListView(PaginatedListView):
+ def get_context_data(self, **kwargs):
+ # Call the base implementation first to get a context
+ context = super(GuideListView, self).get_context_data(**kwargs)
+ context['topic_list'] = Guide.tags.all()
+ return context
+
+
+class GuideCatListView(GuideListView):
model = Guide
def get_queryset(self, **kwargs):
cat = Category.objects.get(slug=self.kwargs['slug'])
- qs = Guide.objects.filter(status=1, category=cat)
+ qs = Guide.objects.filter(status=1, tags=cat)
return qs
class GuideDetailView(DetailView):
diff --git a/app/taxonomy/admin.py b/app/taxonomy/admin.py
new file mode 100644
index 0000000..cc48fac
--- /dev/null
+++ b/app/taxonomy/admin.py
@@ -0,0 +1,28 @@
+from django.contrib import admin
+from .models import Category
+
+
+@admin.register(Category)
+class CategoryAdmin(admin.ModelAdmin):
+ list_display = (
+ 'name',
+ 'color_rgb',
+ )
+ fieldsets = (
+ ('Item', {
+ 'fields': (
+ 'name',
+ 'color_rgb',
+ 'slug',
+ ),
+ 'classes': (
+ 'show',
+ 'extrapretty',
+ 'wide'
+ )
+ }
+ ),
+ )
+
+ class Media:
+ js = ('image-loader.js', 'next-prev-links.js')
diff --git a/config/base_urls.py b/config/base_urls.py
index a7b8d04..a22d203 100644
--- a/config/base_urls.py
+++ b/config/base_urls.py
@@ -3,6 +3,7 @@ from django.contrib import admin
from django.conf.urls.static import static
from django.conf import settings
from django.contrib.sitemaps.views import sitemap
+from django.views.generic.base import RedirectView
from pages.views import PageDetailView
from jrnl.models import BlogSitemap
@@ -46,13 +47,17 @@ urlpatterns = [
path(r'locations/', include('locations.urls')),
path(r'expenses/', include('expenses.urls', namespace='expenses')),
path(r'photos/', include('photos.urls')),
+ path(r'guide/', include('guides.guide_urls')),
+ re_path(r'^guide/$', RedirectView.as_view(url='/guides/')),
+ path(r'guides/', include('guides.urls')),
+ path(r'review/', include('guides.review_urls')),
+ re_path(r'^review/$', RedirectView.as_view(url='/guides/')),
path(r'guides/', include('guides.urls')),
path(r'book-notes/', include('books.urls')),
path(r'people/', include('people.urls')),
path(r'dialogues/', include('sightings.urls', namespace='sightings')),
path(r'field-notes/', include('fieldnotes.urls', namespace='fieldnotes')),
path(r'src/', include('src.urls', namespace='src')),
- path(r'tools/', include('essays.urls', namespace='tools')),
path(r'essays/', include('essays.urls', namespace='essays')),
path(r'work/', include('resume.urls', namespace='resume')),
path(r'map', include('locations.urls', namespace='map')),
diff --git a/design/templates/base.html b/design/templates/base.html
index 4ba62a1..2941a0a 100644
--- a/design/templates/base.html
+++ b/design/templates/base.html
@@ -31,11 +31,11 @@
</div>
<nav>
<ul>
- <li><a href="/jrnl/" title="What I've been up to lately">Jrnl</a></li>
- <li><a href="/essays/" title="longer essays and posts about non-travel related things">Essays</a></li>
- <li><a href="/field-notes/" title="Shorter posts">Notes</a></li>
+ <li><a href="/jrnl/" title="Stories of life on the road.">Jrnl</a></li>
+ <li><a href="/guides/" title="Advice, Tools, Tips and Tricks for Full Time Van or RV Life.">Guides</a></li>
+ <li><a href="/field-notes/" title="Short stories, snapshots of daily life on the road.">Notes</a></li>
<li><a href="/newsletter/" title="The 'friends of a long year' newsletter">Lttr</a></li>
- <!--<li id="guide"><a href="/guides/" title="">Guides</a></li>-->
+ <!--<li><a href="/essays/" title="longer essays and posts about non-travel related things">Essays</a></li>-->
<li><a href="/about" title="About Scott">About</a></li>
</ul>
</nav>