Browse Source

Remove flake8, run black on everything

Debian 9 can't support black out of the box due to a Python 3.6
requirement.  I'm still opting to use it on the codebase, and at some
point down the road it can be integrated into CI and etc.

Since flake8 conflicts with black, it is being removed.
pull/326/head
parent
commit
0cfefb7032
Signed by: Hristos N. Triantafillou <me@hristos.triantafillou.us> GPG Key ID: 5FC7664AD47AA1C5
71 changed files with 2977 additions and 1829 deletions
  1. 0
    1
      Makefile
  2. 34
    32
      bin/seed_db.py
  3. 6
    6
      momw/chroniko/__init__.py
  4. 1
    1
      momw/chroniko/apps.py
  5. 376
    250
      momw/chroniko/data_seeds/blog.py
  6. 11
    7
      momw/chroniko/feeds.py
  7. 11
    9
      momw/chroniko/forms.py
  8. 129
    46
      momw/chroniko/migrations/0001_initial.py
  9. 40
    31
      momw/chroniko/models.py
  10. 90
    64
      momw/chroniko/tests.py
  11. 54
    35
      momw/chroniko/urls.py
  12. 143
    93
      momw/chroniko/views.py
  13. 2
    2
      momw/media/__init__.py
  14. 1
    1
      momw/media/apps.py
  15. 37
    13
      momw/media/data_seeds/media.py
  16. 2
    2
      momw/media/feeds.py
  17. 7
    7
      momw/media/forms.py
  18. 45
    15
      momw/media/migrations/0001_initial.py
  19. 3
    6
      momw/media/migrations/0002_auto_20171110_1604.py
  20. 10
    13
      momw/media/migrations/0003_auto_20180107_1358.py
  21. 8
    7
      momw/media/migrations/0004_auto_20190504_2044.py
  22. 34
    21
      momw/media/models.py
  23. 29
    18
      momw/media/tests.py
  24. 25
    14
      momw/media/urls.py
  25. 52
    32
      momw/media/views.py
  26. 33
    21
      momw/momw/cfg.py
  27. 1
    2
      momw/momw/context_processors.py
  28. 540
    255
      momw/momw/data_seeds/media.py
  29. 173
    118
      momw/momw/data_seeds/test_mod_data.py
  30. 1
    2
      momw/momw/errors.py
  31. 1
    1
      momw/momw/feeds.py
  32. 38
    23
      momw/momw/forms.py
  33. 8
    4
      momw/momw/managers.py
  34. 167
    54
      momw/momw/migrations/0001_initial.py
  35. 20
    14
      momw/momw/migrations/0002_auto_20180413_1444.py
  36. 5
    7
      momw/momw/migrations/0003_tag_description.py
  37. 10
    8
      momw/momw/migrations/0004_auto_20180714_1729.py
  38. 7
    7
      momw/momw/migrations/0005_auto_20180715_1516.py
  39. 2
    9
      momw/momw/migrations/0006_remove_mod_plugin_order.py
  40. 8
    7
      momw/momw/migrations/0007_mod_has_bsa.py
  41. 13
    7
      momw/momw/migrations/0008_mod_compat.py
  42. 30
    15
      momw/momw/migrations/0009_modissue.py
  43. 4
    6
      momw/momw/migrations/0010_mod_needs_cleaning.py
  44. 3
    7
      momw/momw/migrations/0011_mod_extra_cfg.py
  45. 3
    7
      momw/momw/migrations/0012_mod_extra_cfg_raw.py
  46. 7
    7
      momw/momw/migrations/0013_mod_depends_on.py
  47. 7
    7
      momw/momw/migrations/0014_mod_folder_paths.py
  48. 80
    51
      momw/momw/models.py
  49. 85
    73
      momw/momw/settings.py
  50. 36
    36
      momw/momw/sitemaps.py
  51. 87
    28
      momw/momw/tests.py
  52. 132
    76
      momw/momw/urls.py
  53. 170
    129
      momw/momw/views.py
  54. 1
    1
      momw/search/__init__.py
  55. 1
    1
      momw/search/apps.py
  56. 1
    3
      momw/search/urls.py
  57. 58
    46
      momw/search/views.py
  58. 1
    1
      momw/utilz/__init__.py
  59. 1
    1
      momw/utilz/apps.py
  60. 13
    10
      momw/utilz/cache.py
  61. 11
    11
      momw/utilz/context_processors.py
  62. 12
    5
      momw/utilz/forms.py
  63. 1
    1
      momw/utilz/git.py
  64. 2
    2
      momw/utilz/management/commands/printurls.py
  65. 2
    2
      momw/utilz/management/commands/warmcache.py
  66. 2
    5
      momw/utilz/middleware.py
  67. 2
    4
      momw/utilz/queries.py
  68. 3
    3
      momw/utilz/templatetags/extra_tags.py
  69. 1
    1
      momw/utilz/templatetags/filterz.py
  70. 27
    10
      momw/utilz/tests.py
  71. 17
    15
      momw/utilz/views.py

+ 0
- 1
Makefile View File

@@ -61,7 +61,6 @@ start-xvfb-ci:
61 61
 
62 62
 test:
63 63
 ifndef SKIPTESTS
64
-	find $(proj_dir) -type f -name "*.py" | xargs flake8
65 64
 	sudo -u momwdb dropdb test_momwdb || echo test db is gone
66 65
 	$(proj_dir)/momw/manage.py test chroniko.tests momw.tests utilz.tests
67 66
 endif

+ 34
- 32
bin/seed_db.py View File

@@ -2,16 +2,21 @@
2 2
 import sys
3 3
 import os
4 4
 import pendulum
5
+
5 6
 BASE_DIR = os.path.dirname(os.path.dirname(__file__))
6
-sys.path.append(BASE_DIR + '/momw')
7
-os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'momw.settings')
7
+sys.path.append(BASE_DIR + "/momw")
8
+os.environ.setdefault("DJANGO_SETTINGS_MODULE", "momw.settings")
8 9
 import django
10
+
9 11
 django.setup()
10 12
 from django.conf import settings
11 13
 from django.contrib.auth import get_user_model
12 14
 from django.contrib.sites.models import Site
13
-from momw.data_seeds.blog import blog_category_factory, blog_tag_factory, \
14
-    blog_entry_factory
15
+from momw.data_seeds.blog import (
16
+    blog_category_factory,
17
+    blog_tag_factory,
18
+    blog_entry_factory,
19
+)
15 20
 from momw.data_seeds.media import media_factory
16 21
 from momw.data_seeds.mod_data import mod_cats, mods, mod_tags
17 22
 
@@ -22,20 +27,16 @@ User = get_user_model()
22 27
 
23 28
 def site_factory():
24 29
     s1 = Site.objects.get(pk=1)
25
-    s1.domain = '0.0.0.0:8666'
26
-    s1.name = 'Modding-OpenMW.com'
30
+    s1.domain = "0.0.0.0:8666"
31
+    s1.name = "Modding-OpenMW.com"
27 32
     s1.save()
28 33
 
29 34
     # For testing from my phone.
30
-    site2 = {
31
-        "domain": "192.168.1.100:8666",
32
-        "name": "Modding-OpenMW.com"}
35
+    site2 = {"domain": "192.168.1.100:8666", "name": "Modding-OpenMW.com"}
33 36
     s2 = Site(**site2)
34 37
     s2.save()
35 38
 
36
-    site3 = {
37
-        "domain": "localhost:8666",
38
-        "name": "Modding-OpenMW.com"}
39
+    site3 = {"domain": "localhost:8666", "name": "Modding-OpenMW.com"}
39 40
     s3 = Site(**site3)
40 41
     s3.save()
41 42
 
@@ -43,11 +44,12 @@ def site_factory():
43 44
 def user_factory():
44 45
     """Creates user accounts!"""
45 46
     admin = {
46
-        'username': 'MaiqTheAdmin',
47
-        'password': 'pbkdf2_sha256$30000$sq1bF20gppnd$OLo3HeVIpZXD9obg4uFU3SjbHQE4kCAV0Pmgo6cqNrw=',
48
-        'first_name': "M'aiq",
49
-        'last_name': 'The Admin',
50
-        'email': 'admin@modding-openmw.com'}
47
+        "username": "MaiqTheAdmin",
48
+        "password": "pbkdf2_sha256$30000$sq1bF20gppnd$OLo3HeVIpZXD9obg4uFU3SjbHQE4kCAV0Pmgo6cqNrw=",
49
+        "first_name": "M'aiq",
50
+        "last_name": "The Admin",
51
+        "email": "admin@modding-openmw.com",
52
+    }
51 53
     a = User(**admin)
52 54
     a.is_staff = True
53 55
     a.is_superuser = True
@@ -56,26 +58,26 @@ def user_factory():
56 58
 
57 59
 def main():
58 60
     def _run(arg, func, earg=None):
59
-        if '--{}'.format(arg) in sys.argv or '--full' in sys.argv:
60
-            print('Running {}() ...'.format(func.__name__), end=' ')
61
+        if "--{}".format(arg) in sys.argv or "--full" in sys.argv:
62
+            print("Running {}() ...".format(func.__name__), end=" ")
61 63
             if earg:
62 64
                 func(earg)
63 65
             else:
64 66
                 func()
65
-            print('Done!')
67
+            print("Done!")
66 68
 
67
-    print('... Starting {} db seed ...'.format(settings.PROJECT_NAME.upper()))
68
-    _run('site', site_factory)
69
-    _run('user', user_factory)
70
-    _run('blog-cat', blog_category_factory)
71
-    _run('blog-tag', blog_tag_factory)
72
-    _run('blog-entry', blog_entry_factory)
73
-    _run('media', media_factory)
74
-    _run('mod-cat', mod_cats)
75
-    _run('mod-tag', mod_tags)
76
-    _run('mods', mods, earg=User.objects.get(pk=1))
77
-    print('... Finished {} db seed!'.format(settings.PROJECT_NAME.upper()))
69
+    print("... Starting {} db seed ...".format(settings.PROJECT_NAME.upper()))
70
+    _run("site", site_factory)
71
+    _run("user", user_factory)
72
+    _run("blog-cat", blog_category_factory)
73
+    _run("blog-tag", blog_tag_factory)
74
+    _run("blog-entry", blog_entry_factory)
75
+    _run("media", media_factory)
76
+    _run("mod-cat", mod_cats)
77
+    _run("mod-tag", mod_tags)
78
+    _run("mods", mods, earg=User.objects.get(pk=1))
79
+    print("... Finished {} db seed!".format(settings.PROJECT_NAME.upper()))
78 80
 
79 81
 
80
-if __name__ == '__main__':
82
+if __name__ == "__main__":
81 83
     main()

+ 6
- 6
momw/chroniko/__init__.py View File

@@ -1,9 +1,9 @@
1 1
 # Some constants for the blog
2 2
 # TODO: de-hard code the app name
3
-ADD_CATEGORY_PERM = 'chroniko.add_blogcategory'
4
-ADD_ENTRY_PERM = 'chroniko.add_blogentry'
5
-CHANGE_CATEGORY_PERM = 'chroniko.change_blogcategory'
6
-CHANGE_ENTRY_PERM = 'chroniko.change_blogentry'
7
-ENTRY_DATE_FIELD = 'date_added'
3
+ADD_CATEGORY_PERM = "chroniko.add_blogcategory"
4
+ADD_ENTRY_PERM = "chroniko.add_blogentry"
5
+CHANGE_CATEGORY_PERM = "chroniko.change_blogcategory"
6
+CHANGE_ENTRY_PERM = "chroniko.change_blogentry"
7
+ENTRY_DATE_FIELD = "date_added"
8 8
 
9
-default_app_config = 'chroniko.apps.ChronikoConfig'
9
+default_app_config = "chroniko.apps.ChronikoConfig"

+ 1
- 1
momw/chroniko/apps.py View File

@@ -2,5 +2,5 @@ from django.apps import AppConfig
2 2
 
3 3
 
4 4
 class ChronikoConfig(AppConfig):
5
-    name = 'chroniko'
5
+    name = "chroniko"
6 6
     verbose_name = "Chroniko Blogging Engine"

+ 376
- 250
momw/chroniko/data_seeds/blog.py View File

@@ -17,8 +17,7 @@ def generate_category(title, slug, desc):
17 17
     return c
18 18
 
19 19
 
20
-def generate_entry(body, date_added, slug, status,
21
-                   title, author, category, excerpt=''):
20
+def generate_entry(body, date_added, slug, status, title, author, category, excerpt=""):
22 21
     """
23 22
        'body': rikeripsum.generate_paragraph(100),
24 23
         'date_added': datetime.strptime('2010-12-18 14:34:34 -0500', datetime_format),
@@ -28,71 +27,118 @@ def generate_entry(body, date_added, slug, status,
28 27
         'author': u,
29 28
         'category': cat1
30 29
     """
31
-    e = BlogEntry.objects.create(body=body, date_added=date_added, slug=slug,
32
-                                 status=status, title=title, author=author,
33
-                                 category=category, excerpt=excerpt)
30
+    e = BlogEntry.objects.create(
31
+        body=body,
32
+        date_added=date_added,
33
+        slug=slug,
34
+        status=status,
35
+        title=title,
36
+        author=author,
37
+        category=category,
38
+        excerpt=excerpt,
39
+    )
34 40
     e.save()
35 41
     return e
36 42
 
37 43
 
38 44
 def blog_category_factory():
