From dccde771896d26febac924ddc837406abe00c90e Mon Sep 17 00:00:00 2001 From: Gustavo Andres Morero Date: Fri, 15 May 2020 19:04:00 -0300 Subject: [PATCH] adding Article inherited_from for permissions handling. --- .../migrations/0004_article_inherited_from.py | 19 +++++++++++++++++++ src/wiki/models/article.py | 5 +++++ 2 files changed, 24 insertions(+) create mode 100644 src/wiki/migrations/0004_article_inherited_from.py diff --git a/src/wiki/migrations/0004_article_inherited_from.py b/src/wiki/migrations/0004_article_inherited_from.py new file mode 100644 index 00000000..2fe97260 --- /dev/null +++ b/src/wiki/migrations/0004_article_inherited_from.py @@ -0,0 +1,19 @@ +# Generated by Django 2.2.12 on 2020-05-15 12:59 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('wiki', '0003_article_search_vector'), + ] + + operations = [ + migrations.AddField( + model_name='article', + name='inherited_from', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='inherit_children', to='wiki.Article'), + ), + ] diff --git a/src/wiki/models/article.py b/src/wiki/models/article.py index bf319ac8..8e57d3cb 100644 --- a/src/wiki/models/article.py +++ b/src/wiki/models/article.py @@ -77,6 +77,11 @@ class Article(models.Model): search_vector = SearchVectorField(null=True) + inherited_from = models.ForeignKey( + 'self', related_name='inherit_children', + null=True, blank=True, on_delete=models.SET_NULL, + ) + # PERMISSIONS def can_read(self, user): return permissions.can_read(self, user) -- 2.45.2