diff options
author | luxagraf <sng@luxagraf.net> | 2019-02-08 13:47:02 -0600 |
---|---|---|
committer | luxagraf <sng@luxagraf.net> | 2019-02-08 13:47:02 -0600 |
commit | ee62ce525c5c5c1b3abd25673598360f2ccd79cc (patch) | |
tree | ead317f6b487fc31219a48a1baf7d17cabcf4ce3 /app | |
parent | 27aaf92d26eb75157dcfa923a5d63ea63feeb98c (diff) |
changed essays to allow easier building
Diffstat (limited to 'app')
-rw-r--r-- | app/builder/views.py | 4 | ||||
-rw-r--r-- | app/essays/admin.py | 8 | ||||
-rw-r--r-- | app/essays/build.py | 50 | ||||
-rw-r--r-- | app/essays/migrations/0005_auto_20190208_0946.py | 25 | ||||
-rw-r--r-- | app/essays/models.py | 13 | ||||
-rw-r--r-- | app/essays/urls.py | 2 | ||||
-rw-r--r-- | app/essays/views.py | 13 | ||||
-rw-r--r-- | app/jrnl/views.py | 2 |
8 files changed, 42 insertions, 75 deletions
diff --git a/app/builder/views.py b/app/builder/views.py index 3bab64e..7949a35 100644 --- a/app/builder/views.py +++ b/app/builder/views.py @@ -12,6 +12,7 @@ from notes.build import builder as notes_builder from pages.build import builder as page_builder from sketches.build import builder as sketches_builder from photos.build import dailybuilder +from essays.build import essaybuilder options = { 'writing': BuildWriting, @@ -76,6 +77,9 @@ def do_build(request): elif section == 'sketches': context = {'message': 'Writing Notes to Disk'} sketches_builder() + elif section == 'essays': + context = {'message': 'Writing Essays to Disk'} + essaybuilder() else: options[section]().build() context = {'message': 'Writing %s to Disk' % section} 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 diff --git a/app/jrnl/views.py b/app/jrnl/views.py index b2b0316..70b6bf0 100644 --- a/app/jrnl/views.py +++ b/app/jrnl/views.py @@ -109,7 +109,7 @@ class HomepageList(ListView): def get_queryset(self): queryset = super(HomepageList, self).get_queryset() self.home = self.get_home() - return queryset.filter(status__exact=1).order_by('-pub_date').exclude().select_related('location').select_related('featured_image')[:8] + return queryset.filter(status__exact=1).order_by('-pub_date').exclude().select_related('location').select_related('featured_image')[1:9] def get_template_names(self): return ['%s' % self.home.template_name] |