39
-    BlogCategory(title='Category One', slug='category-one', description=rikeripsum.generate_paragraph(10)).save()
40
-    BlogCategory(title='Category Two', slug='category-two', description=rikeripsum.generate_paragraph(10)).save()
41
-    BlogCategory(title='Category Three', slug='category-three', description=rikeripsum.generate_paragraph(10)).save()
42
-    BlogCategory(title='Category Four', slug='category-four', description=rikeripsum.generate_paragraph(10)).save()
43
-    BlogCategory(title='Category Five', slug='category-five', description=rikeripsum.generate_paragraph(10)).save()
44
-    BlogCategory(title='Category Six', slug='category-six', description=rikeripsum.generate_paragraph(10)).save()
45
-    BlogCategory(title='Category Seven', slug='category-seven', description=rikeripsum.generate_paragraph(10)).save()
46
-    BlogCategory(title='Category Eight', slug='category-eight', description=rikeripsum.generate_paragraph(10)).save()
47
-    BlogCategory(title='Category Nine', slug='category-nine', description=rikeripsum.generate_paragraph(10)).save()
48
-    BlogCategory(title='Category Ten', slug='category-ten', description=rikeripsum.generate_paragraph(10)).save()
45
+    BlogCategory(
46
+        title="Category One",
47
+        slug="category-one",
48
+        description=rikeripsum.generate_paragraph(10),
49
+    ).save()
50
+    BlogCategory(
51
+        title="Category Two",
52
+        slug="category-two",
53
+        description=rikeripsum.generate_paragraph(10),
54
+    ).save()
55
+    BlogCategory(
56
+        title="Category Three",
57
+        slug="category-three",
58
+        description=rikeripsum.generate_paragraph(10),
59
+    ).save()
60
+    BlogCategory(
61
+        title="Category Four",
62
+        slug="category-four",
63
+        description=rikeripsum.generate_paragraph(10),
64
+    ).save()
65
+    BlogCategory(
66
+        title="Category Five",
67
+        slug="category-five",
68
+        description=rikeripsum.generate_paragraph(10),
69
+    ).save()
70
+    BlogCategory(
71
+        title="Category Six",
72
+        slug="category-six",
73
+        description=rikeripsum.generate_paragraph(10),
74
+    ).save()
75
+    BlogCategory(
76
+        title="Category Seven",
77
+        slug="category-seven",
78
+        description=rikeripsum.generate_paragraph(10),
79
+    ).save()
80
+    BlogCategory(
81
+        title="Category Eight",
82
+        slug="category-eight",
83
+        description=rikeripsum.generate_paragraph(10),
84
+    ).save()
85
+    BlogCategory(
86
+        title="Category Nine",
87
+        slug="category-nine",
88
+        description=rikeripsum.generate_paragraph(10),
89
+    ).save()
90
+    BlogCategory(
91
+        title="Category Ten",
92
+        slug="category-ten",
93
+        description=rikeripsum.generate_paragraph(10),
94
+    ).save()
49 95
 
50 96
 
51 97
 def blog_tag_factory():
52
-    BlogTag(name='Tag1').save()
53
-    BlogTag(name='Tag2').save()
54
-    BlogTag(name='Tag3').save()
55
-    BlogTag(name='Tag4').save()
56
-    BlogTag(name='Tag5').save()
57
-    BlogTag(name='Tag6').save()
58
-    BlogTag(name='Tag7').save()
59
-    BlogTag(name='Tag8').save()
60
-    BlogTag(name='Tag9').save()
61
-    BlogTag(name='Tag10').save()
62
-    BlogTag(name='Tag11').save()
63
-    BlogTag(name='Tag12').save()
64
-    BlogTag(name='Tag13').save()
65
-    BlogTag(name='Tag14').save()
66
-    BlogTag(name='Tag15').save()
67
-    BlogTag(name='Tag16').save()
68
-    BlogTag(name='Tag17').save()
69
-    BlogTag(name='Tag18').save()
70
-    BlogTag(name='Tag19').save()
71
-    BlogTag(name='Tag20').save()
72
-    BlogTag(name='Tag21').save()
73
-    BlogTag(name='Tag22').save()
74
-    BlogTag(name='Tag23').save()
75
-    BlogTag(name='Tag24').save()
76
-    BlogTag(name='Tag25').save()
77
-    BlogTag(name='Tag26').save()
78
-    BlogTag(name='Tag27').save()
79
-    BlogTag(name='Tag28').save()
80
-    BlogTag(name='Tag29').save()
81
-    BlogTag(name='Tag30').save()
82
-    BlogTag(name='Tag31').save()
83
-    BlogTag(name='Tag32').save()
84
-    BlogTag(name='Tag33').save()
85
-    BlogTag(name='Tag34').save()
86
-    BlogTag(name='Tag35').save()
87
-    BlogTag(name='Tag36').save()
88
-    BlogTag(name='Tag37').save()
89
-    BlogTag(name='Tag38').save()
90
-    BlogTag(name='Tag39').save()
91
-    BlogTag(name='Tag40').save()
98
+    BlogTag(name="Tag1").save()
99
+    BlogTag(name="Tag2").save()
100
+    BlogTag(name="Tag3").save()
101
+    BlogTag(name="Tag4").save()
102
+    BlogTag(name="Tag5").save()
103
+    BlogTag(name="Tag6").save()
104
+    BlogTag(name="Tag7").save()
105
+    BlogTag(name="Tag8").save()
106
+    BlogTag(name="Tag9").save()
107
+    BlogTag(name="Tag10").save()
108
+    BlogTag(name="Tag11").save()
109
+    BlogTag(name="Tag12").save()
110
+    BlogTag(name="Tag13").save()
111
+    BlogTag(name="Tag14").save()
112
+    BlogTag(name="Tag15").save()
113
+    BlogTag(name="Tag16").save()
114
+    BlogTag(name="Tag17").save()
115
+    BlogTag(name="Tag18").save()
116
+    BlogTag(name="Tag19").save()
117
+    BlogTag(name="Tag20").save()
118
+    BlogTag(name="Tag21").save()
119
+    BlogTag(name="Tag22").save()
120
+    BlogTag(name="Tag23").save()
121
+    BlogTag(name="Tag24").save()
122
+    BlogTag(name="Tag25").save()
123
+    BlogTag(name="Tag26").save()
124
+    BlogTag(name="Tag27").save()
125
+    BlogTag(name="Tag28").save()
126
+    BlogTag(name="Tag29").save()
127
+    BlogTag(name="Tag30").save()
128
+    BlogTag(name="Tag31").save()
129
+    BlogTag(name="Tag32").save()
130
+    BlogTag(name="Tag33").save()
131
+    BlogTag(name="Tag34").save()
132
+    BlogTag(name="Tag35").save()
133
+    BlogTag(name="Tag36").save()
134
+    BlogTag(name="Tag37").save()
135
+    BlogTag(name="Tag38").save()
136
+    BlogTag(name="Tag39").save()
137
+    BlogTag(name="Tag40").save()
92 138
 
93 139
 
94 140
 def blog_entry_factory():
95
-    datetime_format = '%Y-%m-%d %H:%M:%S %z'
141
+    datetime_format = "%Y-%m-%d %H:%M:%S %z"
96 142
     entry_content_type = ContentType.objects.get_for_model(BlogEntry)
97 143
     u = User.objects.get(pk=1)
98 144
     cat1 = BlogCategory.objects.get(pk=1)
@@ -146,198 +192,198 @@ def blog_entry_factory():
146 192
     tag39 = BlogTag.objects.get(pk=39)
147 193
     tag40 = BlogTag.objects.get(pk=40)
148 194
     e1 = {
149
-        'body': rikeripsum.generate_paragraph(100),
150
-        'date_added': datetime.strptime('2010-12-18 14:34:34 -0500', datetime_format),
151
-        'slug': 'blog-entry-one',
152
-        'status': 1,
153
-        'title': 'Blog Entry One LIVE',
154
-        'author': u,
155
-        'category': cat1
195
+        "body": rikeripsum.generate_paragraph(100),
196
+        "date_added": datetime.strptime("2010-12-18 14:34:34 -0500", datetime_format),
197
+        "slug": "blog-entry-one",
198
+        "status": 1,
199
+        "title": "Blog Entry One LIVE",
200
+        "author": u,
201
+        "category": cat1,
156 202
     }
157 203
     e2 = {
158
-        'excerpt': rikeripsum.generate_paragraph(5),
159
-        'body': rikeripsum.generate_paragraph(100),
160
-        'date_added': datetime.strptime('2011-01-19 10:34:34 -0500', datetime_format),
161
-        'slug': 'blog-entry-two',
162
-        'status': 2,
163
-        'title': 'Blog Entry Two DRAFT',
164
-        'author': u,
165
-        'category': cat2
204
+        "excerpt": rikeripsum.generate_paragraph(5),
205
+        "body": rikeripsum.generate_paragraph(100),
206
+        "date_added": datetime.strptime("2011-01-19 10:34:34 -0500", datetime_format),
207
+        "slug": "blog-entry-two",
208
+        "status": 2,
209
+        "title": "Blog Entry Two DRAFT",
210
+        "author": u,
211
+        "category": cat2,
166 212
     }
167 213
     e3 = {
168
-        'excerpt': rikeripsum.generate_paragraph(5),
169
-        'body': rikeripsum.generate_paragraph(100),
170
-        'date_added': datetime.strptime('2011-02-22 16:34:34 -0500', datetime_format),
171
-        'slug': 'blog-entry-three',
172
-        'status': 3,
173
-        'title': 'Blog Entry Three HIDDEN',
174
-        'author': u,
175
-        'category': cat3
214
+        "excerpt": rikeripsum.generate_paragraph(5),
215
+        "body": rikeripsum.generate_paragraph(100),
216
+        "date_added": datetime.strptime("2011-02-22 16:34:34 -0500", datetime_format),
217
+        "slug": "blog-entry-three",
218
+        "status": 3,
219
+        "title": "Blog Entry Three HIDDEN",
220
+        "author": u,
221
+        "category": cat3,
176 222
     }
177 223
     e4 = {
178
-        'body': rikeripsum.generate_paragraph(100),
179
-        'date_added': datetime.strptime('2011-02-22 16:34:34 -0500', datetime_format),
180
-        'slug': 'blog-entry-four',
181
-        'status': 1,
182
-        'title': 'Blog Entry Four LIVE',
183
-        'author': u,
184
-        'category': cat4
224
+        "body": rikeripsum.generate_paragraph(100),
225
+        "date_added": datetime.strptime("2011-02-22 16:34:34 -0500", datetime_format),
226
+        "slug": "blog-entry-four",
227
+        "status": 1,
228
+        "title": "Blog Entry Four LIVE",
229
+        "author": u,
230
+        "category": cat4,
185 231
     }
186 232
     e5 = {
187
-        'excerpt': rikeripsum.generate_paragraph(5),
188
-        'body': rikeripsum.generate_paragraph(100),
189
-        'date_added': datetime.strptime('2011-03-04 03:04:34 -0500', datetime_format),
190
-        'slug': 'blog-entry-five',
191
-        'status': 2,
192
-        'title': 'Blog Entry Five DRAFT',
193
-        'author': u,
194
-        'category': cat5
233
+        "excerpt": rikeripsum.generate_paragraph(5),
234
+        "body": rikeripsum.generate_paragraph(100),
235
+        "date_added": datetime.strptime("2011-03-04 03:04:34 -0500", datetime_format),
236
+        "slug": "blog-entry-five",
237
+        "status": 2,
238
+        "title": "Blog Entry Five DRAFT",
239
+        "author": u,
240
+        "category": cat5,
195 241
     }
196 242
     e6 = {
197
-        'excerpt': rikeripsum.generate_paragraph(5),
198
-        'body': rikeripsum.generate_paragraph(100),
199
-        'date_added': datetime.strptime('2011-04-20 04:20:34 -0500', datetime_format),
200
-        'slug': 'blog-entry-six',
201
-        'status': 3,
202
-        'title': 'Blog Entry Six HIDDEN',
203
-        'author': u,
204
-        'category': cat6
243
+        "excerpt": rikeripsum.generate_paragraph(5),
244
+        "body": rikeripsum.generate_paragraph(100),
245
+        "date_added": datetime.strptime("2011-04-20 04:20:34 -0500", datetime_format),
246
+        "slug": "blog-entry-six",
247
+        "status": 3,
248
+        "title": "Blog Entry Six HIDDEN",
249
+        "author": u,
250
+        "category": cat6,
205 251
     }
206 252
     e7 = {
207
-        'body': rikeripsum.generate_paragraph(100),
208
-        'date_added': datetime.strptime('2012-01-01 15:20:34 -0500', datetime_format),
209
-        'slug': 'blog-entry-seven',
210
-        'status': 1,
211
-        'title': 'Blog Entry Seven LIVE',
212
-        'author': u,
213
-        'category': cat7
253
+        "body": rikeripsum.generate_paragraph(100),
254
+        "date_added": datetime.strptime("2012-01-01 15:20:34 -0500", datetime_format),
255
+        "slug": "blog-entry-seven",
256
+        "status": 1,
257
+        "title": "Blog Entry Seven LIVE",
258
+        "author": u,
259
+        "category": cat7,
214 260
     }
215 261
     e8 = {
216
-        'body': rikeripsum.generate_paragraph(100),
217
-        'date_added': datetime.strptime('2012-02-11 15:34:34 -0500', datetime_format),
218
-        'slug': 'blog-entry-eight',
219
-        'status': 1,
220
-        'title': 'Blog Entry Eight LIVE',
221
-        'author': u,
222
-        'category': cat8
262
+        "body": rikeripsum.generate_paragraph(100),
263
+        "date_added": datetime.strptime("2012-02-11 15:34:34 -0500", datetime_format),
264
+        "slug": "blog-entry-eight",
265
+        "status": 1,
266
+        "title": "Blog Entry Eight LIVE",
267
+        "author": u,
268
+        "category": cat8,
223 269
     }
224 270
     e9 = {
225
-        'body': rikeripsum.generate_paragraph(100),
226
-        'date_added': datetime.strptime('2012-02-11 15:34:34 -0500', datetime_format),
227
-        'slug': 'blog-entry-nine',
228
-        'status': 1,
229
-        'title': 'Blog Entry Nine LIVE',
230
-        'author': u,
231
-        'category': cat9
271
+        "body": rikeripsum.generate_paragraph(100),
272
+        "date_added": datetime.strptime("2012-02-11 15:34:34 -0500", datetime_format),
273
+        "slug": "blog-entry-nine",
274
+        "status": 1,
275
+        "title": "Blog Entry Nine LIVE",
276
+        "author": u,
277
+        "category": cat9,
232 278
     }
233 279
     e10 = {
234
-        'body': rikeripsum.generate_paragraph(100),
235
-        'date_added': datetime.strptime('2012-03-04 15:34:34 -0500', datetime_format),
236
-        'slug': 'blog-entry-ten',
237
-        'status': 1,
238
-        'title': 'Blog Entry Ten LIVE',
239
-        'author': u,
240
-        'category': cat10
280
+        "body": rikeripsum.generate_paragraph(100),
281
+        "date_added": datetime.strptime("2012-03-04 15:34:34 -0500", datetime_format),
282
+        "slug": "blog-entry-ten",
283
+        "status": 1,
284
+        "title": "Blog Entry Ten LIVE",
285
+        "author": u,
286
+        "category": cat10,
241 287
     }
