From 5dc9b251a29c79fdd0dafc9ef79318e8f213cb3a Mon Sep 17 00:00:00 2001 From: luxagraf Date: Mon, 7 Dec 2015 21:31:43 -0500 Subject: added builder to resume section --- app/TODO | 8 +++- app/builder/base.py | 2 +- app/pages/admin.py | 2 +- app/pages/migrations/0003_page_app.py | 20 ++++++++++ app/pages/models.py | 6 ++- app/resume/build.py | 21 +++++++--- app/resume/migrations/0001_initial.py | 49 ++++++++++++++++++++++++ app/resume/migrations/0002_auto_20151207_2105.py | 25 ++++++++++++ app/resume/migrations/__init__.py | 0 app/resume/models.py | 5 +++ app/resume/urls.py | 2 +- design/sass/_resume.scss | 11 ++++-- design/templates/archives/resume-pubs.html | 17 ++++---- 13 files changed, 146 insertions(+), 22 deletions(-) create mode 100644 app/pages/migrations/0003_page_app.py create mode 100644 app/resume/migrations/0001_initial.py create mode 100644 app/resume/migrations/0002_auto_20151207_2105.py create mode 100644 app/resume/migrations/__init__.py diff --git a/app/TODO b/app/TODO index 2936c09..f8e24d1 100644 --- a/app/TODO +++ b/app/TODO @@ -16,9 +16,15 @@ fix amp support by sanitizing html: https://github.com/duner/django-bluebox/blob/master/bluebox/converters/sanitizer.py --- - resume +add build script + + +--- + +src + clean up design of book detail handle callbacks from paypal to deliver the book and link to files: https://developer.paypal.com/webapps/developer/docs/classic/ipn/integration-guide/IPNandPDTVariables/ diff --git a/app/builder/base.py b/app/builder/base.py index c3da573..a578920 100644 --- a/app/builder/base.py +++ b/app/builder/base.py @@ -70,7 +70,7 @@ class BuildNew(): path = base_path url = base_path print(path) - response = self.client.get(url, HTTP_HOST='127.0.0.1') + response = self.client.get(url, HTTP_HOST='127.0.0.1', follow=True) if page == 0: self.write_file(base_path, response.content) self.write_file(path, response.content) diff --git a/app/pages/admin.py b/app/pages/admin.py index 977a0cf..b5e41b4 100644 --- a/app/pages/admin.py +++ b/app/pages/admin.py @@ -22,7 +22,7 @@ class PageAdmin(admin.ModelAdmin): prepopulated_fields = {"slug": ('title',)} fieldsets = ( ('Page', { - 'fields': ('title', 'body_markdown', ('slug', 'path')), + 'fields': ('title', 'body_markdown', ('slug', 'path', 'app')), 'classes': ('show', 'extrapretty', 'wide') }), ('Metadata', { diff --git a/app/pages/migrations/0003_page_app.py b/app/pages/migrations/0003_page_app.py new file mode 100644 index 0000000..5edf898 --- /dev/null +++ b/app/pages/migrations/0003_page_app.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9 on 2015-12-07 20:28 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('pages', '0002_page_path'), + ] + + operations = [ + migrations.AddField( + model_name='page', + name='app', + field=models.CharField(blank=True, max_length=50, null=True), + ), + ] diff --git a/app/pages/models.py b/app/pages/models.py index 9b7be7f..0bbd069 100644 --- a/app/pages/models.py +++ b/app/pages/models.py @@ -11,12 +11,16 @@ class Page(models.Model): body_markdown = models.TextField() meta_description = models.CharField(max_length=256, null=True, blank=True) path = models.CharField(max_length=200, null=True, blank=True) + app = models.CharField(max_length=50, null=True, blank=True) def __unicode__(self): return self.title def get_absolute_url(self): - return "/%s/" % (self.slug) + if self.path: + return "/%s/%s" % (self.path, self.slug) + else: + return "/%s" % (self.slug) def save(self): # run markdown diff --git a/app/resume/build.py b/app/resume/build.py index 2b472a4..9d6ad60 100644 --- a/app/resume/build.py +++ b/app/resume/build.py @@ -1,6 +1,7 @@ import os from django.core.urlresolvers import reverse from builder.base import BuildNew +from pages.models import Page class BuildResume(BuildNew): @@ -8,17 +9,14 @@ class BuildResume(BuildNew): def build(self): self.build_detail_view() self.build_list_view( - base_path=reverse("resume:list"), - paginate_by=99999 + base_path=reverse("resume:live_redirect"), + paginate_by=8 ) def get_model_queryset(self): return self.model.objects.all() def build_detail_view(self): - ''' - write out my backups of published articles - ''' for obj in self.get_model_queryset(): url = obj.get_absolute_url() path, slug = os.path.split(url) @@ -28,6 +26,19 @@ class BuildResume(BuildNew): print(path, slug) self.write_file(path, response.content, filename=slug) + def build_pages(self): + ''' + build out /resume and /resume/cv + ''' + pages = Page.objects.filter(app="resume") + for obj in pages: + url = obj.get_absolute_url() + path, slug = os.path.split(url) + path = '%s/' % path + # write html + response = self.client.get(url) + print(path, slug) + self.write_file(path, response.content, filename=slug) def builder(): j = BuildResume("resume", "pubitem") diff --git a/app/resume/migrations/0001_initial.py b/app/resume/migrations/0001_initial.py new file mode 100644 index 0000000..14c9348 --- /dev/null +++ b/app/resume/migrations/0001_initial.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9 on 2015-12-07 21:04 +from __future__ import unicode_literals + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='PubItem', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('title', models.CharField(max_length=200)), + ('slug', models.CharField(max_length=50)), + ('body_markdown', models.TextField(blank=True, null=True)), + ('body_html', models.TextField(blank=True, null=True)), + ('url', models.CharField(blank=True, max_length=200, null=True)), + ('pub_date', models.DateTimeField(verbose_name='Date published')), + ], + options={ + 'ordering': ('-pub_date',), + }, + ), + migrations.CreateModel( + name='Publisher', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=200)), + ('slug', models.SlugField()), + ('body_markdown', models.TextField(blank=True, null=True)), + ('body_html', models.TextField(blank=True, null=True)), + ('url', models.CharField(blank=True, max_length=200, null=True)), + ('payment_time', models.DecimalField(decimal_places=0, max_digits=2)), + ], + ), + migrations.AddField( + model_name='pubitem', + name='publisher', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='resume.Publisher'), + ), + ] diff --git a/app/resume/migrations/0002_auto_20151207_2105.py b/app/resume/migrations/0002_auto_20151207_2105.py new file mode 100644 index 0000000..7ac653f --- /dev/null +++ b/app/resume/migrations/0002_auto_20151207_2105.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9 on 2015-12-07 21:05 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('resume', '0001_initial'), + ] + + operations = [ + migrations.AlterModelOptions( + name='publisher', + options={'ordering': ('-order',)}, + ), + migrations.AddField( + model_name='publisher', + name='order', + field=models.DecimalField(decimal_places=0, default=1, max_digits=1), + preserve_default=False, + ), + ] diff --git a/app/resume/migrations/__init__.py b/app/resume/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/app/resume/models.py b/app/resume/models.py index a8c9809..95c66f7 100644 --- a/app/resume/models.py +++ b/app/resume/models.py @@ -3,6 +3,7 @@ from django.core.urlresolvers import reverse from utils.widgets import markdown_to_html + class Publisher(models.Model): name = models.CharField(max_length=200) slug = models.SlugField(max_length=50) @@ -10,6 +11,10 @@ class Publisher(models.Model): body_html = models.TextField(null=True, blank=True) url = models.CharField(max_length=200, blank=True, null=True) payment_time = models.DecimalField(max_digits=2, decimal_places=0) + order = models.DecimalField(max_digits=1, decimal_places=0) + + class Meta: + ordering = ('order',) def __str__(self): return self.name diff --git a/app/resume/urls.py b/app/resume/urls.py index bc54d36..791f834 100644 --- a/app/resume/urls.py +++ b/app/resume/urls.py @@ -19,7 +19,7 @@ urlpatterns = [ url( r'pubs/$', RedirectView.as_view(url="/resume/pubs/1/", permanent=False), - name="live-redirect" + name="live_redirect" ), url( r'^(?P[-\w]+)(?:/(?P[-\w]+))$', diff --git a/design/sass/_resume.scss b/design/sass/_resume.scss index 1bd9db2..157e88f 100644 --- a/design/sass/_resume.scss +++ b/design/sass/_resume.scss @@ -123,10 +123,13 @@ } } -.pub-title a { - color: $brown; - text-decoration: none; - font-weight: 400; +.pub-title { + margin-bottom: 1.75em; + a { + color: $brown; + text-decoration: none; + font-weight: 400; + } } .resume h6 { @include constrain_narrow; diff --git a/design/templates/archives/resume-pubs.html b/design/templates/archives/resume-pubs.html index daed46f..16270b3 100644 --- a/design/templates/archives/resume-pubs.html +++ b/design/templates/archives/resume-pubs.html @@ -18,14 +18,15 @@ -{% regroup object_list by publisher.name as pub_list %}{% for pub in pub_list %} -
    -
  • {{ pub.grouper }}

  • - {% endfor %} +
      {% regroup object_list|dictsort:"publisher_id" by publisher.name as pub_list %}{% for pub in pub_list %} +
    • +

      {{ pub.grouper }}

      + +
    • {% endfor %}
    {% endblock %} -- cgit v1.2.3-70-g09d2