From 5b86e4c986b39bc1027d371e9c108fa30ef3f052 Mon Sep 17 00:00:00 2001 From: luxagraf Date: Wed, 24 Mar 2021 14:22:04 -0400 Subject: lttr: migrated to new post -> lttr -> send system. --- app/builder/views.py | 15 +- app/lttr/admin.py | 37 ++++- app/lttr/build.py | 37 ----- app/lttr/migrations/0015_newnewslettermailing.py | 35 +++++ .../0016_mailingstatus_newnewsletter_mailing.py | 20 +++ app/lttr/migrations/0017_auto_20210324_1330.py | 19 +++ app/lttr/migrations/0018_auto_20210324_1331.py | 23 +++ app/lttr/migrations/0019_auto_20210324_1350.py | 20 +++ app/lttr/migrations/0020_auto_20210324_1351.py | 19 +++ app/lttr/migrations/0021_auto_20210324_1352.py | 18 +++ app/lttr/models.py | 52 +++++- app/lttr/templates/lttr/confirm_activate.html | 2 +- .../templates/lttr/emails/friends_html_email.html | 9 +- .../lttr/emails/friends_plain_text_email.txt | 6 +- .../templates/lttr/emails/range_html_email.html | 13 +- .../lttr/emails/range_plain_text_email.txt | 6 +- .../lttr/emails/test-friends_html_email.html | 8 +- .../lttr/emails/test-friends_plain_text_email.txt | 6 +- .../lttr/emails/test-range_html_email.html | 13 +- .../lttr/emails/test-range_plain_text_email.txt | 8 +- app/lttr/templates/lttr/friends_detail.html | 175 --------------------- app/lttr/templates/lttr/friends_list.html | 29 ---- app/lttr/templates/lttr/subscribed.html | 4 +- app/lttr/templates/lttr/unsubscribe.html | 15 +- app/lttr/urls.py | 32 +--- app/lttr/views.py | 51 +----- app/posts/build.py | 29 ++++ app/posts/models.py | 12 +- app/posts/urls/friends_urls.py | 7 +- app/posts/urls/range_urls.py | 11 +- app/posts/views/friends_views.py | 15 ++ app/posts/views/range_views.py | 15 ++ 32 files changed, 367 insertions(+), 394 deletions(-) delete mode 100644 app/lttr/build.py create mode 100644 app/lttr/migrations/0015_newnewslettermailing.py create mode 100644 app/lttr/migrations/0016_mailingstatus_newnewsletter_mailing.py create mode 100644 app/lttr/migrations/0017_auto_20210324_1330.py create mode 100644 app/lttr/migrations/0018_auto_20210324_1331.py create mode 100644 app/lttr/migrations/0019_auto_20210324_1350.py create mode 100644 app/lttr/migrations/0020_auto_20210324_1351.py create mode 100644 app/lttr/migrations/0021_auto_20210324_1352.py delete mode 100644 app/lttr/templates/lttr/friends_detail.html delete mode 100644 app/lttr/templates/lttr/friends_list.html (limited to 'app') diff --git a/app/builder/views.py b/app/builder/views.py index e3c795e..5d209d5 100644 --- a/app/builder/views.py +++ b/app/builder/views.py @@ -6,8 +6,7 @@ from resume.build import pub_builder, resume_builder from books.build import builder as book_builder from sightings.build import builder as sightings_builder from pages.build import BuildPages, BuildHome -from posts.build import BuildJrnl, BuildFieldNotes, BuildSrc, BuildGuide, BuildEssays -from lttr.build import lttr_builder +from posts.build import BuildJrnl, BuildFieldNotes, BuildSrc, BuildGuide, BuildEssays, BuildRange, BuildFriends def do_build(request): section = request.GET.get('id', '') @@ -35,15 +34,18 @@ def do_build(request): elif section == 'guide': context = {'message': 'Writing guide section to Disk'} BuildGuide("posts", "post").build() + elif section == 'range': + context = {'message': 'Writing Range to Disk'} + BuildRange("posts", "post").build() + elif section == 'friends': + context = {'message': 'Writing Friends to Disk'} + BuildFriends("posts", "post").build() elif section == 'pages': context = {'message': 'Writing Pages to Disk'} BuildPages("pages", "page", 'luxagraf.net').build() elif section == 'fieldnotes': context = {'message': 'Writing FieldNotes to Disk'} BuildFieldNotes("posts", "post").build() - elif section == 'lttr_archive': - context = {'message': 'Writing newsletter archives to Disk'} - lttr_builder() elif section == 'buildbooks': context = {'message': 'Writing Book Pages to Disk'} book_builder() @@ -62,9 +64,6 @@ def do_build(request): elif section == 'discursivepages': context = {'message': 'Writing Discursive Meditation Pages to Disk'} BuildPages("pages", "page", 'discursivemeditation.com').build() - elif section == 'srcrss': - context = {'message': 'Writing SrcRSS to Disk'} - BuildSrc("posts", "post").build_feed("src:feed") return render(request, 'admin/message.html', context) diff --git a/app/lttr/admin.py b/app/lttr/admin.py index da306f5..a13ab5b 100644 --- a/app/lttr/admin.py +++ b/app/lttr/admin.py @@ -2,7 +2,7 @@ from django.contrib import admin from utils.widgets import AdminImageWidget, LGEntryForm -from .models import NewsletterMailing, Subscriber, Newsletter, MailingStatus +from .models import NewsletterMailing, OldNewsletterMailing, Subscriber, Newsletter, MailingStatus @admin.register(Subscriber) class SubscriberAdmin(admin.ModelAdmin): @@ -17,8 +17,8 @@ class SubscriberAdmin(admin.ModelAdmin): class NewsletterAdmin(admin.ModelAdmin): pass -@admin.register(NewsletterMailing) -class NewsletterMailingAdmin(admin.ModelAdmin): +@admin.register(OldNewsletterMailing) +class OldNewsletterMailingAdmin(admin.ModelAdmin): form = LGEntryForm list_display = ('title', 'pub_date', 'newsletter', 'status') list_filter = ['newsletter'] @@ -53,3 +53,34 @@ class NewsletterMailingAdmin(admin.ModelAdmin): class MailingStatusAdmin(admin.ModelAdmin): list_display = ('newsletter_mailing', 'subscriber', 'status', 'creation_date', 'newsletter') list_filter = ('status', 'creation_date', 'newsletter_mailing__newsletter') + +@admin.register(NewsletterMailing) +class NewsletterMailingAdmin(admin.ModelAdmin): + form = LGEntryForm + list_display = ('title', 'pub_date', 'newsletter', 'post') + list_filter = ['newsletter'] + fieldsets = ( + ('Entry', { + 'fields': ( + ("newsletter", "post"), + 'title', + 'subtitle', + 'body_markdown', + 'body_html', + 'body_email_html', + 'pub_date', + 'featured_image', + ), + 'classes': ( + 'show', + 'extrapretty', + 'wide' + ) + } + ), + ) + class Media: + js = ('image-loader.js', 'next-prev-links.js') + css = { + "all": ("my_styles.css",) + } diff --git a/app/lttr/build.py b/app/lttr/build.py deleted file mode 100644 index 4e53e39..0000000 --- a/app/lttr/build.py +++ /dev/null @@ -1,37 +0,0 @@ -import os -from django.urls import reverse -from django.apps import apps -from builder.base import BuildNew -from itertools import chain - -from django.conf import settings -from .models import NewsletterMailing - - -class BuildNewsletterArchives(BuildNew): - - def get_model_queryset(self): - return self.model.objects.exclude(slug='test-friends').exclude(slug='test-range').exclude(slug='test-src').exclude(slug='src') - - - def build(self): - for lttr in self.get_model_queryset(): - self.build_list_view( - base_path=reverse("lttr:list", kwargs={'slug':lttr.slug}), - paginate_by=50 - ) - self.build_detail_view(lttr) - - def build_detail_view(self, lttr): - for obj in lttr.newslettermailing_set.all(): - 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 lttr_builder(): - j = BuildNewsletterArchives("lttr", "Newsletter") - j.build() diff --git a/app/lttr/migrations/0015_newnewslettermailing.py b/app/lttr/migrations/0015_newnewslettermailing.py new file mode 100644 index 0000000..0d8fa34 --- /dev/null +++ b/app/lttr/migrations/0015_newnewslettermailing.py @@ -0,0 +1,35 @@ +# Generated by Django 3.1 on 2021-03-24 12:54 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('media', '0008_auto_20201202_1155'), + ('posts', '0019_auto_20210323_2155'), + ('lttr', '0014_newsletter_intro'), + ] + + operations = [ + migrations.CreateModel( + name='NewNewsletterMailing', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('title', models.CharField(blank=True, max_length=250)), + ('subtitle', models.CharField(blank=True, max_length=250, null=True)), + ('body_html', models.TextField(blank=True)), + ('body_email_html', models.TextField(blank=True)), + ('body_markdown', models.TextField(blank=True)), + ('pub_date', models.DateTimeField(blank=True)), + ('issue', models.PositiveIntegerField(blank=True)), + ('featured_image', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='media.luximage')), + ('newsletter', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='lttr.newsletter')), + ('post', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='posts.post')), + ], + options={ + 'ordering': ('-title', '-pub_date'), + }, + ), + ] diff --git a/app/lttr/migrations/0016_mailingstatus_newnewsletter_mailing.py b/app/lttr/migrations/0016_mailingstatus_newnewsletter_mailing.py new file mode 100644 index 0000000..dfe9463 --- /dev/null +++ b/app/lttr/migrations/0016_mailingstatus_newnewsletter_mailing.py @@ -0,0 +1,20 @@ +# Generated by Django 3.1 on 2021-03-24 13:23 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('lttr', '0015_newnewslettermailing'), + ] + + operations = [ + migrations.AddField( + model_name='mailingstatus', + name='newnewsletter_mailing', + field=models.ForeignKey(default=1, on_delete=django.db.models.deletion.CASCADE, to='lttr.newnewslettermailing', verbose_name='newsletter'), + preserve_default=False, + ), + ] diff --git a/app/lttr/migrations/0017_auto_20210324_1330.py b/app/lttr/migrations/0017_auto_20210324_1330.py new file mode 100644 index 0000000..3519eec --- /dev/null +++ b/app/lttr/migrations/0017_auto_20210324_1330.py @@ -0,0 +1,19 @@ +# Generated by Django 3.1 on 2021-03-24 13:30 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('lttr', '0016_mailingstatus_newnewsletter_mailing'), + ] + + operations = [ + migrations.AlterField( + model_name='mailingstatus', + name='newnewsletter_mailing', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='lttr.newnewslettermailing', verbose_name='newnewsletter'), + ), + ] diff --git a/app/lttr/migrations/0018_auto_20210324_1331.py b/app/lttr/migrations/0018_auto_20210324_1331.py new file mode 100644 index 0000000..1dc16a1 --- /dev/null +++ b/app/lttr/migrations/0018_auto_20210324_1331.py @@ -0,0 +1,23 @@ +# Generated by Django 3.1 on 2021-03-24 13:31 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('lttr', '0017_auto_20210324_1330'), + ] + + operations = [ + migrations.RemoveField( + model_name='mailingstatus', + name='newsletter_mailing', + ), + migrations.AlterField( + model_name='mailingstatus', + name='newnewsletter_mailing', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='lttr.newnewslettermailing', verbose_name='newsletter'), + ), + ] diff --git a/app/lttr/migrations/0019_auto_20210324_1350.py b/app/lttr/migrations/0019_auto_20210324_1350.py new file mode 100644 index 0000000..47b0f38 --- /dev/null +++ b/app/lttr/migrations/0019_auto_20210324_1350.py @@ -0,0 +1,20 @@ +# Generated by Django 3.1 on 2021-03-24 13:50 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('media', '0008_auto_20201202_1155'), + ('taxonomy', '0006_auto_20210107_1611'), + ('books', '0016_bookhighlight_is_public'), + ('lttr', '0018_auto_20210324_1331'), + ] + + operations = [ + migrations.RenameModel( + old_name='NewsletterMailing', + new_name='OldNewsletterMailing', + ), + ] diff --git a/app/lttr/migrations/0020_auto_20210324_1351.py b/app/lttr/migrations/0020_auto_20210324_1351.py new file mode 100644 index 0000000..e4315dc --- /dev/null +++ b/app/lttr/migrations/0020_auto_20210324_1351.py @@ -0,0 +1,19 @@ +# Generated by Django 3.1 on 2021-03-24 13:51 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('posts', '0019_auto_20210323_2155'), + ('media', '0008_auto_20201202_1155'), + ('lttr', '0019_auto_20210324_1350'), + ] + + operations = [ + migrations.RenameModel( + old_name='NewNewsletterMailing', + new_name='NewsletterMailing', + ), + ] diff --git a/app/lttr/migrations/0021_auto_20210324_1352.py b/app/lttr/migrations/0021_auto_20210324_1352.py new file mode 100644 index 0000000..42d6b41 --- /dev/null +++ b/app/lttr/migrations/0021_auto_20210324_1352.py @@ -0,0 +1,18 @@ +# Generated by Django 3.1 on 2021-03-24 13:52 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('lttr', '0020_auto_20210324_1351'), + ] + + operations = [ + migrations.RenameField( + model_name='mailingstatus', + old_name='newnewsletter_mailing', + new_name='newsletter_mailing', + ), + ] diff --git a/app/lttr/models.py b/app/lttr/models.py index e39b3b0..f1125d0 100644 --- a/app/lttr/models.py +++ b/app/lttr/models.py @@ -21,6 +21,7 @@ from utils.util import render_images, parse_video, markdown_to_html from taxonomy.models import TaggedItems from media.models import LuxImage, LuxImageSize from books.models import Book +from posts.models import Post # Possible actions that user can perform @@ -125,7 +126,7 @@ class Newsletter(models.Model): return None -class NewsletterMailing(models.Model): +class OldNewsletterMailing(models.Model): """ A model for Newletter Mailings, the things actually sent out """ newsletter = models.ForeignKey(Newsletter, on_delete=models.CASCADE) title = models.CharField(max_length=250) @@ -206,6 +207,55 @@ class NewsletterMailing(models.Model): super(NewsletterMailing, self).save() +class NewsletterMailing(models.Model): + """ A model for Newletter Mailings, the things actually sent out """ + newsletter = models.ForeignKey(Newsletter, on_delete=models.CASCADE) + post = models.ForeignKey(Post, null=True, blank=True, on_delete=models.SET_NULL) + title = models.CharField(max_length=250, blank=True) + subtitle = models.CharField(max_length=250, null=True, blank=True) + body_html = models.TextField(blank=True) + body_email_html = models.TextField(blank=True) + body_markdown = models.TextField(blank=True) + pub_date = models.DateTimeField(blank=True) + featured_image = models.ForeignKey(LuxImage, on_delete=models.CASCADE, null=True, blank=True) + issue = models.PositiveIntegerField(blank=True) + + class Meta: + ordering = ('-title', '-pub_date') + + def __str__(self): + return self.title + + def email_encode(self): + return self.body_markdown + + 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 + + def save(self, *args, **kwargs): + created = self.pk is None + if created and self.post: + self.title = self.post.title + self.subtitle = self.post.subtitle + self.body_markdown = self.post.body_markdown + self.pub_date = self.post.pub_date + self.featured_image = self.post.featured_image + self.issue = self.post.issue + if not created: + md = render_images(self.body_markdown) + self.body_html = markdown_to_html(md) + self.body_email_html = markdown_to_emailhtml(self.body_html) + self.date_created = timezone.now() + if created and not self.featured_image: + self.featured_image = LuxImage.objects.latest() + super(NewNewsletterMailing, self).save() + + class Subscriber(models.Model): """ A model for Newletter Subscriber """ email_field = models.EmailField(db_column='email', db_index=True, blank=True, null=True) diff --git a/app/lttr/templates/lttr/confirm_activate.html b/app/lttr/templates/lttr/confirm_activate.html index 533d93f..a2d3a3d 100644 --- a/app/lttr/templates/lttr/confirm_activate.html +++ b/app/lttr/templates/lttr/confirm_activate.html @@ -18,7 +18,7 @@