242 288
     e11 = {
243
-        'excerpt': rikeripsum.generate_paragraph(5),
244
-        'body': rikeripsum.generate_paragraph(100),
245
-        'date_added': datetime.strptime('2012-04-20 16:20:34 -0500', datetime_format),
246
-        'slug': 'blog-entry-eleven',
247
-        'status': 1,
248
-        'title': 'Blog Entry Eleven LIVE',
249
-        'author': u,
250
-        'category': cat1
289
+        "excerpt": rikeripsum.generate_paragraph(5),
290
+        "body": rikeripsum.generate_paragraph(100),
291
+        "date_added": datetime.strptime("2012-04-20 16:20:34 -0500", datetime_format),
292
+        "slug": "blog-entry-eleven",
293
+        "status": 1,
294
+        "title": "Blog Entry Eleven LIVE",
295
+        "author": u,
296
+        "category": cat1,
251 297
     }
252 298
     e12 = {
253
-        'excerpt': rikeripsum.generate_paragraph(5),
254
-        'body': rikeripsum.generate_paragraph(100),
255
-        'date_added': datetime.strptime('2012-05-06 15:34:34 -0500', datetime_format),
256
-        'slug': 'blog-entry-twelve',
257
-        'status': 1,
258
-        'title': 'Blog Entry Twelve LIVE',
259
-        'author': u,
260
-        'category': cat2
299
+        "excerpt": rikeripsum.generate_paragraph(5),
300
+        "body": rikeripsum.generate_paragraph(100),
301
+        "date_added": datetime.strptime("2012-05-06 15:34:34 -0500", datetime_format),
302
+        "slug": "blog-entry-twelve",
303
+        "status": 1,
304
+        "title": "Blog Entry Twelve LIVE",
305
+        "author": u,
306
+        "category": cat2,
261 307
     }
262 308
     e13 = {
263
-        'excerpt': rikeripsum.generate_paragraph(5),
264
-        'body': rikeripsum.generate_paragraph(100),
265
-        'date_added': datetime.strptime('2012-05-06 15:34:34 -0500', datetime_format),
266
-        'slug': 'blog-entry-thirteen',
267
-        'status': 1,
268
-        'title': 'Blog Entry Thirteen LIVE',
269
-        'author': u,
270
-        'category': cat3
309
+        "excerpt": rikeripsum.generate_paragraph(5),
310
+        "body": rikeripsum.generate_paragraph(100),
311
+        "date_added": datetime.strptime("2012-05-06 15:34:34 -0500", datetime_format),
312
+        "slug": "blog-entry-thirteen",
313
+        "status": 1,
314
+        "title": "Blog Entry Thirteen LIVE",
315
+        "author": u,
316
+        "category": cat3,
271 317
     }
272 318
     e14 = {
273
-        'excerpt': rikeripsum.generate_paragraph(5),
274
-        'body': rikeripsum.generate_paragraph(100),
275
-        'date_added': datetime.strptime('2012-06-30 15:34:34 -0500', datetime_format),
276
-        'slug': 'blog-entry-fourteen',
277
-        'status': 1,
278
-        'title': 'Blog Entry Fourteen LIVE',
279
-        'author': u,
280
-        'category': cat4
319
+        "excerpt": rikeripsum.generate_paragraph(5),
320
+        "body": rikeripsum.generate_paragraph(100),
321
+        "date_added": datetime.strptime("2012-06-30 15:34:34 -0500", datetime_format),
322
+        "slug": "blog-entry-fourteen",
323
+        "status": 1,
324
+        "title": "Blog Entry Fourteen LIVE",
325
+        "author": u,
326
+        "category": cat4,
281 327
     }
282 328
     e15 = {
283
-        'excerpt': rikeripsum.generate_paragraph(5),
284
-        'body': rikeripsum.generate_paragraph(100),
285
-        'date_added': datetime.strptime('2013-03-04 20:34:34 -0500', datetime_format),
286
-        'slug': 'blog-entry-fifteen',
287
-        'status': 1,
288
-        'title': 'Blog Entry Fifteen LIVE',
289
-        'author': u,
290
-        'category': cat5
329
+        "excerpt": rikeripsum.generate_paragraph(5),
330
+        "body": rikeripsum.generate_paragraph(100),
331
+        "date_added": datetime.strptime("2013-03-04 20:34:34 -0500", datetime_format),
332
+        "slug": "blog-entry-fifteen",
333
+        "status": 1,
334
+        "title": "Blog Entry Fifteen LIVE",
335
+        "author": u,
336
+        "category": cat5,
291 337
     }
292 338
     e16 = {
293
-        'excerpt': rikeripsum.generate_paragraph(5),
294
-        'body': rikeripsum.generate_paragraph(100),
295
-        'date_added': datetime.strptime('2013-07-13 20:34:34 -0500', datetime_format),
296
-        'slug': 'blog-entry-sixteen',
297
-        'status': 1,
298
-        'title': 'Blog Entry Sixteen LIVE',
299
-        'author': u,
300
-        'category': cat6
339
+        "excerpt": rikeripsum.generate_paragraph(5),
340
+        "body": rikeripsum.generate_paragraph(100),
341
+        "date_added": datetime.strptime("2013-07-13 20:34:34 -0500", datetime_format),
342
+        "slug": "blog-entry-sixteen",
343
+        "status": 1,
344
+        "title": "Blog Entry Sixteen LIVE",
345
+        "author": u,
346
+        "category": cat6,
301 347
     }
302 348
     e17 = {
303
-        'excerpt': rikeripsum.generate_paragraph(5),
304
-        'body': rikeripsum.generate_paragraph(100),
305
-        'date_added': datetime.strptime('2013-07-14 20:34:34 -0500', datetime_format),
306
-        'slug': 'blog-entry-seventeen',
307
-        'status': 1,
308
-        'title': 'Blog Entry Seventeen LIVE',
309
-        'author': u,
310
-        'category': cat7
349
+        "excerpt": rikeripsum.generate_paragraph(5),
350
+        "body": rikeripsum.generate_paragraph(100),
351
+        "date_added": datetime.strptime("2013-07-14 20:34:34 -0500", datetime_format),
352
+        "slug": "blog-entry-seventeen",
353
+        "status": 1,
354
+        "title": "Blog Entry Seventeen LIVE",
355
+        "author": u,
356
+        "category": cat7,
311 357
     }
312 358
     e18 = {
313
-        'excerpt': rikeripsum.generate_paragraph(5),
314
-        'body': rikeripsum.generate_paragraph(100),
315
-        'date_added': datetime.strptime('2014-03-04 20:34:34 -0500', datetime_format),
316
-        'slug': 'blog-entry-eighteen',
317
-        'status': 1,
318
-        'title': 'Blog Entry Eighteen LIVE',
319
-        'author': u,
320
-        'category': cat8
359
+        "excerpt": rikeripsum.generate_paragraph(5),
360
+        "body": rikeripsum.generate_paragraph(100),
361
+        "date_added": datetime.strptime("2014-03-04 20:34:34 -0500", datetime_format),
362
+        "slug": "blog-entry-eighteen",
363
+        "status": 1,
364
+        "title": "Blog Entry Eighteen LIVE",
365
+        "author": u,
366
+        "category": cat8,
321 367
     }
322 368
     e19 = {
323
-        'excerpt': rikeripsum.generate_paragraph(5),
324
-        'body': rikeripsum.generate_paragraph(100),
325
-        'date_added': datetime.strptime('2014-04-20 20:34:34 -0500', datetime_format),
326
-        'slug': 'blog-entry-nineteen',
327
-        'status': 1,
328
-        'title': 'Blog Entry Nineteen LIVE',
329
-        'author': u,
330
-        'category': cat9
369
+        "excerpt": rikeripsum.generate_paragraph(5),
370
+        "body": rikeripsum.generate_paragraph(100),
371
+        "date_added": datetime.strptime("2014-04-20 20:34:34 -0500", datetime_format),
372
+        "slug": "blog-entry-nineteen",
373
+        "status": 1,
374
+        "title": "Blog Entry Nineteen LIVE",
375
+        "author": u,
376
+        "category": cat9,
331 377
     }
332 378
     e20 = {
333
-        'excerpt': rikeripsum.generate_paragraph(5),
334
-        'body': rikeripsum.generate_paragraph(100),
335
-        'date_added': datetime.strptime('2014-10-10 20:34:34 -0500', datetime_format),
336
-        'slug': 'blog-entry-twenty',
337
-        'status': 1,
338
-        'title': 'Blog Entry Twenty LIVE',
339
-        'author': u,
340
-        'category': cat10
379
+        "excerpt": rikeripsum.generate_paragraph(5),
380
+        "body": rikeripsum.generate_paragraph(100),
381
+        "date_added": datetime.strptime("2014-10-10 20:34:34 -0500", datetime_format),
382
+        "slug": "blog-entry-twenty",
383
+        "status": 1,
384
+        "title": "Blog Entry Twenty LIVE",
385
+        "author": u,
386
+        "category": cat10,
341 387
     }
342 388
     BlogEntry(**e1).save()
343 389
     BlogEntry(**e2).save()
@@ -391,62 +437,142 @@ def blog_entry_factory():
391 437
     entry19 = BlogEntry.objects.get(pk=19)
392 438
     entry20 = BlogEntry.objects.get(pk=20)
393 439
     entry1.tags.add(tag1, tag2)
394
-    TaggedEntry(content_type_id=entry_content_type.id, object_id=entry1.id, tag=tag1).save()
395
-    TaggedEntry(content_type_id=entry_content_type.id, object_id=entry1.id, tag=tag2).save()
440
+    TaggedEntry(
441
+        content_type_id=entry_content_type.id, object_id=entry1.id, tag=tag1
442
+    ).save()
443
+    TaggedEntry(
444
+        content_type_id=entry_content_type.id, object_id=entry1.id, tag=tag2
445
+    ).save()
396 446
     entry2.tags.add(tag3, tag4)
397
-    TaggedEntry(content_type_id=entry_content_type.id, object_id=entry2.id, tag=tag3).save()
398
-    TaggedEntry(content_type_id=entry_content_type.id, object_id=entry2.id, tag=tag4).save()
447
+    TaggedEntry(
448
+        content_type_id=entry_content_type.id, object_id=entry2.id, tag=tag3
449
+    ).save()
450
+    TaggedEntry(
451
+        content_type_id=entry_content_type.id, object_id=entry2.id, tag=tag4
452
+    ).save()
399 453
     entry3.tags.add(tag5, tag6)
400
-    TaggedEntry(content_type_id=entry_content_type.id, object_id=entry3.id, tag=tag5).save()
401
-    TaggedEntry(content_type_id=entry_content_type.id, object_id=entry3.id, tag=tag6).save()
454
+    TaggedEntry(
455
+        content_type_id=entry_content_type.id, object_id=entry3.id, tag=tag5
456
+    ).save()
457
+    TaggedEntry(
458
+        content_type_id=entry_content_type.id, object_id=entry3.id, tag=tag6
459
+    ).save()
402 460
     entry4.tags.add(tag7, tag8)
403
-    TaggedEntry(content_type_id=entry_content_type.id, object_id=entry4.id, tag=tag7).save()
404
-    TaggedEntry(content_type_id=entry_content_type.id, object_id=entry4.id, tag=tag8).save()
461
+    TaggedEntry(
462
+        content_type_id=entry_content_type.id, object_id=entry4.id, tag=tag7
463
+    ).save()
464
+    TaggedEntry(
465
+        content_type_id=entry_content_type.id, object_id=entry4.id, tag=tag8
466
+    ).save()
405 467
     entry5.tags.add(tag9, tag10)
406
-    TaggedEntry(content_type_id=entry_content_type.id, object_id=entry5.id, tag=tag9).save()
407
-    TaggedEntry(content_type_id=entry_content_type.id, object_id=entry5.id, tag=tag10).save()
468
+    TaggedEntry(
469
+        content_type_id=entry_content_type.id, object_id=entry5.id, tag=tag9
470
+    ).save()
471
+    TaggedEntry(
472
+        content_type_id=entry_content_type.id, object_id=entry5.id, tag=tag10
473
+    ).save()
408 474
     entry6.tags.add(tag11, tag12)
409
-    TaggedEntry(content_type_id=entry_content_type.id, object_id=entry6.id, tag=tag11).save()
410
-    TaggedEntry(content_type_id=entry_content_type.id, object_id=entry6.id, tag=tag12).save()
475
+    TaggedEntry(
476
+        content_type_id=entry_content_type.id, object_id=entry6.id, tag=tag11
477
+    ).save()
478
+    TaggedEntry(
479
+        content_type_id=entry_content_type.id, object_id=entry6.id, tag=tag12
480
+    ).save()
411 481
     entry7.tags.add(tag13, tag14)
412
-    TaggedEntry(content_type_id=entry_content_type.id, object_id=entry7.id, tag=tag13).save()
413
-    TaggedEntry(content_type_id=entry_content_type.id, object_id=entry7.id, tag=tag14).save()
482
+    TaggedEntry(
483
+        content_type_id=entry_content_type.id, object_id=entry7.id, tag=tag13
484
+    ).save()
485
+    TaggedEntry(
486
+        content_type_id=entry_content_type.id, object_id=entry7.id, tag=tag14
487
+    ).save()
414 488
     entry8.tags.add(tag15, tag16)
415
-    TaggedEntry(content_type_id=entry_content_type.id, object_id=entry8.id, tag=tag15).save()
416
-    TaggedEntry(content_type_id=entry_content_type.id, object_id=entry8.id, tag=tag16).save()
489
+    TaggedEntry(
490
+        content_type_id=entry_content_type.id, object_id=entry8.id, tag=tag15
491
+    ).save()
492
+    TaggedEntry(
493
+        content_type_id=entry_content_type.id, object_id=entry8.id, tag=tag16
494
+    ).save()
417 495
     entry9.tags.add(tag17, tag18)
418
-    TaggedEntry(content_type_id=entry_content_type.id, object_id=entry9.id, tag=tag17).save()
419
-    TaggedEntry(content_type_id=entry_content_type.id, object_id=entry9.id, tag=tag18).save()
496
+    TaggedEntry(
497
+        content_type_id=entry_content_type.id, object_id=entry9.id, tag=tag17
498
+    ).save()
499
+    TaggedEntry(
500
+        content_type_id=entry_content_type.id, object_id=entry9.id, tag=tag18
501
+    ).save()
420 502
     entry10.tags.add(tag19, tag20)
