summaryrefslogtreecommitdiff
path: root/app/essays
diff options
context:
space:
mode:
Diffstat (limited to 'app/essays')
-rw-r--r--app/essays/admin.py8
-rw-r--r--app/essays/build.py50
-rw-r--r--app/essays/migrations/0005_auto_20190208_0946.py25
-rw-r--r--app/essays/models.py13
-rw-r--r--app/essays/urls.py2
-rw-r--r--app/essays/views.py13
6 files changed, 37 insertions, 74 deletions
diff --git a/app/essays/admin.py b/app/essays/admin.py
index f326092..35a9997 100644
--- a/app/essays/admin.py
+++ b/app/essays/admin.py
@@ -1,12 +1,8 @@
from django.contrib import admin
-from .models import Essay, PostType
-from utils.widgets import LGEntryForm
-
-@admin.register(PostType)
-class PostTypeAdmin(admin.ModelAdmin):
- prepopulated_fields = {"slug": ('name',)}
+from utils.widgets import LGEntryForm
+from .models import Essay
@admin.register(Essay)
class EssayAdmin(admin.ModelAdmin):
diff --git a/app/essays/build.py b/app/essays/build.py
index cd6cc28..62370d0 100644
--- a/app/essays/build.py
+++ b/app/essays/build.py
@@ -4,56 +4,16 @@ from django.urls import reverse
from . import models
-class BuildSrc(BuildNew):
+class BuildEssays(BuildNew):
def build(self):
- self.build_list_view(
- base_path=reverse("src:list"),
- paginate_by=99999
- )
- self.build_list_view(
- base_path=reverse("src:list_books"),
- paginate_by=99999
- )
+ self.build_list_view()
self.build_detail_view()
# These are the unique classes for this model:
- # self.build_books_view()
- self.build_topic_view()
- self.build_feed("src:feed")
+ #self.build_feed("src:feed")
- def build_topic_view(self):
- for topic in models.Topic.objects.all():
- url = reverse("src:list_topics", kwargs={'slug': topic.slug, })
- path, slug = os.path.split(url)
- response = self.client.get(url, HTTP_HOST='127.0.0.1')
- self.write_file('%s/' % path, response.content, filename=slug)
- def build_books_view(self):
- for obj in models.Book.objects.all():
- url = reverse("src:detail_book", kwargs={'slug': obj.slug, })
- path, slug = os.path.split(url)
- response = self.client.get(url, HTTP_HOST='127.0.0.1')
- self.write_file('%s/' % path, response.content, filename=slug)
-
-def builder():
- j = BuildSrc("src", "post")
+def essaybuilder():
+ j = BuildEssays("essays", "essay")
j.build()
-
-
-"""
-
-
-
-
- def build_books(self):
- path = 'src/books/'
- c = Context({
- 'object_list': Book.objects.filter(status__exact=1),
- 'MEDIA_URL': settings.BAKED_MEDIA_URL,
- 'IMAGES_URL': settings.BAKED_IMAGES_URL
- })
- t = render_to_string('archives/src_books.html', c).encode('utf-8')
- self.write_file(path, t)
-
-"""
diff --git a/app/essays/migrations/0005_auto_20190208_0946.py b/app/essays/migrations/0005_auto_20190208_0946.py
new file mode 100644
index 0000000..5b68bb4
--- /dev/null
+++ b/app/essays/migrations/0005_auto_20190208_0946.py
@@ -0,0 +1,25 @@
+# Generated by Django 2.1.5 on 2019-02-08 09:46
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('essays', '0004_auto_20190205_0830'),
+ ]
+
+ operations = [
+ migrations.DeleteModel(
+ name='PostType',
+ ),
+ migrations.RemoveField(
+ model_name='essay',
+ name='post_type',
+ ),
+ migrations.AddField(
+ model_name='essay',
+ name='preamble',
+ field=models.TextField(blank=True),
+ ),
+ ]
diff --git a/app/essays/models.py b/app/essays/models.py
index 23a4cce..6160165 100644
--- a/app/essays/models.py
+++ b/app/essays/models.py
@@ -20,19 +20,11 @@ POST_TYPE = (
)
-class PostType(models.Model):
- name = models.CharField(max_length=200)
- dek = models.TextField(blank=True)
- slug = models.SlugField()
-
- def __str__(self):
- return self.name
-
-
class Essay(models.Model):
title = models.CharField(max_length=200)
sub_title = models.CharField(max_length=200, blank=True)
dek = models.TextField(blank=True)
+ preamble = models.TextField(blank=True)
slug = models.SlugField(unique_for_date='pub_date')
body_html = models.TextField(blank=True)
body_markdown = models.TextField()
@@ -46,7 +38,6 @@ class Essay(models.Model):
)
status = models.IntegerField(choices=PUB_STATUS, default=0)
meta_description = models.CharField(max_length=256, null=True, blank=True)
- post_type = models.IntegerField(choices=POST_TYPE, default=0)
tags = TaggableManager(through=TaggedItems, blank=True, help_text='Topics Covered')
originally_published_by = models.CharField(max_length=400, blank=True)
originally_published_by_url = models.CharField(max_length=400, blank=True)
@@ -66,7 +57,7 @@ class Essay(models.Model):
return self.title
def get_absolute_url(self):
- return "/%s/%s" % (self.get_post_type_display(), self.slug)
+ return reverse('essays:detail', kwargs={"slug": self.slug})
def comment_period_open(self):
return self.enable_comments and datetime.datetime.today() - datetime.timedelta(30) <= self.pub_date
diff --git a/app/essays/urls.py b/app/essays/urls.py
index 408e959..8216f06 100644
--- a/app/essays/urls.py
+++ b/app/essays/urls.py
@@ -16,7 +16,7 @@ urlpatterns = [
name="detail"
),
path(
- r'<str:slug>.txt',
+ r'<str:slug>',
views.EntryDetailViewTXT.as_view(),
name="detail-txt"
),
diff --git a/app/essays/views.py b/app/essays/views.py
index 0fdaa63..f8c68c7 100644
--- a/app/essays/views.py
+++ b/app/essays/views.py
@@ -3,25 +3,16 @@ from django.views.generic.detail import DetailView
from django.contrib.syndication.views import Feed
-from .models import Essay, PostType, POST_TYPE
+from .models import Essay
class EssayListView(ListView):
model = Essay
def get_queryset(self, **kwargs):
- t = self.request.path.split('/')[1]
- type_reverse = dict((v, k) for k, v in POST_TYPE)
- self.essay_type = t
- qs = Essay.objects.filter(post_type=type_reverse[t])
+ qs = Essay.objects.filter(status=1)
return qs
- def get_context_data(self, **kwargs):
- # Call the base implementation first to get a context
- context = super(EssayListView, self).get_context_data(**kwargs)
- context['essay_type'] = PostType.objects.get(slug=self.essay_type)
- return context
-
class EntryDetailView(DetailView):
model = Essay