Skip to content

Commit 9e1a3bc

Browse files
committed
Reinstate originalish directory structure
1 parent 25a14af commit 9e1a3bc

File tree

6 files changed

+12
-8
lines changed

6 files changed

+12
-8
lines changed
File renamed without changes.
File renamed without changes.
File renamed without changes.

pythonineducation/migrations/0001_initial.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -*- coding: utf-8 -*-
2-
# Generated by Django 1.9.7 on 2016-07-16 22:55
2+
# Generated by Django 1.9.7 on 2016-07-28 18:06
33
from __future__ import unicode_literals
44

55
from django.db import migrations, models
@@ -21,6 +21,8 @@ class Migration(migrations.Migration):
2121
('content', models.TextField()),
2222
('content_format', models.CharField(max_length=255)),
2323
('title', models.CharField(max_length=255)),
24+
('slug', models.CharField(max_length=255)),
25+
('language', models.CharField(max_length=255)),
2426
],
2527
options={
2628
'abstract': False,

pythonineducation/models.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,12 @@
44

55
class Page(ModelWithContent):
66
title = models.CharField(max_length=255)
7+
slug = models.CharField(max_length=255)
8+
language = models.CharField(max_length=255)
79

8-
def language(self):
9-
return self.key.split('-', 1)[0]
10+
dump_path_template = 'content/[language]/[slug].[content_format]'
1011

11-
def slug(self):
12-
return self.key.split('-', 1)[1]
12+
key_field_names = ['language', 'slug']
13+
14+
def __str__(self):
15+
return '{}/{}'.format(self.language, self.slug)

pythonineducation/views.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@
44

55

66
def page_view(request, language='en', slug='home'):
7-
key = '{}-{}'.format(language, slug)
8-
page = get_object_or_404(Page, key=key)
7+
page = get_object_or_404(Page, language=language, slug=slug)
98

10-
assert page.content_format == '.md', 'Markdown is only supported format'
9+
assert page.content_format == 'md', 'Markdown is only supported format'
1110

1211
template = 'pythonineducation/page_{}.html'.format(language)
1312

0 commit comments

Comments
 (0)