421
-    TaggedEntry(content_type_id=entry_content_type.id, object_id=entry10.id, tag=tag19).save()
422
-    TaggedEntry(content_type_id=entry_content_type.id, object_id=entry10.id, tag=tag20).save()
503
+    TaggedEntry(
504
+        content_type_id=entry_content_type.id, object_id=entry10.id, tag=tag19
505
+    ).save()
506
+    TaggedEntry(
507
+        content_type_id=entry_content_type.id, object_id=entry10.id, tag=tag20
508
+    ).save()
423 509
     entry11.tags.add(tag21, tag22)
424
-    TaggedEntry(content_type_id=entry_content_type.id, object_id=entry11.id, tag=tag21).save()
425
-    TaggedEntry(content_type_id=entry_content_type.id, object_id=entry11.id, tag=tag22).save()
510
+    TaggedEntry(
511
+        content_type_id=entry_content_type.id, object_id=entry11.id, tag=tag21
512
+    ).save()
513
+    TaggedEntry(
514
+        content_type_id=entry_content_type.id, object_id=entry11.id, tag=tag22
515
+    ).save()
426 516
     entry12.tags.add(tag23, tag24)
427
-    TaggedEntry(content_type_id=entry_content_type.id, object_id=entry12.id, tag=tag23).save()
428
-    TaggedEntry(content_type_id=entry_content_type.id, object_id=entry12.id, tag=tag24).save()
517
+    TaggedEntry(
518
+        content_type_id=entry_content_type.id, object_id=entry12.id, tag=tag23
519
+    ).save()
520
+    TaggedEntry(
521
+        content_type_id=entry_content_type.id, object_id=entry12.id, tag=tag24
522
+    ).save()
429 523
     entry13.tags.add(tag25, tag26)
430
-    TaggedEntry(content_type_id=entry_content_type.id, object_id=entry13.id, tag=tag25).save()
431
-    TaggedEntry(content_type_id=entry_content_type.id, object_id=entry13.id, tag=tag26).save()
524
+    TaggedEntry(
525
+        content_type_id=entry_content_type.id, object_id=entry13.id, tag=tag25
526
+    ).save()
527
+    TaggedEntry(
528
+        content_type_id=entry_content_type.id, object_id=entry13.id, tag=tag26
529
+    ).save()
432 530
     entry14.tags.add(tag27, tag28)
433
-    TaggedEntry(content_type_id=entry_content_type.id, object_id=entry14.id, tag=tag27).save()
434
-    TaggedEntry(content_type_id=entry_content_type.id, object_id=entry14.id, tag=tag28).save()
531
+    TaggedEntry(
532
+        content_type_id=entry_content_type.id, object_id=entry14.id, tag=tag27
533
+    ).save()
534
+    TaggedEntry(
535
+        content_type_id=entry_content_type.id, object_id=entry14.id, tag=tag28
536
+    ).save()
435 537
     entry15.tags.add(tag29, tag30)
436
-    TaggedEntry(content_type_id=entry_content_type.id, object_id=entry15.id, tag=tag29).save()
437
-    TaggedEntry(content_type_id=entry_content_type.id, object_id=entry15.id, tag=tag30).save()
538
+    TaggedEntry(
539
+        content_type_id=entry_content_type.id, object_id=entry15.id, tag=tag29
540
+    ).save()
541
+    TaggedEntry(
542
+        content_type_id=entry_content_type.id, object_id=entry15.id, tag=tag30
543
+    ).save()
438 544
     entry16.tags.add(tag31, tag32)
439
-    TaggedEntry(content_type_id=entry_content_type.id, object_id=entry16.id, tag=tag31).save()
440
-    TaggedEntry(content_type_id=entry_content_type.id, object_id=entry16.id, tag=tag32).save()
545
+    TaggedEntry(
546
+        content_type_id=entry_content_type.id, object_id=entry16.id, tag=tag31
547
+    ).save()
548
+    TaggedEntry(
549
+        content_type_id=entry_content_type.id, object_id=entry16.id, tag=tag32
550
+    ).save()
441 551
     entry17.tags.add(tag33, tag34)
442
-    TaggedEntry(content_type_id=entry_content_type.id, object_id=entry17.id, tag=tag33).save()
443
-    TaggedEntry(content_type_id=entry_content_type.id, object_id=entry17.id, tag=tag34).save()
552
+    TaggedEntry(
553
+        content_type_id=entry_content_type.id, object_id=entry17.id, tag=tag33
554
+    ).save()
555
+    TaggedEntry(
556
+        content_type_id=entry_content_type.id, object_id=entry17.id, tag=tag34
557
+    ).save()
444 558
     entry18.tags.add(tag35, tag36)
445
-    TaggedEntry(content_type_id=entry_content_type.id, object_id=entry18.id, tag=tag35).save()
446
-    TaggedEntry(content_type_id=entry_content_type.id, object_id=entry18.id, tag=tag36).save()
559
+    TaggedEntry(
560
+        content_type_id=entry_content_type.id, object_id=entry18.id, tag=tag35
561
+    ).save()
562
+    TaggedEntry(
563
+        content_type_id=entry_content_type.id, object_id=entry18.id, tag=tag36
564
+    ).save()
447 565
     entry19.tags.add(tag37, tag38)
448
-    TaggedEntry(content_type_id=entry_content_type.id, object_id=entry19.id, tag=tag37).save()
449
-    TaggedEntry(content_type_id=entry_content_type.id, object_id=entry19.id, tag=tag38).save()
566
+    TaggedEntry(
567
+        content_type_id=entry_content_type.id, object_id=entry19.id, tag=tag37
568
+    ).save()
569
+    TaggedEntry(
570
+        content_type_id=entry_content_type.id, object_id=entry19.id, tag=tag38
571
+    ).save()
450 572
     entry20.tags.add(tag39, tag40)
451
-    TaggedEntry(content_type_id=entry_content_type.id, object_id=entry20.id, tag=tag39).save()
452
-    TaggedEntry(content_type_id=entry_content_type.id, object_id=entry20.id, tag=tag40).save()
573
+    TaggedEntry(
574
+        content_type_id=entry_content_type.id, object_id=entry20.id, tag=tag39
575
+    ).save()
576
+    TaggedEntry(
577
+        content_type_id=entry_content_type.id, object_id=entry20.id, tag=tag40
578
+    ).save()

+ 11
- 7
momw/chroniko/feeds.py View File

@@ -17,7 +17,7 @@ except AttributeError:
17 17
 
18 18
 class LatestEntriesFeed(Feed):
19 19
     description = DESCRIPTION
20
-    link = '/blog/'  # TODO: find out wtf this is for
20
+    link = "/blog/"  # TODO: find out wtf this is for
21 21
     title = TITLE
22 22
 
23 23
     def items(self):
@@ -31,11 +31,15 @@ class LatestEntriesFeed(Feed):
31 31
             return item.excerpt
32 32
         else:
33 33
             excerpt = item.body.split()[:50]
34
-            return ' '.join(excerpt)
34
+            return " ".join(excerpt)
35 35
 
36 36
     def item_link(self, item):
37
-        return reverse('blog:entry_detail', kwargs={
38
-            'year': item.date_added.astimezone(TZ).strftime("%Y"),
39
-            'month': item.date_added.astimezone(TZ).strftime("%m"),
40
-            'day': item.date_added.astimezone(TZ).strftime("%d"),
41
-            'slug': item.slug})
37
+        return reverse(
38
+            "blog:entry_detail",
39
+            kwargs={
40
+                "year": item.date_added.astimezone(TZ).strftime("%Y"),
41
+                "month": item.date_added.astimezone(TZ).strftime("%m"),
42
+                "day": item.date_added.astimezone(TZ).strftime("%d"),
43
+                "slug": item.slug,
44
+            },
45
+        )

+ 11
- 9
momw/chroniko/forms.py View File

@@ -7,7 +7,7 @@ class CategoryForm(forms.ModelForm):
7 7
         super().__init__(*args, **kwargs)
8 8
 
9 9
     class Meta:
10
-        fields = '__all__'
10
+        fields = "__all__"
11 11
         model = BlogCategory
12 12
 
13 13
 
@@ -16,7 +16,7 @@ class TagForm(forms.ModelForm):
16 16
         super().__init__(*args, **kwargs)
17 17
 
18 18
     class Meta:
19
-        fields = '__all__'
19
+        fields = "__all__"
20 20
         model = BlogTag
21 21
 
22 22
 
@@ -31,20 +31,22 @@ class DeleteThingForm(forms.Form):
31 31
 class EntryForm(forms.ModelForm):
32 32
     def __init__(self, *args, **kwargs):
33 33
         super().__init__(*args, **kwargs)
34
-        self.fields['category'].widget.attrs['class'] = 'u-full-width'
35
-        self.fields['status'].widget.attrs['class'] = 'u-full-width'
36
-        self.fields['tags'].label = 'Comma-separated list of tags'
34
+        self.fields["category"].widget.attrs["class"] = "u-full-width"
35
+        self.fields["status"].widget.attrs["class"] = "u-full-width"
36
+        self.fields["tags"].label = "Comma-separated list of tags"
37 37
 
38 38
     class Meta:
39
-        exclude = ('author', 'date_added')
39
+        exclude = ("author", "date_added")
40 40
         model = BlogEntry
41 41
 
42
-    date_added_0 = forms.DateField(label='Publish Date', required=True)
43
-    date_added_1 = forms.TimeField(label='Publish Time', required=True)
42
+    date_added_0 = forms.DateField(label="Publish Date", required=True)
43
+    date_added_1 = forms.TimeField(label="Publish Time", required=True)
44 44
 
45 45
 
46 46
 class ToggleTinyMCEForm(forms.Form):
47 47
     def __init__(self, *args, **kwargs):
48 48
         super().__init__(*args, **kwargs)
49 49
 
50
-    toggle_tinymce = forms.BooleanField(help_text="Toggle the TinyMCE editor on or off.  Any unsaved data will be lost!!")
50
+    toggle_tinymce = forms.BooleanField(
51
+        help_text="Toggle the TinyMCE editor on or off.  Any unsaved data will be lost!!"
52
+    )

+ 129
- 46
momw/chroniko/migrations/0001_initial.py View File

@@ -12,77 +12,160 @@ class Migration(migrations.Migration):
12 12
 
13 13
     dependencies = [
14 14
         migrations.swappable_dependency(settings.AUTH_USER_MODEL),
15
-        ('contenttypes', '0002_remove_content_type_name'),
15
+        ("contenttypes", "0002_remove_content_type_name"),
16 16
     ]
17 17
 
18 18
     operations = [
19 19
         migrations.CreateModel(
20
-            name='BlogCategory',
20
+            name="BlogCategory",
21 21
             fields=[
22
-                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
23
-                ('title', models.CharField(max_length=250)),
24
-                ('slug', models.SlugField(help_text='Suggested value automatically generated from title.', unique=True)),
25
-                ('description', models.TextField()),
22
+                (
23
+                    "id",
24
+                    models.AutoField(
25
+                        auto_created=True,
26
+                        primary_key=True,
27
+                        serialize=False,
28
+                        verbose_name="ID",
29
+                    ),
30
+                ),
31
+                ("title", models.CharField(max_length=250)),
32
+                (
33
+                    "slug",
34
+                    models.SlugField(
35
+                        help_text="Suggested value automatically generated from title.",
36
+                        unique=True,
37
+                    ),
38
+                ),
39
+                ("description", models.TextField()),
26 40
             ],
27 41
             options={
28
-                'verbose_name': 'Category',
29
-                'verbose_name_plural': 'Categories',
30
-                'db_table': 'blog_categories',
31
-                'ordering': ['title'],
42
+                "verbose_name": "Category",
43
+                "verbose_name_plural": "Categories",
44
+                "db_table": "blog_categories",
45
+                "ordering": ["title"],
32 46
             },
33 47
         ),
34 48
         migrations.CreateModel(
35
-            name='BlogEntry',
49
+            name="BlogEntry",
36 50
             fields=[
37
-                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
38
-                ('body', models.TextField()),
39
-                ('excerpt', models.TextField(blank=True)),
40
-                ('featured', models.BooleanField(default=False)),
41
-                ('date_added', models.DateTimeField()),
42
-                ('date_updated', models.DateTimeField(auto_now=True)),
43
-                ('slug', models.SlugField(unique=True)),
44
-                ('status', models.IntegerField(choices=[(1, 'Live'), (2, 'Draft'), (3, 'Hidden')], default=2)),
45
-                ('title', models.CharField(max_length=250)),
46
-                ('author', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to=settings.AUTH_USER_MODEL)),
47
-                ('category', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='chroniko.BlogCategory')),
51
+                (
52
+                    "id",
53
+                    models.AutoField(
54
+                        auto_created=True,
55
+                        primary_key=True,
56
+                        serialize=False,
57
+                        verbose_name="ID",
58
+                    ),
59
+                ),
60
+                ("body", models.TextField()),
61
+                ("excerpt", models.TextField(blank=True)),
62
+                ("featured", models.BooleanField(default=False)),
63
+                ("date_added", models.DateTimeField()),
64
+                ("date_updated", models.DateTimeField(auto_now=True)),
65
+                ("slug", models.SlugField(unique=True)),
66
+                (
67
+                    "status",
68
+                    models.IntegerField(
69
+                        choices=[(1, "Live"), (2, "Draft"), (3, "Hidden")], default=2
70
+                    ),
71
+                ),
72
+                ("title", models.CharField(max_length=250)),
73
+                (
74
+                    "author",
75
+                    models.ForeignKey(
76
+                        on_delete=django.db.models.deletion.PROTECT,
77
+                        to=settings.AUTH_USER_MODEL,
78
+                    ),
79
+                ),
80
+                (
81
+                    "category",
82
+                    models.ForeignKey(
83
+                        on_delete=django.db.models.deletion.PROTECT,
84
+                        to="chroniko.BlogCategory",
85
+                    ),
86
+                ),
48 87
             ],
49 88
             options={
50
-                'verbose_name': 'Entry',
51
-                'verbose_name_plural': 'Entries',
52
-                'db_table': 'blog_entries',
53
-                'ordering': ['-date_added'],
89
+                "verbose_name": "Entry",
90
+                "verbose_name_plural": "Entries",
91
+                "db_table": "blog_entries",
92
+                "ordering": ["-date_added"],
54 93
             },
55 94
         ),
