diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/posts/migrations/0019_auto_20210323_2155.py | 23 | ||||
-rw-r--r-- | app/posts/models.py | 12 | ||||
-rw-r--r-- | app/posts/urls/friends_urls.py | 2 |
3 files changed, 35 insertions, 2 deletions
diff --git a/app/posts/migrations/0019_auto_20210323_2155.py b/app/posts/migrations/0019_auto_20210323_2155.py new file mode 100644 index 0000000..0f3af44 --- /dev/null +++ b/app/posts/migrations/0019_auto_20210323_2155.py @@ -0,0 +1,23 @@ +# Generated by Django 3.1 on 2021-03-23 21:55 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('posts', '0018_auto_20210128_1708'), + ] + + operations = [ + migrations.AddField( + model_name='post', + name='issue', + field=models.PositiveIntegerField(null=True), + ), + migrations.AlterField( + model_name='post', + name='post_type', + field=models.IntegerField(choices=[(0, 'range'), (1, 'review'), (2, 'essay'), (3, 'src'), (4, 'jrnl'), (5, 'field note'), (6, 'guide'), (7, 'friends')], default=4), + ), + ] diff --git a/app/posts/models.py b/app/posts/models.py index cc6e1d5..6adae3b 100644 --- a/app/posts/models.py +++ b/app/posts/models.py @@ -115,7 +115,9 @@ 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={"slug": self.slug}) + return reverse('range:detail', kwargs={"issue": self.issue, "slug": self.slug}) + if self.post_type == PostType.FRIENDS: + return reverse('friends:friends-detail', kwargs={"issue": self.get_issue_str(), "slug": self.slug}) def comment_period_open(self): return self.enable_comments and datetime.datetime.today() - datetime.timedelta(30) <= self.pub_date @@ -126,6 +128,14 @@ class Post(models.Model): def get_content_type(self): return ContentType.objects.get(app_label="posts", model="post") + 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 + @property def get_previous_published(self): return self.get_previous_by_pub_date(status__exact=1,post_type=self.post_type) diff --git a/app/posts/urls/friends_urls.py b/app/posts/urls/friends_urls.py index 2e2d220..5998d08 100644 --- a/app/posts/urls/friends_urls.py +++ b/app/posts/urls/friends_urls.py @@ -7,7 +7,7 @@ app_name = "range" urlpatterns = [ path( - r'<str:slug>', + r'<int:issue>/<str:slug>', views.FriendsDetailView.as_view(), name="friends-detail" ), |