Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions blog/migrations/0009_private.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.5 on 2017-10-09 02:49
from __future__ import unicode_literals

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('blog', '0008_entry_tweet_html'),
]

operations = [
migrations.AddField(
model_name='blogmark',
name='private',
field=models.BooleanField(default=False),
),
migrations.AddField(
model_name='entry',
name='private',
field=models.BooleanField(default=False),
),
migrations.AddField(
model_name='quotation',
name='private',
field=models.BooleanField(default=False),
),
]
1 change: 1 addition & 0 deletions blog/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ class BaseModel(models.Model):
slug = models.SlugField(max_length=64)
metadata = JSONField(blank=True, default={})
search_document = SearchVectorField(null=True)
private = models.BooleanField(default=False)

def created_unixtimestamp(self):
return arrow.get(self.created).timestamp
Expand Down
9 changes: 9 additions & 0 deletions blog/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@ def test_entry(self):
self.assertTemplateUsed(response, 'entry.html')
self.assertEqual(response.context['entry'].pk, entry.pk)

def test_private_items_404(self):
for obj in (
EntryFactory(private=True),
BlogmarkFactory(private=True),
QuotationFactory(private=True),
):
response = self.client.get(obj.get_absolute_url())
self.assertEqual(response.status_code, 404)

def test_blogmark(self):
blogmark = BlogmarkFactory()
response = self.client.get(blogmark.get_absolute_url())
Expand Down
3 changes: 2 additions & 1 deletion blog/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ def archive_item(request, year, month, day, slug):
created__year=int(year),
created__month=MONTHS_3_REV[month.lower()],
created__day=int(day),
slug=slug
slug=slug,
private=False,
)
except Http404:
continue
Expand Down