56 95
         migrations.CreateModel(
57
-            name='BlogTag',
96
+            name="BlogTag",
58 97
             fields=[
59
-                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
60
-                ('name', models.CharField(max_length=100, unique=True, verbose_name='Name')),
61
-                ('slug', models.SlugField(max_length=100, unique=True, verbose_name='Slug')),
62
-                ('is_enabled', models.BooleanField(default=True)),
98
+                (
99
+                    "id",
100
+                    models.AutoField(
101
+                        auto_created=True,
102
+                        primary_key=True,
103
+                        serialize=False,
104
+                        verbose_name="ID",
105
+                    ),
106
+                ),
107
+                (
108
+                    "name",
109
+                    models.CharField(max_length=100, unique=True, verbose_name="Name"),
110
+                ),
111
+                (
112
+                    "slug",
113
+                    models.SlugField(max_length=100, unique=True, verbose_name="Slug"),
114
+                ),
115
+                ("is_enabled", models.BooleanField(default=True)),
63 116
             ],
64 117
             options={
65
-                'verbose_name': 'Tag',
66
-                'verbose_name_plural': 'Tags',
67
-                'db_table': 'blog_tags',
68
-                'ordering': ['-name'],
118
+                "verbose_name": "Tag",
119
+                "verbose_name_plural": "Tags",
120
+                "db_table": "blog_tags",
121
+                "ordering": ["-name"],
69 122
             },
70 123
         ),
71 124
         migrations.CreateModel(
72
-            name='TaggedEntry',
125
+            name="TaggedEntry",
73 126
             fields=[
74
-                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
75
-                ('object_id', models.IntegerField(db_index=True, verbose_name='Object id')),
76
-                ('content_type', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='chroniko_taggedentry_tagged_items', to='contenttypes.ContentType', verbose_name='Content type')),
77
-                ('tag', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='chroniko_taggedentry_items', to='chroniko.BlogTag')),
127
+                (
128
+                    "id",
129
+                    models.AutoField(
130
+                        auto_created=True,
131
+                        primary_key=True,
132
+                        serialize=False,
133
+                        verbose_name="ID",
134
+                    ),
135
+                ),
136
+                (
137
+                    "object_id",
138
+                    models.IntegerField(db_index=True, verbose_name="Object id"),
139
+                ),
140
+                (
141
+                    "content_type",
142
+                    models.ForeignKey(
143
+                        on_delete=django.db.models.deletion.CASCADE,
144
+                        related_name="chroniko_taggedentry_tagged_items",
145
+                        to="contenttypes.ContentType",
146
+                        verbose_name="Content type",
147
+                    ),
148
+                ),
149
+                (
150
+                    "tag",
151
+                    models.ForeignKey(
152
+                        on_delete=django.db.models.deletion.PROTECT,
153
+                        related_name="chroniko_taggedentry_items",
154
+                        to="chroniko.BlogTag",
155
+                    ),
156
+                ),
78 157
             ],
79
-            options={
80
-                'db_table': 'tagged_blog_entries',
81
-            },
158
+            options={"db_table": "tagged_blog_entries"},
82 159
         ),
83 160
         migrations.AddField(
84
-            model_name='blogentry',
85
-            name='tags',
86
-            field=taggit.managers.TaggableManager(blank=True, help_text='A comma-separated list of tags.', through='chroniko.TaggedEntry', to='chroniko.BlogTag', verbose_name='Tags'),
161
+            model_name="blogentry",
162
+            name="tags",
163
+            field=taggit.managers.TaggableManager(
164
+                blank=True,
165
+                help_text="A comma-separated list of tags.",
166
+                through="chroniko.TaggedEntry",
167
+                to="chroniko.BlogTag",
168
+                verbose_name="Tags",
169
+            ),
87 170
         ),
88 171
     ]

+ 40
- 31
momw/chroniko/models.py View File

@@ -7,8 +7,12 @@ from django.db import models
7 7
 from django.utils.translation import ugettext_lazy as _
8 8
 from taggit.managers import TaggableManager
9 9
 from taggit.models import TagBase, GenericTaggedItemBase
10
-from utilz.managers import DraftThingManager, EnabledTagManager, \
11
-    HiddenThingManager, LiveThingManager
10
+from utilz.managers import (
11
+    DraftThingManager,
12
+    EnabledTagManager,
13
+    HiddenThingManager,
14
+    LiveThingManager,
15
+)
12 16
 
13 17
 
14 18
 TZ = pendulum.timezone(settings.TIME_ZONE)
@@ -20,30 +24,29 @@ except AttributeError:
20 24
 
21 25
 class BlogCategory(models.Model):
22 26
     title = models.CharField(max_length=250)
23
-    slug = models.SlugField(help_text='Suggested value automatically generated from title.', unique=True)
27
+    slug = models.SlugField(
28
+        help_text="Suggested value automatically generated from title.", unique=True
29
+    )
24 30
     description = models.TextField()
25 31
 
26 32
     class Meta:
27
-        db_table = 'blog_categories'
28
-        ordering = ['title', ]
29
-        verbose_name = _('Category')
30
-        verbose_name_plural = _('Categories')
33
+        db_table = "blog_categories"
34
+        ordering = ["title"]
35
+        verbose_name = _("Category")
36
+        verbose_name_plural = _("Categories")
31 37
 
32 38
     def __str__(self):
33 39
         return self.title
34 40
 
35 41
     def get_absolute_url(self):
36
-        return reverse('blog:category_detail', kwargs={'slug': self.slug})
42
+        return reverse("blog:category_detail", kwargs={"slug": self.slug})
37 43
 
38 44
 
39 45
 class BlogEntry(models.Model):
40 46
     LIVE = 1
41 47
     DRAFT = 2
42 48
     HIDDEN = 3
43
-    STATUS_CHOICES = (
44
-        (LIVE, 'Live'),
45
-        (DRAFT, 'Draft'),
46
-        (HIDDEN, 'Hidden'))
49
+    STATUS_CHOICES = ((LIVE, "Live"), (DRAFT, "Draft"), (HIDDEN, "Hidden"))
47 50
     objects = models.Manager()
48 51
     live = LiveThingManager()
49 52
     draft = DraftThingManager()
@@ -58,26 +61,30 @@ class BlogEntry(models.Model):
58 61
     title = models.CharField(max_length=250)
59 62
     author = models.ForeignKey(get_user_model(), on_delete=models.PROTECT)
60 63
     category = models.ForeignKey(BlogCategory, on_delete=models.PROTECT)
61
-    tags = TaggableManager(through='TaggedEntry', blank=True)
64
+    tags = TaggableManager(through="TaggedEntry", blank=True)
62 65
 
63 66
     class Meta:
64
-        db_table = 'blog_entries'
65
-        ordering = ['-date_added', ]
66
-        verbose_name = _('Entry')
67
-        verbose_name_plural = _('Entries')
67
+        db_table = "blog_entries"
68
+        ordering = ["-date_added"]
69
+        verbose_name = _("Entry")
70
+        verbose_name_plural = _("Entries")
68 71
 
69 72
     def __str__(self):
70 73
         return self.title
71 74
 
72 75
     def get_absolute_url(self, short=SHORT_URLS):
73 76
         if short:
74
-            url = reverse("slug_root", kwargs={'slug': self.slug})
77
+            url = reverse("slug_root", kwargs={"slug": self.slug})
75 78
         else:
76
-            url = reverse('blog:entry_detail', kwargs={
77
-                'year': self.date_added.astimezone(TZ).strftime("%Y"),
78
-                'month': self.date_added.astimezone(TZ).strftime("%m"),
79
-                'day': self.date_added.astimezone(TZ).strftime("%d"),
80
-                'slug': self.slug})
79
+            url = reverse(
80
+                "blog:entry_detail",
81
+                kwargs={
82
+                    "year": self.date_added.astimezone(TZ).strftime("%Y"),
83
+                    "month": self.date_added.astimezone(TZ).strftime("%m"),
84
+                    "day": self.date_added.astimezone(TZ).strftime("%d"),
85
+                    "slug": self.slug,
86
+                },
87
+            )
81 88
         return url
82 89
 
83 90
     def get_status_string(self):
@@ -90,10 +97,10 @@ class BlogTag(TagBase):
90 97
     is_enabled = models.BooleanField(default=True)
91 98
 
92 99
     class Meta:
93
-        db_table = 'blog_tags'
94
-        ordering = ['-name', ]
95
-        verbose_name = _('Tag')
96
-        verbose_name_plural = _('Tags')
100
+        db_table = "blog_tags"
101
+        ordering = ["-name"]
102
+        verbose_name = _("Tag")
103
+        verbose_name_plural = _("Tags")
97 104
 
98 105
     @property
99 106
     def tagged_entries(self):
@@ -108,16 +115,18 @@ class BlogTag(TagBase):
108 115
         return self.chroniko_taggedentry_items.count()
109 116
 
110 117
     def get_absolute_url(self):
111
-        return reverse('blog:tag_detail', kwargs={'slug': self.slug})
118
+        return reverse("blog:tag_detail", kwargs={"slug": self.slug})
112 119
 
113 120
     def save(self, *args, **kwargs):
114 121
         if not self.pk:
115
-            self.name = self.name.strip(',')
122
+            self.name = self.name.strip(",")
116 123
         super().save(*args, **kwargs)
117 124
 
118 125
 
119 126
 class TaggedEntry(GenericTaggedItemBase):
120
-    tag = models.ForeignKey(BlogTag, related_name='%(app_label)s_%(class)s_items', on_delete=models.PROTECT)
127
+    tag = models.ForeignKey(
128
+        BlogTag, related_name="%(app_label)s_%(class)s_items", on_delete=models.PROTECT
129
+    )
121 130
 
122 131
     class Meta:
123
-        db_table = 'tagged_blog_entries'
132
+        db_table = "tagged_blog_entries"

+ 90
- 64
momw/chroniko/tests.py View File

@@ -7,10 +7,22 @@ from django.utils import timezone
7 7
 from chroniko.data_seeds.blog import generate_category, generate_entry
8 8
 from chroniko.models import BlogEntry
9 9
 from .models import BlogCategory, BlogTag
10
-from .views import CategoryDetailView, CategoryIndexView, DraftEntriesView, \
11
-    EntryDetailView, EntryIndexView, HiddenEntriesView, TagCloudView, \
12
-    TagDetailView, category_create, category_edit, entry_create, entry_delete,\
13
-    entry_edit, tag_edit
10
+from .views import (
11
+    CategoryDetailView,
12
+    CategoryIndexView,
13
+    DraftEntriesView,
14
+    EntryDetailView,
15
+    EntryIndexView,
16
+    HiddenEntriesView,
17
+    TagCloudView,
18
+    TagDetailView,
19
+    category_create,
20
+    category_edit,
21
+    entry_create,
22
+    entry_delete,
23
+    entry_edit,
24
+    tag_edit,
25
+)
14 26
 
15 27
 
16 28
 HTTP_FOUND = 302
@@ -19,56 +31,74 @@ HTTP_NOT_FOUND = 404
19 31
 HTTP_OK = 200
20 32
 
21 33
 
22
-class SetUpBase():
34
+class SetUpBase:
23 35
     def setUp(self):
24 36
         super().setUp()
25 37
         self.f = RequestFactory()
26 38
         # TODO: don't create a user here
27 39
         if not User.objects.all():
28
-            self.u = User.objects.create(first_name="First Name",
29
-                                         last_name="Last Name",
30
-                                         username="first-last-jaja-lala",
31
-                                         password="12345",
32
-                                         is_superuser=True)
33
-        self.c = generate_category("Category One", "one",
34
-                                   "This is category one, yeah!")
35
-        self.c2 = generate_category("Category Two", "TWOOOOOOSWEEEET",
36
-                                    "This is category two, BoiiII!")
37
-        self.e = generate_entry("BODY " * 300,
38
-                                timezone.localtime(timezone.now()),
39
-                                "test-slug", BlogEntry.LIVE,
40
-                                "Test Title", self.u, self.c)
41
-        self.e2 = generate_entry("BODY " * 300,
42
-                                 timezone.localtime(timezone.now()),
43
-                                 "test-slug2", BlogEntry.LIVE,
44
-                                 "Test Title 2", self.u, self.c2,
45
-                                 excerpt="EXCERPT " * 300)
40
+            self.u = User.objects.create(
41
+                first_name="First Name",
42
+                last_name="Last Name",
43
+                username="first-last-jaja-lala",
44
+                password="12345",
45
+                is_superuser=True,
46
+            )
47
+        self.c = generate_category("Category One", "one", "This is category one, yeah!")
48
+        self.c2 = generate_category(
49
+            "Category Two", "TWOOOOOOSWEEEET", "This is category two, BoiiII!"
50
+        )
51
+        self.e = generate_entry(
52
+            "BODY " * 300,
53
+            timezone.localtime(timezone.now()),
54
+            "test-slug",
55
+            BlogEntry.LIVE,
56
+            "Test Title",
57
+            self.u,
58
+            self.c,
59
+        )
60
+        self.e2 = generate_entry(
61
+            "BODY " * 300,
62
+            timezone.localtime(timezone.now()),
63
+            "test-slug2",
64
+            BlogEntry.LIVE,
65
+            "Test Title 2",
66
+            self.u,
67
+            self.c2,
68
+            excerpt="EXCERPT " * 300,
69
+        )
46 70
         self.t = BlogTag.objects.create(name="live")
47 71
         # TODO: use generate_entry() ??
48
-        self.el = BlogEntry.objects.create(excerpt="EXCERPT TIME",
49
-                                           body="BODY TIME",
50
-                                           date_added=timezone.now(),
51
-                                           slug="live-1",
52
-                                           status=BlogEntry.LIVE,
53
-                                           title="Live ONE",
54
-                                           author=self.u,
55
-                                           category=self.c)
56
-        self.ed = BlogEntry.objects.create(excerpt="EXCERPT TIME",
57
-                                           body="BODY TIME",
58
-                                           date_added=timezone.now(),
59
-                                           slug="draft-1",
60
-                                           status=BlogEntry.DRAFT,
61
-                                           title="Draft ONE",
62
-                                           author=self.u,
63
-                                           category=self.c)
64
-        self.eh = BlogEntry.objects.create(excerpt="EXCERPT TIME",
65
-                                           body="BODY TIME",
66
-                                           date_added=timezone.now(),
67
-                                           slug="hidden-1",
68
-                                           status=BlogEntry.HIDDEN,
69
-                                           title="Hidden ONE",
70
-                                           author=self.u,
71
-                                           category=self.c)
72
+        self.el = BlogEntry.objects.create(
73
+            excerpt="EXCERPT TIME",
74
+            body="BODY TIME",
75
+            date_added=timezone.now(),
76
+            slug="live-1",
77
+            status=BlogEntry.LIVE,
78
+            title="Live ONE",
79
+            author=self.u,
80
+            category=self.c,
81
+        )
82
+        self.ed = BlogEntry.objects.create(
83
+            excerpt="EXCERPT TIME",
84
+            body="BODY TIME",
85
+            date_added=timezone.now(),
86
+            slug="draft-1",
87
+            status=BlogEntry.DRAFT,
88
+            title="Draft ONE",
89
+            author=self.u,
90
+            category=self.c,
91
+        )
92
+        self.eh = BlogEntry.objects.create(
93
+            excerpt="EXCERPT TIME",
94
+            body="BODY TIME",
95
+            date_added=timezone.now(),
96
+            slug="hidden-1",
97
+            status=BlogEntry.HIDDEN,
98
+            title="Hidden ONE",
99
+            author=self.u,
100
+            category=self.c,
101
+        )
72 102
 
