File python-django-waliki-django21-no-view_page.patch of Package python-django-waliki

From f0d18a83a17ef942569ce022d2d6889dd0c19b1b Mon Sep 17 00:00:00 2001
From: Oleg Girko <ol@infoserver.lv>
Date: Sat, 27 Apr 2019 00:04:53 +0100
Subject: [PATCH] Don't add view_page permission for Django version 2.1 or
 newer.

Django 2.1 introduced builtin view permission for all models,
so adding view_page permission causes database constraint violation.

Signed-off-by: Oleg Girko <ol@infoserver.lv>
---
 waliki/migrations/0001_initial.py | 5 ++++-
 waliki/models.py                  | 7 ++++---
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/waliki/migrations/0001_initial.py b/waliki/migrations/0001_initial.py
index 118a8a9..afb5146 100644
--- a/waliki/migrations/0001_initial.py
+++ b/waliki/migrations/0001_initial.py
@@ -3,6 +3,7 @@ from __future__ import unicode_literals
 
 from django.db import models, migrations
 from django.conf import settings
+from django import VERSION
 
 
 class Migration(migrations.Migration):
@@ -40,7 +41,9 @@ class Migration(migrations.Migration):
                 ('markup', models.CharField(max_length=20, default='reStructuredText', choices=[('reStructuredText', 'reStructuredText'), ('Markdown', 'Markdown')], verbose_name='Markup')),
             ],
             options={
-                'permissions': (('view_page', 'Can view page'),),
+                'permissions':
+                    (('view_page', 'Can view page'),)
+                        if VERSION[:2] < (2, 1) else (),
                 'verbose_name_plural': 'Pages',
                 'verbose_name': 'Page',
             },
diff --git a/waliki/models.py b/waliki/models.py
index 198d868..8eb6707 100644
--- a/waliki/models.py
+++ b/waliki/models.py
@@ -37,9 +37,10 @@ class Page(models.Model):
     class Meta:
         verbose_name = _('Page')
         verbose_name_plural = _('Pages')
-        permissions = (
-            ('view_page', 'Can view page'),
-        )
+        if VERSION[:2] < (2, 1):
+            permissions = (
+                ('view_page', 'Can view page'),
+            )
 
     class EditionConflict(Exception):
         pass
-- 
2.20.1