You're confirmed, thanks for joining.

-

If you'd like you can visit the archives of past mailings.

+

If you'd like you can browse the archives of past mailings.

{%endblock%} diff --git a/app/lttr/templates/lttr/emails/friends_html_email.html b/app/lttr/templates/lttr/emails/friends_html_email.html index 0c70654..66ae18f 100644 --- a/app/lttr/templates/lttr/emails/friends_html_email.html +++ b/app/lttr/templates/lttr/emails/friends_html_email.html @@ -187,11 +187,11 @@ ul li, ol li {


- Friends of a Long Year — {{object.get_issue_str}} — {{object.pub_date|date:"F"}} {{object.pub_date|date:"j, Y"}}

+ Friends of a Long Year — {{object.get_issue_str}} — {{object.pub_date|date:"F"}} {{object.pub_date|date:"j, Y"}}

{{object.title|safe|smartypants}}


- + {% include "lib/friends_featured_img.html" with image=object.featured_image %}
@@ -218,12 +218,9 @@ ul li, ol li { @@ -210,19 +210,16 @@ ul li, ol li {
- - {%comment%}

This newsletter is made possible by members of SPECIAL PROJECTS.
- If you enjoy Ridgeline, consider joining. Thanks.

{%endcomment%}

New subscriber?
- Browse the online archives here.

+ Browse the online archives here.

⫹⫺

Friends?
diff --git a/app/lttr/templates/lttr/emails/friends_plain_text_email.txt b/app/lttr/templates/lttr/emails/friends_plain_text_email.txt index b145d51..286b527 100644 --- a/app/lttr/templates/lttr/emails/friends_plain_text_email.txt +++ b/app/lttr/templates/lttr/emails/friends_plain_text_email.txt @@ -7,10 +7,10 @@ You're getting this email because you signed up for Scott Gilbertson's (luxagraf)[https://luxagraf.net/] newsletter, -*Friends of a Long Year* [https://luxagraf.net/newsletter/friends/] +*Friends of a Long Year* [https://luxagraf.net/friends/] -If you're new, you can explore past letters here: [https://luxagraf.net/newsletter/friends/] +If you're new, you can explore past letters here: [https://luxagraf.net/friends/] You can always: Unsubscribe [https://luxagraf.net{{subscriber.unsubscribe_activate_url}}] instantly. -[https://luxagraf.net/] ✪ [https://luxagraf.net/newsletter/friends/] +[https://luxagraf.net/] ✪ [https://luxagraf.net/friends/] diff --git a/app/lttr/templates/lttr/emails/range_html_email.html b/app/lttr/templates/lttr/emails/range_html_email.html index 0b94a68..09c2db3 100644 --- a/app/lttr/templates/lttr/emails/range_html_email.html +++ b/app/lttr/templates/lttr/emails/range_html_email.html @@ -179,17 +179,17 @@ ul li, ol li {


- ✪ Range — {{object.get_issue_str}} — {{object.pub_date|date:"F"}} {{object.pub_date|date:"j, Y"}}

+ ✪ Range — {{object.get_issue_str}} — {{object.pub_date|date:"F"}} {{object.pub_date|date:"j, Y"}}

{{object.title|safe|smartypants}}


- + {% include "lib/friends_featured_img.html" with image=object.featured_image %}

- If you'd like to view a larger version, read some backstory, and see a video of the development process in Darktable, head on over to: https://luxagraf.net{{object.get_absolute_url}} + If you'd like to view a larger version, read some backstory, and see a video of the development process in Darktable, head on over to: https://luxagraf.net{{object.post.get_absolute_url}}
@@ -210,19 +210,16 @@ ul li, ol li {
- - {%comment%}

This newsletter is made possible by members of SPECIAL PROJECTS.
- If you enjoy Ridgeline, consider joining. Thanks.

{%endcomment%}

New subscriber?
- Browse the online archives here.

+ Browse the online archives here.

Range?
A weekly letter from Scott Gilberson,
also known as luxagraf.

Shipped from Points Unknown, USA.
- Explained here.

+ Explained here.


If you enjoy this,
please consider forwarding it to a friend.

diff --git a/app/lttr/templates/lttr/emails/range_plain_text_email.txt b/app/lttr/templates/lttr/emails/range_plain_text_email.txt index cdb8c52..2044e44 100644 --- a/app/lttr/templates/lttr/emails/range_plain_text_email.txt +++ b/app/lttr/templates/lttr/emails/range_plain_text_email.txt @@ -10,10 +10,10 @@ You're getting this email because you signed up for Scott Gilbertson's (luxagraf)[https://luxagraf.net/] photo newsletter, -*Range* [https://luxagraf.net/newsletter/range/] +*Range* [https://luxagraf.net/range/] -If you're new, you can explore past letters here: [https://luxagraf.net/newsletter/range/] +If you're new, you can explore past letters here: [https://luxagraf.net/range/] You can always: Unsubscribe [https://luxagraf.net{{subscriber.unsubscribe_activate_url}}] instantly. -[https://luxagraf.net/] ✪ [https://luxagraf.net/newsletter/range/] +[https://luxagraf.net/] ✪ [https://luxagraf.net/range/] diff --git a/app/lttr/templates/lttr/emails/test-friends_html_email.html b/app/lttr/templates/lttr/emails/test-friends_html_email.html index 0c70654..d1e2f5a 100644 --- a/app/lttr/templates/lttr/emails/test-friends_html_email.html +++ b/app/lttr/templates/lttr/emails/test-friends_html_email.html @@ -187,11 +187,11 @@ ul li, ol li {


- Friends of a Long Year — {{object.get_issue_str}} — {{object.pub_date|date:"F"}} {{object.pub_date|date:"j, Y"}}

+ Friends of a Long Year — {{object.get_issue_str}} — {{object.pub_date|date:"F"}} {{object.pub_date|date:"j, Y"}}

{{object.title|safe|smartypants}}


- + {% include "lib/friends_featured_img.html" with image=object.featured_image %}
@@ -219,11 +219,9 @@ ul li, ol li {
- {%comment%}

This newsletter is made possible by members of SPECIAL PROJECTS.
- If you enjoy Ridgeline, consider joining. Thanks.

{%endcomment%}

New subscriber?
- Browse the online archives here.

+ Browse the online archives here.

⫹⫺

Friends?
diff --git a/app/lttr/templates/lttr/emails/test-friends_plain_text_email.txt b/app/lttr/templates/lttr/emails/test-friends_plain_text_email.txt index b145d51..286b527 100644 --- a/app/lttr/templates/lttr/emails/test-friends_plain_text_email.txt +++ b/app/lttr/templates/lttr/emails/test-friends_plain_text_email.txt @@ -7,10 +7,10 @@ You're getting this email because you signed up for Scott Gilbertson's (luxagraf)[https://luxagraf.net/] newsletter, -*Friends of a Long Year* [https://luxagraf.net/newsletter/friends/] +*Friends of a Long Year* [https://luxagraf.net/friends/] -If you're new, you can explore past letters here: [https://luxagraf.net/newsletter/friends/] +If you're new, you can explore past letters here: [https://luxagraf.net/friends/] You can always: Unsubscribe [https://luxagraf.net{{subscriber.unsubscribe_activate_url}}] instantly. -[https://luxagraf.net/] ✪ [https://luxagraf.net/newsletter/friends/] +[https://luxagraf.net/] ✪ [https://luxagraf.net/friends/] diff --git a/app/lttr/templates/lttr/emails/test-range_html_email.html b/app/lttr/templates/lttr/emails/test-range_html_email.html index 0b94a68..d11479c 100644 --- a/app/lttr/templates/lttr/emails/test-range_html_email.html +++ b/app/lttr/templates/lttr/emails/test-range_html_email.html @@ -179,17 +179,17 @@ ul li, ol li {


- ✪ Range — {{object.get_issue_str}} — {{object.pub_date|date:"F"}} {{object.pub_date|date:"j, Y"}}

+ ✪ Range — {{object.get_issue_str}} — {{object.pub_date|date:"F"}} {{object.pub_date|date:"j, Y"}}

{{object.title|safe|smartypants}}


- + {% include "lib/friends_featured_img.html" with image=object.featured_image %}

- If you'd like to view a larger version, read some backstory, and see a video of the development process in Darktable, head on over to: https://luxagraf.net{{object.get_absolute_url}} + If you'd like to view a larger version, read some backstory, and see a video of the development process in Darktable, head on over to: https://luxagraf.net{{object.post.get_absolute_url}}
- - {%comment%}

This newsletter is made possible by members of SPECIAL PROJECTS.
- If you enjoy Ridgeline, consider joining. Thanks.

{%endcomment%}

New subscriber?
- Browse the online archives here.

+ Browse the online archives here.

Range?
A weekly letter from Scott Gilberson,
also known as luxagraf.

Shipped from Points Unknown, USA.
- Explained here.

+ Explained here.


If you enjoy this,
please consider forwarding it to a friend.

diff --git a/app/lttr/templates/lttr/emails/test-range_plain_text_email.txt b/app/lttr/templates/lttr/emails/test-range_plain_text_email.txt index b823d2f..970c42f 100644 --- a/app/lttr/templates/lttr/emails/test-range_plain_text_email.txt +++ b/app/lttr/templates/lttr/emails/test-range_plain_text_email.txt @@ -2,7 +2,7 @@ Greetings Range subscribers- While I respect your desire for plain text email, there really isn't a way to do a photo newsletter in plain text other than to say, here's a link to the web-based version: -<{{ object.get_absolute_url }}> + ----- @@ -10,10 +10,10 @@ You're getting this email because you signed up for Scott Gilbertson's (luxagraf)[https://luxagraf.net/] photo newsletter, -*Range* [https://luxagraf.net/newsletter/range/] +*Range* [https://luxagraf.net/range/] -If you're new, you can explore past letters here: [https://luxagraf.net/newsletter/range/] +If you're new, you can explore past letters here: [https://luxagraf.net/range/] You can always: Unsubscribe [https://luxagraf.net{{subscriber.unsubscribe_activate_url}}] instantly. -[https://luxagraf.net/] ✪ [https://luxagraf.net/newsletter/range/] +[https://luxagraf.net/] ✪ [https://luxagraf.net/range/] diff --git a/app/lttr/templates/lttr/friends_detail.html b/app/lttr/templates/lttr/friends_detail.html deleted file mode 100644 index 5a8c92d..0000000 --- a/app/lttr/templates/lttr/friends_detail.html +++ /dev/null @@ -1,175 +0,0 @@ -{% extends 'base.html' %} -{% load typogrify_tags %} -{% load get_image_by_size %} -{%block htmlclass%}{%endblock%} -{% block sitename %} - - {{object.title|safe}} by Scott Gilbertson - {%endblock%} - - {%block extrahead%} - - - - - - - - - - - - - - - - - - -{%endblock%} -{%block bodyid%}id="home" class="friends"{%endblock%} -{% block breadcrumbs %} -{% endblock %} -{% block primary %} -
-
- {%with image=object.featured_image%} - {{image.alt}} photographed by {% if image.photo_credit_source %}{{image.photo_credit_source}}{%else%}luxagraf{%endif%} - {%endwith%} -
-
-
-

{{object.title|smartypants|safe}}

- -
-
- {{object.body_html|safe|smartypants}} -
- {%if object.books.all %}
- - {% with object.get_next_published as next %} - {% with object.get_previous_published as prev %} - {%endwith%}{%endwith%} - - {% if object.related.all %}
- -
{%endif%} -
-{% endblock %} - -{% block js %}{% comment %} {% endcomment%}{% endblock%} diff --git a/app/lttr/templates/lttr/friends_list.html b/app/lttr/templates/lttr/friends_list.html deleted file mode 100644 index 3318a08..0000000 --- a/app/lttr/templates/lttr/friends_list.html +++ /dev/null @@ -1,29 +0,0 @@ -{% extends 'base.html' %} -{% load typogrify_tags %} - -{% block pagetitle %}Luxagraf | Friends of a Long Year {% endblock %} -{% block metadescription %}An infrequesnt mailing list about living outdoors, travel, literature, music, vintage vehicles, and other ephemera.{% endblock %} -{% block breadcrumbs %}{% include "lib/breadcrumbs.html" with breadcrumbs=breadcrumbs %}{% endblock %} -{% block primary %} -
-
-

Join the Friends of a Long Year.

- -

Say what?

-

Friends of a Long Year is a monthly letter about living outdoors, travel, literature, music, vintage vehicles, and other ephemera. It's written in the spirit of Mary Austin. And Mike’s emails. A more detailed explaination can be found here.

-

Unsubscribing is easy. It's all self-hosted and designed to respect your privacy.

-

There's also the Range newsletter if you'd like a photo in your inbox once a week.

-
-

Letters

- -
-{%endblock%} diff --git a/app/lttr/templates/lttr/subscribed.html b/app/lttr/templates/lttr/subscribed.html index 7139d24..43278cf 100644 --- a/app/lttr/templates/lttr/subscribed.html +++ b/app/lttr/templates/lttr/subscribed.html @@ -17,8 +17,8 @@
-

Thanks for joining.

-

Check your email for a link to confirm your subscription

+

Thanks, You're Almost There.

+

Check your email for a link to confirm your subscription

{%endblock%} diff --git a/app/lttr/templates/lttr/unsubscribe.html b/app/lttr/templates/lttr/unsubscribe.html index d3f17e0..993ea9f 100644 --- a/app/lttr/templates/lttr/unsubscribe.html +++ b/app/lttr/templates/lttr/unsubscribe.html @@ -4,10 +4,17 @@ {% block pagetitle %}Luxagraf | Friends of a Long Year {% endblock %} {% block metadescription %}An infrequesnt mailing list about travel, photography, tools, walking, the natural world and other ephemera.{% endblock %} -{% block primary %} +{% block primary %} +

You're unsubscribed, so long friend

diff --git a/app/lttr/urls.py b/app/lttr/urls.py index b4485d2..abeac11 100644 --- a/app/lttr/urls.py +++ b/app/lttr/urls.py @@ -6,32 +6,17 @@ app_name = "lttr" urlpatterns = [ path( - r'feed.xml', - views.NewsletterRSSFeedView(), - name="feed" - ), - path( - 'unsubscribe/', + '/unsubscribe/', views.UnsubscribeRequestView.as_view(), name='newsletter_unsubscribe' ), path( - r'/', - views.NewsletterMailingDetail.as_view(), - name="detail" - ), - path( - r'subscribe/', + r'/subscribe/', views.NewsletterSubscribeView.as_view(), name="subscribe" ), path( - r'', - views.NewsletterListView.as_view(), - name="list" - ), - path( - 'activate//', + '/activate//', views.ConfirmSubscriptionView.as_view(), name='newsletter_activate' ), path( @@ -39,15 +24,4 @@ urlpatterns = [ views.NewsletterSubscribedView.as_view(), name="subscribed" ), - path( - r'', - views.NewsletterListView.as_view(), - {'page': 1}, - name="list" - ), - path( - r'', - views.NewsletterOptionsView.as_view(), - name="newsletters" - ), ] diff --git a/app/lttr/views.py b/app/lttr/views.py index 6a9cfd8..7f094c6 100644 --- a/app/lttr/views.py +++ b/app/lttr/views.py @@ -13,49 +13,16 @@ from django.urls import reverse, reverse_lazy from utils.views import PaginatedListView, LuxDetailView from smtplib import SMTPException -from .models import NewsletterMailing, Subscriber, Newsletter +from .models import OldNewsletterMailing, Subscriber, Newsletter from .forms import SubscribeRequestForm, UpdateForm ACTIONS = ('subscribe', 'unsubscribe', 'update') -class NewsletterMailingDetail(LuxDetailView): - model = NewsletterMailing - slug_field = "slug" - slug_url_kwarg = 'mailing' - - def get_queryset(self): - queryset = super(NewsletterMailingDetail, self).get_queryset() - return queryset.filter(issue=self.kwargs['issue']) - - def get_template_names(self): - obj = self.get_object() - return ["lttr/%s_detail.html" % obj.newsletter.slug, 'post_detail.html'] - - class NewsletterSubscribedView(TemplateView): template_name = "lttr/subscribed.html" -class NewsletterListView(ListView): - """ - Return a list of Newsletter posts in reverse chronological order - """ - model = NewsletterMailing - - def get_template_names(self): - return ["lttr/%s_list.html" % self.kwargs['slug'], 'newsletter_list.html'] - - def get_queryset(self): - queryset = super(NewsletterListView, self).get_queryset() - return queryset.filter(newsletter__slug=self.kwargs['slug']).order_by('-pub_date') - - def get_context_data(self, **kwargs): - context = super(NewsletterListView, self).get_context_data(**kwargs) - context['breadcrumbs'] = [self.kwargs['slug'],] - return context - - class NewsletterOptionsView(ListView): model = Newsletter @@ -137,19 +104,3 @@ class UnsubscribeRequestView(DetailView): context['subscriber'] = self.get_object() context['newsletter'] = self.kwargs['slug'] return context - -class NewsletterRSSFeedView(Feed): - title = "Luxagraf: Range, A Weekly Photo" - link = "/newsletter/range/" - description = "Latest Range Newsletter" - description_template = 'feeds/blog_description.html' - - def items(self): - return NewsletterMailing.objects.filter(newsletter__slug='ranger',status__exact=1) - - def item_pubdate(self, item): - """ - Takes an item, as returned by items(), and returns the item's - pubdate. - """ - diff --git a/app/posts/build.py b/app/posts/build.py index 9a7e2c1..b49b925 100644 --- a/app/posts/build.py +++ b/app/posts/build.py @@ -18,6 +18,7 @@ class BuildSrc(BuildNew): paginate_by=50 ) self.build_detail_view() + self.build_feed("src:feed") class BuildGuide(BuildNew): @@ -121,3 +122,31 @@ class BuildEssays(BuildNew): paginate_by=50 ) self.build_detail_view() + + +class BuildRange(BuildNew): + + def get_model_queryset(self): + return self.model.objects.filter(post_type=PostType.RANGE).filter(status__exact=1).order_by('-pub_date') + + def build(self): + self.build_list_view( + base_path=reverse("range:range-list"), + paginate_by=30 + ) + self.build_detail_view() + self.build_feed("range:feed") + + +class BuildFriends(BuildNew): + + def get_model_queryset(self): + return self.model.objects.filter(post_type=PostType.FRIENDS).filter(status__exact=1).order_by('-pub_date') + + def build(self): + self.build_list_view( + base_path=reverse("friends:friends-list"), + paginate_by=30 + ) + self.build_detail_view() + self.build_feed("friends:feed") diff --git a/app/posts/models.py b/app/posts/models.py index 6adae3b..21dd6d5 100644 --- a/app/posts/models.py +++ b/app/posts/models.py @@ -32,8 +32,6 @@ from books.models import Book from taxonomy.models import TaggedItems, Category from utils.util import render_images, render_products, parse_video, markdown_to_html, extract_main_image -from lttr.models import Newsletter - def get_upload_path(self, filename): return "images/post-images/%s/%s" % (datetime.datetime.today().strftime("%Y"), filename) @@ -115,7 +113,7 @@ class Post(models.Model): if self.post_type == PostType.JRNL: return reverse('jrnl:detail', kwargs={"year": self.pub_date.year, "month": self.pub_date.strftime("%m"), "slug": self.slug}) if self.post_type == PostType.RANGE: - return reverse('range:detail', kwargs={"issue": self.issue, "slug": self.slug}) + return reverse('range:range-detail', kwargs={"issue": self.get_issue_str(), "slug": self.slug}) if self.post_type == PostType.FRIENDS: return reverse('friends:friends-detail', kwargs={"issue": self.get_issue_str(), "slug": self.slug}) @@ -241,14 +239,6 @@ class PostModerator(CommentModerator): return True moderator.register(Post, PostModerator) -#class PostMailing(models.Model): -# newsletter = models.ForeignKey(Newsletter, null=True, on_delete=models.SET_NULL) -# post = models.ForeignKey(Post, null=True, on_delete=models.SET_NULL) -# body_email_html = models.TextField(blank=True) -# issue = models.PositiveIntegerField() -# date_sent = models.DateTimeField(blank=True, auto_now_add=True, editable=False) - - @receiver(comment_was_posted, sender=Comment) def cache_gravatar(sender, comment, **kwargs): gravatar_exists = has_gravatar(comment.email) diff --git a/app/posts/urls/friends_urls.py b/app/posts/urls/friends_urls.py index 5998d08..b7f7608 100644 --- a/app/posts/urls/friends_urls.py +++ b/app/posts/urls/friends_urls.py @@ -6,6 +6,11 @@ from ..views import friends_views as views app_name = "range" urlpatterns = [ + path( + r'feed.xml', + views.FriendsRSSFeedView(), + name="feed" + ), path( r'/', views.FriendsDetailView.as_view(), @@ -15,6 +20,6 @@ urlpatterns = [ r'', views.FriendsListView.as_view(), {'page':1}, - name="friends-base" + name="friends-list" ), ] diff --git a/app/posts/urls/range_urls.py b/app/posts/urls/range_urls.py index 7b29569..16655d6 100644 --- a/app/posts/urls/range_urls.py +++ b/app/posts/urls/range_urls.py @@ -7,14 +7,19 @@ app_name = "range" urlpatterns = [ path( - r'', + r'feed.xml', + views.RangeRSSFeedView(), + name="feed" + ), + path( + r'/', views.RangeDetailView.as_view(), - name="detail" + name="range-detail" ), path( r'', views.RangeListView.as_view(), {'page':1}, - name="range-base" + name="range-list" ), ] diff --git a/app/posts/views/friends_views.py b/app/posts/views/friends_views.py index dd4dac2..3d6ea8d 100644 --- a/app/posts/views/friends_views.py +++ b/app/posts/views/friends_views.py @@ -37,3 +37,18 @@ class FriendsListView(PaginatedListView): return context +class FriendsRSSFeedView(Feed): + title = "Friends of a Long Year" + link = "/range/" + description = "Friends of a Long Year: A monthly newsletter" + description_template = 'feeds/blog_description.html' + + def items(self): + return Post.objects.filter(status__exact=1).filter(post_type=PostType.FRIENDS).order_by('-pub_date')[:10] + + def item_pubdate(self, item): + """ + Takes an item, as returned by items(), and returns the item's + pubdate. + """ + return item.pub_date diff --git a/app/posts/views/range_views.py b/app/posts/views/range_views.py index 989134d..0a3a564 100644 --- a/app/posts/views/range_views.py +++ b/app/posts/views/range_views.py @@ -37,3 +37,18 @@ class RangeListView(PaginatedListView): return context +class RangeRSSFeedView(Feed): + title = "Range: A weekly photo, developed" + link = "/range/" + description = "Range: A weekly photo, developed" + description_template = 'feeds/blog_description.html' + + def items(self): + return Post.objects.filter(status__exact=1).filter(post_type=PostType.RANGE).order_by('-pub_date')[:10] + + def item_pubdate(self, item): + """ + Takes an item, as returned by items(), and returns the item's + pubdate. + """ + return item.pub_date -- cgit v1.2.3-70-g09d2