73 103
 
74 104
 class ChronikoSeleniumTestCase(SetUpBase):
@@ -229,7 +259,6 @@ class ChronikoSeleniumTestCase(SetUpBase):
229 259
 
230 260
 # TODO: many if not all of the below are obsoleted by the above selenium tests
231 261
 class ChronikoTestCase(SetUpBase, TestCase):
232
-
233 262
     def test_cat_absolute_url(self):
234 263
         self.assertIsInstance(self.c.get_absolute_url(), str)
235 264
 
@@ -247,10 +276,9 @@ class ChronikoTestCase(SetUpBase, TestCase):
247 276
         slug = self.el.slug
248 277
         r = self.f.get(self.el.get_absolute_url())
249 278
         r.user = AnonymousUser()
250
-        response = EntryDetailView.as_view()(r, year=year,
251
-                                             month=month,
252
-                                             day=day,
253
-                                             slug=slug)
279
+        response = EntryDetailView.as_view()(
280
+            r, year=year, month=month, day=day, slug=slug
281
+        )
254 282
         self.assertEqual(response.status_code, HTTP_OK)
255 283
 
256 284
     def test_live_entry_is_viewable_short_url(self):
@@ -273,8 +301,7 @@ class ChronikoTestCase(SetUpBase, TestCase):
273 301
         self.assertEqual(response.status_code, HTTP_OK)
274 302
 
275 303
     def test_category_detail(self):
276
-        r = self.f.get(reverse("blog:category_detail",
277
-                               kwargs={"slug": self.c.slug}))
304
+        r = self.f.get(reverse("blog:category_detail", kwargs={"slug": self.c.slug}))
278 305
         r.user = AnonymousUser()
279 306
         response = CategoryDetailView.as_view()(r, slug=self.c.slug)
280 307
         self.assertEqual(response.status_code, HTTP_OK)
@@ -295,25 +322,24 @@ class ChronikoTestCase(SetUpBase, TestCase):
295 322
         self.assertEqual(r.status_code, HTTP_NOT_FOUND)
296 323
 
297 324
     def test_category_create_post(self):
298
-        r = self.f.post(reverse("blog:new_category"),
299
-                        data={"title": "New 1",
300
-                              "slug": "new-1",
301
-                              "description": "STUFF HERE"})
325
+        r = self.f.post(
326
+            reverse("blog:new_category"),
327
+            data={"title": "New 1", "slug": "new-1", "description": "STUFF HERE"},
328
+        )
302 329
         r.user = self.u
303 330
         category_create(r)
304 331
         self.assertTrue(BlogCategory.objects.get(slug="new-1"))
305 332
 
306 333
     def test_category_edit_post(self):
307 334
         c = self.c
308
-        r = self.f.post(reverse("blog:category_edit",
309
-                                kwargs={"slug": c.slug}),
310
-                        data={"title": "New 11",
311
-                              "slug": "new-11",
312
-                              "description": "NEW STUFF HERE"})
335
+        r = self.f.post(
336
+            reverse("blog:category_edit", kwargs={"slug": c.slug}),
337
+            data={"title": "New 11", "slug": "new-11", "description": "NEW STUFF HERE"},
338
+        )
313 339
         r.user = self.u
314 340
         category_edit(r, slug=c.slug)
315 341
         c_edited = BlogCategory.objects.get(pk=c.pk)
316
-        self.assertTrue(c_edited.slug == 'new-11')
342
+        self.assertTrue(c_edited.slug == "new-11")
317 343
 
318 344
     # def test_category_delete(self):
319 345
     #     pass

+ 54
- 35
momw/chroniko/urls.py View File

@@ -2,42 +2,61 @@ from django.conf import settings
2 2
 from django.urls import path
3 3
 from django.views.decorators.cache import cache_page
4 4
 from .feeds import LatestEntriesFeed
5
-from .views import AllEntriesView, CategoryDetailView, CategoryIndexView, \
6
-    DraftEntriesView, EntriesByDayView, EntriesByMonthView, EntriesByYearView,\
7
-    EntryDetailView, EntryIndexView, HiddenEntriesView, TagCloudView, \
8
-    TagDetailView, category_create, category_delete, category_edit, \
9
-    entry_create, entry_delete, entry_edit, tag_edit
5
+from .views import (
6
+    AllEntriesView,
7
+    CategoryDetailView,
8
+    CategoryIndexView,
9
+    DraftEntriesView,
10
+    EntriesByDayView,
11
+    EntriesByMonthView,
12
+    EntriesByYearView,
13
+    EntryDetailView,
14
+    EntryIndexView,
15
+    HiddenEntriesView,
16
+    TagCloudView,
17
+    TagDetailView,
18
+    category_create,
19
+    category_delete,
20
+    category_edit,
21
+    entry_create,
22
+    entry_delete,
23
+    entry_edit,
24
+    tag_edit,
25
+)
10 26
 
11 27
 
12
-app_name = 'chroniko'  # TODO: DRY this
28
+app_name = "chroniko"  # TODO: DRY this
13 29
 urlpatterns = [
14
-    path('', EntryIndexView.as_view(), name='index'),
15
-    path('categories/', CategoryIndexView.as_view(), name='category_index'),
16
-    path('categories/new/', category_create, name='new_category'),
17
-    path('categories/<slug:slug>/', CategoryDetailView.as_view(),
18
-         name='category_detail'),
19
-    path('categories/<slug:slug>/delete/', category_delete,
20
-         name='category_delete'),
21
-    path('categories/<slug:slug>/edit/', category_edit,
22
-         name='category_edit'),
23
-    path('drafts/', DraftEntriesView.as_view(), name='draft_entries'),
24
-    path('entries/all/', AllEntriesView.as_view(), name='all_entries'),
25
-    path('entries/new/', entry_create, name='new_entry'),
26
-    path('feeds/latest-entries/', cache_page(settings.CACHE_MIDDLEWARE_SECONDS)(LatestEntriesFeed()),
27
-         name='latest_entries_feed'),
28
-    path('hidden/', HiddenEntriesView.as_view(), name='hidden_entries'),
29
-    path('tag/cloud/', TagCloudView.as_view(), name='tag_cloud'),
30
-    path('tag/<slug:slug>/', TagDetailView.as_view(),
31
-         name='tag_detail'),
32
-    path('tag/<slug:slug>/edit/', tag_edit,
33
-         name='tag_edit'),
34
-    path('<slug:slug>/delete/', entry_delete, name='entry_delete'),
35
-    path('<slug:slug>/edit/', entry_edit, name='entry_edit'),
36
-    path('<int:year>/', EntriesByYearView.as_view(), name='by_year'),
37
-    path('<int:year>/<int:month>/', EntriesByMonthView.as_view(),
38
-         name='by_month'),
39
-    path('<int:year>/<int:month>/<int:day>/',
40
-         EntriesByDayView.as_view(), name='by_day'),
41
-    path('<int:year>/<int:month>/<int:day>/<slug:slug>/',
42
-         EntryDetailView.as_view(), name='entry_detail'),
30
+    path("", EntryIndexView.as_view(), name="index"),
31
+    path("categories/", CategoryIndexView.as_view(), name="category_index"),
32
+    path("categories/new/", category_create, name="new_category"),
33
+    path(
34
+        "categories/<slug:slug>/", CategoryDetailView.as_view(), name="category_detail"
35
+    ),
36
+    path("categories/<slug:slug>/delete/", category_delete, name="category_delete"),
37
+    path("categories/<slug:slug>/edit/", category_edit, name="category_edit"),
38
+    path("drafts/", DraftEntriesView.as_view(), name="draft_entries"),
39
+    path("entries/all/", AllEntriesView.as_view(), name="all_entries"),
40
+    path("entries/new/", entry_create, name="new_entry"),
41
+    path(
42
+        "feeds/latest-entries/",
43
+        cache_page(settings.CACHE_MIDDLEWARE_SECONDS)(LatestEntriesFeed()),
44
+        name="latest_entries_feed",
45
+    ),
46
+    path("hidden/", HiddenEntriesView.as_view(), name="hidden_entries"),
47
+    path("tag/cloud/", TagCloudView.as_view(), name="tag_cloud"),
48
+    path("tag/<slug:slug>/", TagDetailView.as_view(), name="tag_detail"),
49
+    path("tag/<slug:slug>/edit/", tag_edit, name="tag_edit"),
50
+    path("<slug:slug>/delete/", entry_delete, name="entry_delete"),
51
+    path("<slug:slug>/edit/", entry_edit, name="entry_edit"),
52
+    path("<int:year>/", EntriesByYearView.as_view(), name="by_year"),
53
+    path("<int:year>/<int:month>/", EntriesByMonthView.as_view(), name="by_month"),
54
+    path(
55
+        "<int:year>/<int:month>/<int:day>/", EntriesByDayView.as_view(), name="by_day"
56
+    ),
57
+    path(
58
+        "<int:year>/<int:month>/<int:day>/<slug:slug>/",
59
+        EntryDetailView.as_view(),
60
+        name="entry_detail",
61
+    ),
43 62
 ]

+ 143
- 93
momw/chroniko/views.py View File

@@ -4,125 +4,130 @@ from django.contrib.auth.mixins import LoginRequiredMixin
4 4
 from django.contrib.contenttypes.models import ContentType
5 5
 from django.http import Http404, HttpResponseRedirect
6 6
 from django.shortcuts import render, reverse, get_object_or_404
7
-from django.views.generic import (DayArchiveView, DetailView, ListView,
8
-                                  MonthArchiveView, YearArchiveView)
7
+from django.views.generic import (
8
+    DayArchiveView,
9
+    DetailView,
10
+    ListView,
11
+    MonthArchiveView,
12
+    YearArchiveView,
13
+)
9 14
 from utilz.cache import CacheCtl
10
-from . import (CHANGE_CATEGORY_PERM, CHANGE_ENTRY_PERM,
11
-               ENTRY_DATE_FIELD)
12
-from .forms import CategoryForm, DeleteThingForm, EntryForm, TagForm, \
13
-    ToggleTinyMCEForm
15
+from . import CHANGE_CATEGORY_PERM, CHANGE_ENTRY_PERM, ENTRY_DATE_FIELD
16
+from .forms import CategoryForm, DeleteThingForm, EntryForm, TagForm, ToggleTinyMCEForm
14 17
 from .models import BlogCategory, BlogEntry, BlogTag, TaggedEntry
15 18
 
16 19
 
17 20
 # TODO: use a mixin for pagination
18 21
 class AllEntriesView(CacheCtl, ListView):
19
-    context_object_name = 'all_entries'
22
+    context_object_name = "all_entries"
20 23
     date_field = ENTRY_DATE_FIELD
21 24
     queryset = BlogEntry.live.all()
22
-    template_name = 'all_entries.html'
25
+    template_name = "all_entries.html"
23 26
     paginate_by = settings.PAGINATE_BY
24 27
 
25 28
 
26 29
 class DraftEntriesView(LoginRequiredMixin, ListView):
27
-    context_object_name = 'draft_entries'
30
+    context_object_name = "draft_entries"
28 31
     date_field = ENTRY_DATE_FIELD
29 32
     queryset = BlogEntry.draft.all()
30 33
     raise_exception = True
31
-    template_name = 'draft_entries.html'
34
+    template_name = "draft_entries.html"
32 35
     paginate_by = settings.PAGINATE_BY
33 36
 
34 37
 
35 38
 class EntriesByDayView(CacheCtl, DayArchiveView):
36
-    context_object_name = 'entries_by_day'
39
+    context_object_name = "entries_by_day"
37 40
     date_field = ENTRY_DATE_FIELD
38 41
     make_object_list = True
39 42
     month_format = settings.MONTH_FORMAT
40 43
     paginate_by = settings.PAGINATE_BY
41 44
     queryset = BlogEntry.live.all()
42
-    template_name = 'entries_by_day.html'
45
+    template_name = "entries_by_day.html"
43 46
     paginate_by = settings.PAGINATE_BY
44 47
 
45 48
 
46 49
 class EntriesByMonthView(CacheCtl, MonthArchiveView):
47
-    context_object_name = 'entries_by_month'
50
+    context_object_name = "entries_by_month"
48 51
     date_field = ENTRY_DATE_FIELD
49 52
     make_object_list = True
50 53
     month_format = settings.MONTH_FORMAT
51 54
     paginate_by = settings.PAGINATE_BY
52 55
     queryset = BlogEntry.live.all()
53
-    template_name = 'entries_by_month.html'
56
+    template_name = "entries_by_month.html"
54 57
     paginate_by = settings.PAGINATE_BY
55 58
 
56 59
 
57 60
 class EntriesByYearView(CacheCtl, YearArchiveView):
58
-    context_object_name = 'entries_by_year'
61
+    context_object_name = "entries_by_year"
59 62
     date_field = ENTRY_DATE_FIELD
60 63
     make_object_list = True
61 64
     month_format = settings.MONTH_FORMAT
62 65
     paginate_by = settings.PAGINATE_BY
63 66
     queryset = BlogEntry.live.all()
64
-    template_name = 'entries_by_year.html'
67
+    template_name = "entries_by_year.html"
65 68
     paginate_by = settings.PAGINATE_BY
66 69
 
67 70
 
68 71
 class EntryDetailView(CacheCtl, DetailView):
69
-    context_object_name = 'entry'
72
+    context_object_name = "entry"
70 73
     model = BlogEntry
71 74
     month_format = settings.MONTH_FORMAT
72 75
     queryset = BlogEntry.live.all()
73
-    template_name = 'entry_detail.html'
76
+    template_name = "entry_detail.html"
74 77
     paginate_by = settings.PAGINATE_BY
75 78
 
76 79
 
77 80
 class EntryIndexView(CacheCtl, ListView):
78
-    context_object_name = 'entry_list'
81
+    context_object_name = "entry_list"
79 82
     date_field = ENTRY_DATE_FIELD
80 83
     paginate_by = settings.PAGINATE_BY
81 84
     paginate_orphans = 4
82 85
     queryset = BlogEntry.live.all()
83
-    template_name = 'entry_index.html'
86
+    template_name = "entry_index.html"
84 87
     paginate_by = settings.PAGINATE_BY
85 88
 
86 89
 
87 90
 class HiddenEntriesView(LoginRequiredMixin, ListView):
88
-    context_object_name = 'hidden_entries'
91
+    context_object_name = "hidden_entries"
89 92
     date_field = ENTRY_DATE_FIELD
90 93
     queryset = BlogEntry.hidden.all()
91 94
     raise_exception = True
92
-    template_name = 'hidden_entries.html'
95
+    template_name = "hidden_entries.html"
93 96
     paginate_by = settings.PAGINATE_BY
94 97
 
95 98
 
96 99
 class CategoryDetailView(CacheCtl, DetailView):
97
-    context_object_name = 'category'
100
+    context_object_name = "category"
98 101
     model = BlogCategory
99
-    template_name = 'category_detail.html'
102
+    template_name = "category_detail.html"
100 103
     paginate_by = settings.PAGINATE_BY
101 104
 
102 105
     def get_context_data(self, **kwargs):
103 106
         context = super(CategoryDetailView, self).get_context_data(**kwargs)
104
-        context['category_live_entries'] = BlogEntry.live.filter(category=context['object'].pk)
107
+        context["category_live_entries"] = BlogEntry.live.filter(
108
+            category=context["object"].pk
109
+        )
105 110
         return context
106 111
 
107 112
 
108 113
 class CategoryIndexView(CacheCtl, ListView):
109
-    context_object_name = 'categories'
114
+    context_object_name = "categories"
110 115
     model = BlogCategory
111
-    template_name = 'category_index.html'
116
+    template_name = "category_index.html"
112 117
     paginate_by = settings.PAGINATE_BY
113 118
 
114 119
 
115 120
 class TagCloudView(CacheCtl, ListView):
116
-    context_object_name = 'tags'
121
+    context_object_name = "tags"
117 122
     queryset = BlogTag.enabled.all()
118
-    template_name = 'tag_cloud.html'
123
+    template_name = "tag_cloud.html"
119 124
     paginate_by = settings.PAGINATE_BY
120 125
 
121 126
 
122 127
 class TagDetailView(CacheCtl, DetailView):
123
-    context_object_name = 'tag'
128
+    context_object_name = "tag"
124 129
     model = BlogTag
125
-    template_name = 'tag_detail.html'
130
+    template_name = "tag_detail.html"
126 131
     paginate_by = settings.PAGINATE_BY
127 132
 
128 133
 
@@ -130,7 +135,7 @@ def category_create(request):
130 135
     form = CategoryForm()
131 136
     user = request.user
132 137
     if user.is_authenticated and user.has_perm(CHANGE_CATEGORY_PERM):
133
-        if request.method == 'POST':
138
+        if request.method == "POST":
134 139
             postdata = request.POST.copy()
135 140
             form = CategoryForm(postdata)
136 141
             if form.is_valid():
@@ -138,10 +143,9 @@ def category_create(request):
138 143
                 # Redirect to the Category's edit page,
139 144
                 # in case the slug was changed.
140 145
                 return HttpResponseRedirect(
141
-                    reverse("blog:category_edit",
142
-                            kwargs={"slug": postdata.get("slug")}))
143
-        return render(request, 'category_create.html',
144
-                      {'form': form})
146
+                    reverse("blog:category_edit", kwargs={"slug": postdata.get("slug")})
147
+                )
148
+        return render(request, "category_create.html", {"form": form})
145 149
     else:
146 150
         raise Http404
147 151
 
@@ -159,7 +163,7 @@ def category_edit(request, slug):
159 163
     form = CategoryForm()
160 164
     user = request.user
161 165
     if user.is_authenticated and user.has_perm(CHANGE_CATEGORY_PERM):
162
-        if request.method == 'POST':
166
+        if request.method == "POST":
163 167
             postdata = request.POST.copy()
164 168
             form = CategoryForm(postdata, instance=category)
165 169
             if form.is_valid():
@@ -167,18 +171,18 @@ def category_edit(request, slug):
167 171
                 # Redirect to the Category's edit page,
168 172
                 # in case the slug was changed.
169 173
                 return HttpResponseRedirect(
170
-                    reverse("blog:category_edit",
171
-                            kwargs={"slug": postdata.get("slug")}))
172
-        return render(request, 'category_edit.html',
173
-                      {'category': category,
174
-                       'form': form})
174
+                    reverse("blog:category_edit", kwargs={"slug": postdata.get("slug")})
175
+                )
176
+        return render(
177
+            request, "category_edit.html", {"category": category, "form": form}
178
+        )
175 179
     else:
176 180
         raise Http404
177 181
 
178 182
 
179 183
 def entry_create(request):
180 184
     """Create a new Entry."""
181
-    datetime_format = '%Y-%m-%d %H:%M:%S %z'
185
+    datetime_format = "%Y-%m-%d %H:%M:%S %z"
182 186
     user = request.user
183 187
     try:
184 188
         toggle_tinymce = settings.USE_TINYMCE
@@ -187,7 +191,7 @@ def entry_create(request):
187 191
     if user.is_authenticated and user.has_perm(CHANGE_ENTRY_PERM):
188 192
         form = EntryForm()
189 193
         toggleform = ToggleTinyMCEForm()
190
-        if request.method == 'POST':
194
+        if request.method == "POST":
191 195
             postdata = request.POST.copy()
192 196
             if "toggleTinyMCE" not in postdata:
193 197
                 form = EntryForm(postdata)
@@ -198,40 +202,57 @@ def entry_create(request):
198 202
                     new_date = postdata.get("date_added_0", None)
199 203
                     new_time = postdata.get("date_added_1", None)
200 204
                     if new_date and new_time:
201
-                        new_datetime_string = ' '.join((new_date, ''.join((
202
-                            new_time, " ".join((":00", settings.TIME_ZONE_OFFSET))))))
203
-                        new_datetime = datetime.strptime(new_datetime_string, datetime_format)
205
+                        new_datetime_string = " ".join(
206
+                            (
207
+                                new_date,
208
+                                "".join(
209
+                                    (
210
+                                        new_time,
211
+                                        " ".join((":00", settings.TIME_ZONE_OFFSET)),
212
+                                    )
213
+                                ),
214
+                            )
215
+                        )
216
+                        new_datetime = datetime.strptime(
217
+                            new_datetime_string, datetime_format
218
+                        )
204 219
                         entry.date_added = new_datetime
205 220
                     form.save()
206 221
                     # Update the Entry's tags if need be.
207 222
                     new_tags = postdata.get("tags", None)
208 223
                     if new_tags:
209
-                        for t in new_tags.split(', '):
224
+                        for t in new_tags.split(", "):
210 225
                             entry.tags.add(t)
211 226
                             tag = BlogTag.objects.get(name=t)
212
-                            entry_content_type = ContentType.objects.get_for_model(BlogEntry)
227
+                            entry_content_type = ContentType.objects.get_for_model(
228
+                                BlogEntry
229
+                            )
213 230
                             TaggedEntry(
214 231
                                 content_type_id=entry_content_type.id,
215 232
                                 object_id=entry.id,
216
-                                tag=tag).save()
233
+                                tag=tag,
234
+                            ).save()
217 235
                     # Redirect to the Entry's edit page,
218 236
                     # in case the slug was changed.
219 237
                     return HttpResponseRedirect(
220
-                        reverse("slug_entry_edit",
221
-                                kwargs={"slug": postdata.get("slug")}))
238
+                        reverse(
239
+                            "slug_entry_edit", kwargs={"slug": postdata.get("slug")}
240
+                        )
241
+                    )
222 242
             elif "toggleTinyMCE" in postdata:
223 243
                 form = EntryForm()
224 244
                 toggleform = ToggleTinyMCEForm(postdata)
225 245
                 if toggleform.is_valid():
226
-                    if postdata.get("toggle_tinymce", None) == 'on':
246
+                    if postdata.get("toggle_tinymce", None) == "on":
227 247
                         toggle_tinymce = True
228 248
         else:  # if request.method == 'POST':
229 249
             postdata = None
230 250
             toggleform = ToggleTinyMCEForm()
231
-        return render(request, 'entry_create.html',
232
-                      {"form": form,
233
-                       "toggle_tinymce": toggle_tinymce,
234
-                       'toggleform': toggleform})
251
+        return render(
252
+            request,
253
+            "entry_create.html",
254
+            {"form": form, "toggle_tinymce": toggle_tinymce, "toggleform": toggleform},
255
+        )
235 256
     else:  # if user.is_authenticated and user.has_perm(CHANGE_ENTRY_PERM):
236 257
         # Anonymous user
237 258
         raise Http404
@@ -242,7 +263,7 @@ def tag_edit(request, slug):
242 263
     form = TagForm()
243 264
     user = request.user
244 265
     if user.is_authenticated and user.has_perm(CHANGE_CATEGORY_PERM):
245
-        if request.method == 'POST':
266
+        if request.method == "POST":
246 267
             postdata = request.POST.copy()
247 268
             form = TagForm(postdata, instance=tag)
248 269
             if form.is_valid():
@@ -250,11 +271,9 @@ def tag_edit(request, slug):
250 271
                 # Redirect to the Category's edit page,
251 272
                 # in case the slug was changed.
252 273
                 return HttpResponseRedirect(
253
-                    reverse("blog:tag_edit",
254
-                            kwargs={"slug": postdata.get("slug")}))
255
-        return render(request, 'tag_edit.html',
256
-                      {'tag': tag,
257
-                       'form': form})
274
+                    reverse("blog:tag_edit", kwargs={"slug": postdata.get("slug")})
275
+                )
276
+        return render(request, "tag_edit.html", {"tag": tag, "form": form})
258 277
     else:
259 278
         raise Http404
260 279
 
@@ -275,22 +294,32 @@ def entry_delete(request, slug):
275 294
     if user.is_authenticated and user.has_perm(CHANGE_ENTRY_PERM):
276 295
         entry = get_object_or_404(BlogEntry, slug=slug)
277 296
         form = DeleteThingForm()
278
-        if request.method == 'POST':
297
+        if request.method == "POST":
279 298
             postdata = request.POST.copy()
280 299
             form = DeleteThingForm(postdata)
281 300
             if form.is_valid():
282 301
                 deleted_name = entry.__str__()
283 302
                 deleted = _delete_entry(entry)
284
-                return render(request, 'entry_delete.html', {
285
-                    "deleted": deleted,
286
-                    "deleted_name": deleted_name,
287
-                    "entry": entry,
288
-                    "form": form})
289
-        return render(request, 'entry_delete.html', {
290
-            "deleted": deleted,
291
-            "deleted_name": deleted_name,
292
-            "entry": entry,
293
-            "form": form})
303
+                return render(
304
+                    request,
305
+                    "entry_delete.html",
306
+                    {
307
+                        "deleted": deleted,
308
+                        "deleted_name": deleted_name,
309
+                        "entry": entry,
310
+                        "form": form,
311
+                    },
312
+                )
313
+        return render(
314
+            request,
315
+            "entry_delete.html",
316
+            {
317
+                "deleted": deleted,
318
+                "deleted_name": deleted_name,
319
+                "entry": entry,
320
+                "form": form,
321
+            },
322
+        )
294 323
     else:  # if user.is_authenticated and user.has_perm(CHANGE_ENTRY_PERM):
295 324
         # Anonymous user
296 325
         raise Http404
@@ -300,7 +329,7 @@ def entry_edit(request, slug):
300 329
     """Edit the Entry with the slug 'slug'."""
301 330
     date_string = "%Y-%m-%d"
302 331
     time_string = "%H:%M"
303
-    datetime_format = '%Y-%m-%d %H:%M:%S %z'
332
+    datetime_format = "%Y-%m-%d %H:%M:%S %z"
304 333
     entry = get_object_or_404(BlogEntry, slug=slug)
305 334
     entry_date_added = entry.date_added.astimezone().date().strftime(date_string)
306 335
     entry_time_added = entry.date_added.astimezone().time().strftime(time_string)
@@ -313,7 +342,7 @@ def entry_edit(request, slug):
313 342
     [entry_tag_list.append(t.name) for t in entry.tags.all()]
314 343
     if user.is_authenticated and user.has_perm(CHANGE_ENTRY_PERM):
315 344
         toggleform = ToggleTinyMCEForm()
316
-        if request.method == 'POST':
345
+        if request.method == "POST":
317 346
             postdata = request.POST.copy()
318 347
             # We are trying to post changes to an Entry.
319 348
             if "toggleTinyMCE" not in postdata:
@@ -324,9 +353,20 @@ def entry_edit(request, slug):
324 353
                     new_date = postdata.get("date_added_0", None)
325 354
                     new_time = postdata.get("date_added_1", None)
326 355
                     if new_date and new_time:
327
-                        new_datetime_string = ' '.join((new_date, ''.join((
328
-                            new_time, " ".join((":00", settings.TIME_ZONE_OFFSET))))))
329
-                        new_datetime = datetime.strptime(new_datetime_string, datetime_format)
356
+                        new_datetime_string = " ".join(
357
+                            (
358
+                                new_date,
359
+                                "".join(
360
+                                    (
361
+                                        new_time,
362
+                                        " ".join((":00", settings.TIME_ZONE_OFFSET)),
363
+                                    )
364
+                                ),
365
+                            )
366
+                        )
367
+                        new_datetime = datetime.strptime(
368
+                            new_datetime_string, datetime_format
369
+                        )
330 370
                         entry.date_added = new_datetime
331 371
                         entry.save()
332 372
                     # Update the Entry's tags if need be.
@@ -335,37 +375,47 @@ def entry_edit(request, slug):
335 375
                             if t not in entry_tag_list:
336 376
                                 entry.tags.add(t)
337 377
                                 tag = BlogTag.objects.get(name=t)
338
-                                entry_content_type = ContentType.objects.get_for_model(BlogEntry)
378
+                                entry_content_type = ContentType.objects.get_for_model(
379
+                                    BlogEntry
380
+                                )
339 381
                                 TaggedEntry(
340 382
                                     content_type_id=entry_content_type.id,
341 383
                                     object_id=entry.id,
342
-                                    tag=tag).save()
384
+                                    tag=tag,
385
+                                ).save()
343 386
                     # Redirect to the Entry's edit page,
344 387
                     # in case the slug was changed.
345 388
                     # TODO: pass along some sort of message when this is done
346 389
                     return HttpResponseRedirect(
347
-                        reverse("slug_entry_edit",
348
-                                kwargs={"slug": postdata.get("slug")}))
390
+                        reverse(
391
+                            "slug_entry_edit", kwargs={"slug": postdata.get("slug")}
392
+                        )
393
+                    )
349 394
             elif "toggleTinyMCE" in postdata:
350 395
                 form = EntryForm(instance=entry)
351 396
                 toggleform = ToggleTinyMCEForm(postdata)
352 397
                 if toggleform.is_valid():
353
-                    if postdata.get("toggle_tinymce", None) == 'on':
398
+                    if postdata.get("toggle_tinymce", None) == "on":
354 399
                         toggle_tinymce = True
355 400
         else:  # if request.method == 'POST':
356 401
             # We are just looking at an Entry
357 402
             form = EntryForm(instance=entry)
358 403
             postdata = None
359 404
             toggleform = toggleform = ToggleTinyMCEForm()
360
-        return render(request, 'entry_edit.html',
361
-                      {'entry': entry,
362
-                       'entry_date_added': entry_date_added,
363
-                       'entry_time_added': entry_time_added,
364
-                       'entry_tag_list': ', '.join(entry_tag_list),
365
-                       'form': form,
366
-                       'postdata': postdata,
367
-                       'toggle_tinymce': toggle_tinymce,
368
-                       'toggleform': toggleform})
405
+        return render(
406
+            request,
407
+            "entry_edit.html",
408
+            {
409
+                "entry": entry,
410
+                "entry_date_added": entry_date_added,
411
+                "entry_time_added": entry_time_added,
412
+                "entry_tag_list": ", ".join(entry_tag_list),
413
+                "form": form,
414
+                "postdata": postdata,
415
+                "toggle_tinymce": toggle_tinymce,
416
+                "toggleform": toggleform,
417
+            },
418
+        )
369 419
     else:  # if user.is_authenticated and user.has_perm(CHANGE_ENTRY_PERM):
370 420
         # Anonymous user
371 421
         raise Http404

+ 2
- 2
momw/media/__init__.py View File

@@ -1,4 +1,4 @@
1 1
 ADD_MEDIA_PERM = "media.add_mediatrack"
2 2
 CHANGE_MEDIA_PERM = "media.add_mediatrack"
3
-MEDIA_DATE_FIELD = 'date_added'
4
-MONTH_FORMAT = '%m'
3
+MEDIA_DATE_FIELD = "date_added"
4
+MONTH_FORMAT = "%m"

+ 1
- 1
momw/media/apps.py View File

@@ -2,4 +2,4 @@ from django.apps import AppConfig
2 2
 
3 3
 
4 4
 class MediaConfig(AppConfig):
5
-    name = 'media'
5
+    name = "media"

+ 37
- 13
momw/media/data_seeds/media.py View File

@@ -10,7 +10,7 @@ User = get_user_model()
10 10
 
11 11
 
12 12
 def media_factory():
13
-    datetime_format = '%Y-%m-%d %H:%M:%S %z'
13
+    datetime_format = "%Y-%m-%d %H:%M:%S %z"
14 14
     u = User.objects.get(pk=1)
15 15
     desc1 = """Using <a href="https://raw.githubusercontent.com/hristoast/dot-emacs/master/init.el">my Emacs configuration</a>.  C/C++ are the focus of this
16 16
 clip, but you'll be set up for much more.  Downloading packages finishes at 1:00ish.  The following modes make this possible: <code>cc-mode</code>,
@@ -35,21 +35,45 @@ clip, but you'll be set up for much more.  Downloading packages finishes at 1:00
35 35
     slug4 = "a-funny-thing-happened-moon-landing-is-fake-sir"
36 36
 
37 37
     m1 = MediaTrack.objects.create(
38
-        author=u, description=desc1, title=title1, url=url1, slug=slug1,
39
-        media_type=MediaTrack.ASCIINEMA, status=MediaTrack.LIVE,
40
-        date_added=datetime.strptime('2011-02-22 16:34:34 -0500', datetime_format))
38
+        author=u,
39
+        description=desc1,
40
+        title=title1,
41
+        url=url1,
42
+        slug=slug1,
43
+        media_type=MediaTrack.ASCIINEMA,
44
+        status=MediaTrack.LIVE,
45
+        date_added=datetime.strptime("2011-02-22 16:34:34 -0500", datetime_format),
46
+    )
41 47
     m2 = MediaTrack.objects.create(
42
-        author=u, description=desc2, title=title2, url=url2, slug=slug2,
43
-        media_type=MediaTrack.ASCIINEMA, status=MediaTrack.LIVE,
44
-        date_added=datetime.strptime('2011-01-19 10:34:34 -0500', datetime_format))
48
+        author=u,
49
+        description=desc2,
50
+        title=title2,
51
+        url=url2,
52
+        slug=slug2,
53
+        media_type=MediaTrack.ASCIINEMA,
54
+        status=MediaTrack.LIVE,
55
+        date_added=datetime.strptime("2011-01-19 10:34:34 -0500", datetime_format),
56
+    )
45 57
     m3 = MediaTrack.objects.create(
46
-        author=u, description=desc3, title=title3, url=url3, slug=slug3,
47
-        media_type=MediaTrack.AUDIO, status=MediaTrack.LIVE,
48
-        date_added=datetime.strptime('2010-12-18 14:34:34 -0500', datetime_format))
58
+        author=u,
59
+        description=desc3,
60
+        title=title3,
61
+        url=url3,
62
+        slug=slug3,
63
+        media_type=MediaTrack.AUDIO,
64
+        status=MediaTrack.LIVE,
65
+        date_added=datetime.strptime("2010-12-18 14:34:34 -0500", datetime_format),
66
+    )
49 67
     m4 = MediaTrack.objects.create(
50
-        author=u, description=desc4, title=title4, url=url4, slug=slug4,
51
-        media_type=MediaTrack.VIDEO, status=MediaTrack.LIVE,
52
-        date_added=datetime.strptime('2015-01-19 10:34:34 -0500', datetime_format))
68
+        author=u,
69
+        description=desc4,
70
+        title=title4,
71
+        url=url4,
72
+        slug=slug4,
73
+        media_type=MediaTrack.VIDEO,
74
+        status=MediaTrack.LIVE,
75
+        date_added=datetime.strptime("2015-01-19 10:34:34 -0500", datetime_format),
76
+    )
53 77
 
54 78
     m1.save()
55 79
     m2.save()

+ 2
- 2
momw/media/feeds.py View File

@@ -13,7 +13,7 @@ DESCRIPTION = TITLE
13 13
 
14 14
 class LatestMediaFeed(Feed):
15 15
     description = DESCRIPTION
16
-    link = '/media/'  # TODO: find out wtf this is for
16
+    link = "/media/"  # TODO: find out wtf this is for
17 17
     title = TITLE
18 18
 
19 19
     def items(self):
@@ -26,4 +26,4 @@ class LatestMediaFeed(Feed):
26 26
         return item.description
27 27
 
28 28
     def item_link(self, item):
29
-        return reverse('media:detail', kwargs={'slug': item.slug})
29
+        return reverse("media:detail", kwargs={"slug": item.slug})

+ 7
- 7
momw/media/forms.py View File

@@ -5,14 +5,14 @@ from .models import MediaTrack
5 5
 class MediaTrackForm(forms.ModelForm):
6 6
     def __init__(self, *args, **kwargs):
7 7
         super().__init__(*args, **kwargs)
8
-        self.fields['media_type'].widget.attrs['class'] = 'u-full-width'
9
-        self.fields['other_html'].label = "Other HTML"
10
-        self.fields['other_html'].required = False
11
-        self.fields['status'].widget.attrs['class'] = 'u-full-width'
8
+        self.fields["media_type"].widget.attrs["class"] = "u-full-width"
9
+        self.fields["other_html"].label = "Other HTML"
10
+        self.fields["other_html"].required = False
11
+        self.fields["status"].widget.attrs["class"] = "u-full-width"
12 12
 
13 13
     class Meta:
14
-        exclude = ('author', 'pub_date')
14
+        exclude = ("author", "pub_date")
15 15
         model = MediaTrack
16 16
 
17
-    pub_date_0 = forms.DateField(label='Publish Date', required=True)
18
-    pub_date_1 = forms.TimeField(label='Publish Time', required=True)
17
+    pub_date_0 = forms.DateField(label="Publish Date", required=True)
18
+    pub_date_1 = forms.TimeField(label="Publish Time", required=True)

+ 45
- 15
momw/media/migrations/0001_initial.py View File

@@ -11,24 +11,54 @@ class Migration(migrations.Migration):
11 11
 
12 12
     initial = True
13 13
 
14
-    dependencies = [
15
-        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
16
-    ]
14
+    dependencies = [migrations.swappable_dependency(settings.AUTH_USER_MODEL)]
17 15
 
18 16
     operations = [
19 17
         migrations.CreateModel(
20
-            name='MediaTrack',
18
+            name="MediaTrack",
21 19
             fields=[
22
-                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
23
-                ('description', models.TextField()),
24
-                ('media_type', models.IntegerField(choices=[(1, 'Asciinema'), (2, 'Audio'), (3, 'Video')], default=2)),
25
-                ('other_html', models.CharField(help_text='For things like YouTube video links and etc.', max_length=200, null=True)),
26
-                ('pub_date', models.DateTimeField()),
27
-                ('slug', models.SlugField(unique=True)),
28
-                ('status', models.IntegerField(choices=[(1, 'Live'), (2, 'Draft'), (3, 'Hidden')], default=2)),
29
-                ('title', models.CharField(max_length=200)),
30
-                ('url', models.URLField(help_text='URL of the file.')),
31
-                ('author', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
20
+                (
21
+                    "id",
22
+                    models.AutoField(
23
+                        auto_created=True,
24
+                        primary_key=True,
25
+                        serialize=False,
26
+                        verbose_name="ID",
27
+                    ),
28
+                ),
29
+                ("description", models.TextField()),
30
+                (
31
+                    "media_type",
32
+                    models.IntegerField(
33
+                        choices=[(1, "Asciinema"), (2, "Audio"), (3, "Video")],
34
+                        default=2,
35
+                    ),
36
+                ),
37
+                (
38
+                    "other_html",
39
+                    models.CharField(
40
+                        help_text="For things like YouTube video links and etc.",
41
+                        max_length=200,
42
+                        null=True,
43
+                    ),
44
+                ),
45
+                ("pub_date", models.DateTimeField()),
46
+                ("slug", models.SlugField(unique=True)),
47
+                (
48
+                    "status",
49
+                    models.IntegerField(
50
+                        choices=[(1, "Live"), (2, "Draft"), (3, "Hidden")], default=2
51
+                    ),
52
+                ),
53
+                ("title", models.CharField(max_length=200)),
54
+                ("url", models.URLField(help_text="URL of the file.")),
55
+                (
56
+                    "author",
57
+                    models.ForeignKey(
58
+                        on_delete=django.db.models.deletion.CASCADE,
59
+                        to=settings.AUTH_USER_MODEL,
60
+                    ),
61
+                ),
32 62
             ],
33
-        ),
63
+        )
34 64
     ]

+ 3
- 6
momw/media/migrations/0002_auto_20171110_1604.py View File

@@ -7,13 +7,10 @@ from django.db import migrations
7 7
 
8 8
 class Migration(migrations.Migration):
9 9
 
10
-    dependencies = [
11
-        ('media', '0001_initial'),
12
-    ]
10
+    dependencies = [("media", "0001_initial")]
13 11
 
14 12
     operations = [
15 13
         migrations.AlterModelOptions(
16
-            name='mediatrack',
17
-            options={'ordering': ['-pub_date']},
18
-        ),
14
+            name="mediatrack", options={"ordering": ["-pub_date"]}
15
+        )
19 16
     ]

+ 10
- 13
momw/media/migrations/0003_auto_20180107_1358.py View File

@@ -7,28 +7,25 @@ import django.db.models.deletion
7 7
 
8 8
 class Migration(migrations.Migration):
9 9
 
10
-    dependencies = [
11
-        ('media', '0002_auto_20171110_1604'),
12
-    ]
10
+    dependencies = [("media", "0002_auto_20171110_1604")]
13 11
 
14 12
     operations = [
15 13
         migrations.AlterModelOptions(
16
-            name='mediatrack',
17
-            options={'ordering': ['-date_added']},
14
+            name="mediatrack", options={"ordering": ["-date_added"]}
18 15
         ),
19 16
         migrations.RenameField(
20
-            model_name='mediatrack',
21
-            old_name='pub_date',
22
-            new_name='date_added',
17
+            model_name="mediatrack", old_name="pub_date", new_name="date_added"
23 18
         ),
24 19
         migrations.AddField(
25
-            model_name='mediatrack',
26
-            name='date_updated',
20
+            model_name="mediatrack",
21
+            name="date_updated",
27 22
             field=models.DateTimeField(auto_now=True),
28 23
         ),
29 24
         migrations.AlterField(
30
-            model_name='mediatrack',
31
-            name='author',
32
-            field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to=settings.AUTH_USER_MODEL),
25
+            model_name="mediatrack",
26
+            name="author",
27
+            field=models.ForeignKey(
28
+                on_delete=django.db.models.deletion.PROTECT, to=settings.AUTH_USER_MODEL
29
+            ),
33 30
         ),
34 31
     ]

+ 8
- 7
momw/media/migrations/0004_auto_20190504_2044.py View File

@@ -5,14 +5,15 @@ from django.db import migrations, models
5 5
 
6 6
 class Migration(migrations.Migration):
7 7
 
8
-    dependencies = [
9
-        ('media', '0003_auto_20180107_1358'),
10
-    ]
8
+    dependencies = [("media", "0003_auto_20180107_1358")]
11 9
 
12 10
     operations = [
13 11
         migrations.AlterField(
14
-            model_name='mediatrack',
15
-            name='media_type',
16
-            field=models.IntegerField(choices=[(1, 'Asciinema'), (2, 'Audio'), (3, 'Video'), (4, 'Image')], default=2),
17
-        ),
12
+            model_name="mediatrack",
13
+            name="media_type",
14
+            field=models.IntegerField(
15
+                choices=[(1, "Asciinema"), (2, "Audio"), (3, "Video"), (4, "Image")],
16
+                default=2,
17
+            ),
18
+        )
18 19
     ]

+ 34
- 21
momw/media/models.py View File