Kaynağa Gözat

Initial access cotrol implemented

master
Dirk Alders 2 ay önce
ebeveyn
işleme
b8606bc0b5

+ 61
- 3
pages/access.py Dosyayı Görüntüle

@@ -1,14 +1,72 @@
1
+from django.conf import settings
2
+import logging
3
+
4
+from .models import PikiPage
5
+
6
+logger = logging.getLogger(settings.ROOT_LOGGER_NAME).getChild(__name__)
7
+
8
+
1 9
 class access_control(object):
2 10
     def __init__(self, request, rel_path):
3 11
         self._request = request
4 12
         self._rel_path = rel_path
13
+        self._user = request.user
14
+        try:
15
+            self._page = PikiPage.objects.get(rel_path=rel_path)
16
+        except PikiPage.DoesNotExist:
17
+            self._page = None
18
+        self._read = None
19
+        self._write = None
20
+
21
+    def __analyse_access_rights__(self):
22
+        if self._read is None or self._write is None:
23
+            self._read = False
24
+            self._write = False
25
+            #
26
+            if self._user.is_superuser:
27
+                # A superuser has full access
28
+                logger.debug("User is superuser -> full access granted")
29
+                self._read = True
30
+                self._write = True
31
+            elif self._page is None:
32
+                if self._user.is_staff:
33
+                    # Page creation is allowed for staff users
34
+                    logger.debug("Page does not exist and user is staff -> full access granted")
35
+                    self._read = True
36
+                    self._write = True
37
+                else:
38
+                    logger.debug("Page does not exist and user is not staff -> no access granted")
39
+            else:
40
+                user_is_owner = self._page.owner == self._user
41
+                user_in_page_group = self._page.group in self._user.groups.all()
42
+                # read permissions
43
+                if user_is_owner and self._page.owner_perms_read:
44
+                    logger.debug("Read access granted, due to owner permissions of page")
45
+                    self._read = True
46
+                elif user_in_page_group and self._page.group_perms_read:
47
+                    logger.debug("Read access granted, due to group permissions of page")
48
+                    self._read = True
49
+                elif self._page.other_perms_read:
50
+                    logger.debug("Read access granted, due to other permissions of page")
51
+                    self._read = True
52
+                # write permissions
53
+                if user_is_owner and self._page.owner_perms_write:
54
+                    logger.debug("Write access granted, due to owner permissions of page")
55
+                    self._write = True
56
+                elif user_in_page_group and self._page.group_perms_write:
57
+                    logger.debug("Write access granted, due to group permissions of page")
58
+                    self._write = True
59
+                elif self._page.other_perms_write:
60
+                    logger.debug("Write access granted, due to other permissions of page")
61
+                    self._write = True
5 62
 
6 63
     def may_read(self):
7
-        return "private" not in self._rel_path or self.may_write()
64
+        self.__analyse_access_rights__()
65
+        return self._read
8 66
 
9 67
     def may_write(self):
10
-        # /!\ rel_path is the filsystem rel_path - caused by the flat folder structure /!\
11
-        return self._request.user.is_authenticated and self._request.user.username in ['root', 'dirk']
68
+        self.__analyse_access_rights__()
69
+        return self._write
12 70
 
13 71
     def may_read_attachment(self):
14 72
         return self.may_read()

+ 2
- 0
pages/admin.py Dosyayı Görüntüle

@@ -10,6 +10,8 @@ class PikiPageAdmin(SimpleHistoryAdmin):
10 10
     search_fields = ('rel_path', 'tags', )
11 11
     list_filter = (
12 12
         ('deleted', admin.BooleanFieldListFilter),
13
+        ('other_perms_read', admin.BooleanFieldListFilter),
14
+        ('other_perms_write', admin.BooleanFieldListFilter),
13 15
     )
14 16
     ordering = ["rel_path"]
15 17
 

+ 1
- 2
pages/context.py Dosyayı Görüntüle

@@ -5,7 +5,6 @@ import os
5 5
 from django.conf import settings
6 6
 from django.utils.translation import gettext as _
7 7
 
8
-from pages.access import access_control
9 8
 import pages.parameter
10 9
 from .help import actionbar as actionbar_add_help
11 10
 import mycreole
@@ -74,7 +73,7 @@ def actionbar(context, request, caller_name, **kwargs):
74 73
     bar = context[context.ACTIONBAR]
75 74
     if not cms_mode_active(request):
76 75
         if caller_name in ['page', 'edit', 'delete', 'rename']:
77
-            acc = access_control(request, kwargs["rel_path"])
76
+            acc = kwargs["acc"]
78 77
             if acc.may_write():
79 78
                 add_page_menu(request, bar, kwargs["rel_path"], kwargs.get('is_available', False))
80 79
             if acc.may_modify_attachment():

+ 6
- 1
pages/forms.py Dosyayı Görüntüle

@@ -9,7 +9,12 @@ from .models import PikiPage
9 9
 class EditForm(forms.ModelForm):
10 10
     class Meta:
11 11
         model = PikiPage
12
-        fields = ["page_txt", "tags", "owner", "group"]
12
+        fields = [
13
+            "page_txt",
14
+            "tags",
15
+            "owner", "owner_perms_read", "owner_perms_write",
16
+            "group", "group_perms_read", "group_perms_write",
17
+            "other_perms_read", "other_perms_write",]
13 18
 
14 19
 
15 20
 class RenameForm(forms.Form):  # Note that it is not inheriting from forms.ModelForm

+ 18
- 2
pages/help.py Dosyayı Görüntüle

@@ -35,8 +35,24 @@ CREOLE += mycreole.render_simple("""
35 35
 
36 36
 ACCESS = mycreole.render_simple(_("""
37 37
 = Access
38
-* Currently just two specific users have write access.
39
-* Pages containing "private" in the relative page path have no public read access.
38
+== Administrator
39
+If the user has //Superuser status//, the user is able to create, read and write all pages.
40
+== Create new pages
41
+Only users with //Superuser status// or //Staff status// are able to create new pages.
42
+== Page rigths
43
+All following subsections are able to grant read or write access to the user
44
+=== Owner permissions
45
+Every page has an owner, if the user is the owner, the defined read or write permissions will be granted.
46
+=== Group permissions
47
+Every page has a group, if the user is in that group, the defined read or write permissions will be granted.
48
+=== Other permissions
49
+If no other mechanism granted the permissions, the defined read or write permissions for all other users will be granted.
50
+
51
+= Default permissions
52
+| =Mechanism | =Read | Write |
53
+| Owner      |   X   |   X   |
54
+| Group      |   X   |   X   |
55
+| Other      |   X   |   -   |
40 56
 """))
41 57
 
42 58
 SEARCH = mycreole.render_simple(_(

+ 0
- 73
pages/management/commands/migrate_to_db.py Dosyayı Görüntüle

@@ -1,73 +0,0 @@
1
-from django.conf import settings
2
-from django.contrib.auth.models import User
3
-from django.core.management.base import BaseCommand
4
-from pages.page import full_path_all_pages, page_wrapped
5
-
6
-from pages.models import PikiPage
7
-
8
-from datetime import datetime
9
-import fstools
10
-import os
11
-import shutil
12
-from zoneinfo import ZoneInfo
13
-
14
-
15
-def add_page_data(rel_path, tags, page_txt, creation_time, creation_user, modified_time, modified_user):
16
-    try:
17
-        page = PikiPage.objects.get(rel_path=rel_path)
18
-    except PikiPage.DoesNotExist:
19
-        page = PikiPage(rel_path=rel_path)
20
-    #
21
-    page.tags = tags
22
-    page.page_txt = page_txt
23
-    #
24
-    page.creation_time = datetime.fromtimestamp(creation_time, ZoneInfo("UTC"))
25
-    creation_user = creation_user or "dirk"
26
-    page.creation_user = User.objects.get(username=creation_user)
27
-    modified_user = modified_user or "dirk"
28
-    page.modified_time = datetime.fromtimestamp(modified_time, ZoneInfo("UTC"))
29
-    page.modified_user = User.objects.get(username=modified_user)
30
-    page.owner = page.owner or page.creation_user
31
-    #
32
-    page.save()
33
-
34
-
35
-class Command(BaseCommand):
36
-    def handle(self, *args, **options):
37
-        for path in full_path_all_pages():
38
-            fs_page = page_wrapped(None, path)
39
-            if fs_page._page.is_available():
40
-                self.stdout.write(self.style.MIGRATE_HEADING("Migration of page '%s'" % fs_page.rel_path))
41
-                for history_number in fs_page._page.history_numbers_list():
42
-                    self.stdout.write(self.style.MIGRATE_HEADING("  * Adding history version %d" % history_number))
43
-                    h_page = page_wrapped(None, path, history_version=history_number)
44
-                    add_page_data(
45
-                        rel_path=h_page.rel_path,
46
-                        tags=h_page.tags,
47
-                        page_txt=h_page._page.raw_page_src,
48
-                        #
49
-                        creation_time=h_page.creation_time,
50
-                        creation_user=h_page.creation_user,
51
-                        modified_time=h_page.modified_time,
52
-                        modified_user=h_page.modified_user
53
-                    )
54
-                #
55
-                self.stdout.write(self.style.MIGRATE_HEADING("  * Adding current version"))
56
-                add_page_data(
57
-                    rel_path=fs_page.rel_path,
58
-                    tags=fs_page.tags,
59
-                    page_txt=fs_page._page.raw_page_src,
60
-                    #
61
-                    creation_time=fs_page.creation_time,
62
-                    creation_user=fs_page.creation_user,
63
-                    modified_time=fs_page.modified_time,
64
-                    modified_user=fs_page.modified_user
65
-                )
66
-                #
67
-                src = os.path.join(path, "attachments")
68
-                if os.path.isdir(src):
69
-                    dst = os.path.join(settings.MYCREOLE_ROOT, fs_page.rel_path)
70
-                    for attachment in fstools.filelist(src):
71
-                        self.stdout.write(self.style.MIGRATE_HEADING("  * Copy attachment ''%s to new location" % os.path.basename(attachment)))
72
-                        fstools.mkdir(dst)
73
-                        shutil.copy(attachment, dst)

+ 73
- 0
pages/migrations/0002_historicalpikipage_group_perms_read_and_more.py Dosyayı Görüntüle

@@ -0,0 +1,73 @@
1
+# Generated by Django 5.1.2 on 2024-10-21 10:49
2
+
3
+from django.db import migrations, models
4
+
5
+
6
+class Migration(migrations.Migration):
7
+
8
+    dependencies = [
9
+        ('pages', '0001_initial'),
10
+    ]
11
+
12
+    operations = [
13
+        migrations.AddField(
14
+            model_name='historicalpikipage',
15
+            name='group_perms_read',
16
+            field=models.BooleanField(default=True),
17
+        ),
18
+        migrations.AddField(
19
+            model_name='historicalpikipage',
20
+            name='group_perms_write',
21
+            field=models.BooleanField(default=True),
22
+        ),
23
+        migrations.AddField(
24
+            model_name='historicalpikipage',
25
+            name='other_perms_read',
26
+            field=models.BooleanField(default=True),
27
+        ),
28
+        migrations.AddField(
29
+            model_name='historicalpikipage',
30
+            name='other_perms_write',
31
+            field=models.BooleanField(default=False),
32
+        ),
33
+        migrations.AddField(
34
+            model_name='historicalpikipage',
35
+            name='owner_perms_read',
36
+            field=models.BooleanField(default=True),
37
+        ),
38
+        migrations.AddField(
39
+            model_name='historicalpikipage',
40
+            name='owner_perms_write',
41
+            field=models.BooleanField(default=True),
42
+        ),
43
+        migrations.AddField(
44
+            model_name='pikipage',
45
+            name='group_perms_read',
46
+            field=models.BooleanField(default=True),
47
+        ),
48
+        migrations.AddField(
49
+            model_name='pikipage',
50
+            name='group_perms_write',
51
+            field=models.BooleanField(default=True),
52
+        ),
53
+        migrations.AddField(
54
+            model_name='pikipage',
55
+            name='other_perms_read',
56
+            field=models.BooleanField(default=True),
57
+        ),
58
+        migrations.AddField(
59
+            model_name='pikipage',
60
+            name='other_perms_write',
61
+            field=models.BooleanField(default=False),
62
+        ),
63
+        migrations.AddField(
64
+            model_name='pikipage',
65
+            name='owner_perms_read',
66
+            field=models.BooleanField(default=True),
67
+        ),
68
+        migrations.AddField(
69
+            model_name='pikipage',
70
+            name='owner_perms_write',
71
+            field=models.BooleanField(default=True),
72
+        ),
73
+    ]

+ 6
- 0
pages/models.py Dosyayı Görüntüle

@@ -34,8 +34,14 @@ class PikiPage(models.Model):
34 34
     owner = models.ForeignKey(User, null=True, blank=True, on_delete=models.SET_NULL, related_name="owner")
35 35
     group = models.ForeignKey(Group, null=True, blank=True, on_delete=models.SET_NULL, related_name="group")
36 36
     # owner_perms
37
+    owner_perms_read = models.BooleanField(default=True)
38
+    owner_perms_write = models.BooleanField(default=True)
37 39
     # group_perms
40
+    group_perms_read = models.BooleanField(default=True)
41
+    group_perms_write = models.BooleanField(default=True)
38 42
     # other_perms
43
+    other_perms_read = models.BooleanField(default=True)
44
+    other_perms_write = models.BooleanField(default=False)
39 45
     #
40 46
     history = HistoricalRecords()
41 47
 

+ 0
- 347
pages/page.py Dosyayı Görüntüle

@@ -1,347 +0,0 @@
1
-import difflib
2
-from django.conf import settings
3
-from django.utils.translation import gettext as _
4
-import fstools
5
-import json
6
-import logging
7
-from pages import messages, url_page
8
-import mycreole
9
-import os
10
-import shutil
11
-import time
12
-from . import timestamp_to_datetime
13
-
14
-logger = logging.getLogger(settings.ROOT_LOGGER_NAME).getChild(__name__)
15
-
16
-
17
-SPLITCHAR = ":"
18
-HISTORY_FOLDER_NAME = 'history'
19
-
20
-
21
-def full_path_all_pages(expression="*"):
22
-    system_pages = fstools.dirlist(settings.SYSTEM_PAGES_ROOT, expression=expression, rekursive=False)
23
-    system_pages = [os.path.join(settings.PAGES_ROOT, os.path.basename(path)) for path in system_pages]
24
-    pages = fstools.dirlist(settings.PAGES_ROOT, expression=expression, rekursive=False)
25
-    rv = []
26
-    for path in set(system_pages + pages):
27
-        p = page_wrapped(None, path)
28
-        if p.is_available():
29
-            rv.append(path)
30
-    return rv
31
-
32
-
33
-class base(dict):
34
-    @property
35
-    def rel_path(self):
36
-        return os.path.basename(self._path).replace(2*SPLITCHAR, "/")
37
-
38
-    def is_available(self):
39
-        is_a = os.path.isfile(self.filename)
40
-        if not is_a:
41
-            logger.debug("Not available - %s", self.filename)
42
-        return is_a
43
-
44
-    def history_numbers_list(self):
45
-        history_folder = os.path.join(self._path, HISTORY_FOLDER_NAME)
46
-        return list(set([int(os.path.basename(filename)[:5]) for filename in fstools.filelist(history_folder)]))
47
-
48
-
49
-class meta_data(base):
50
-    META_FILE_NAME = 'meta.json'
51
-    #
52
-    KEY_CREATION_TIME = "creation_time"
53
-    KEY_CREATION_USER = "creation_user"
54
-    KEY_MODIFIED_TIME = "modified_time"
55
-    KEY_MODIFIED_USER = "modified_user"
56
-    KEY_TAGS = "tags"
57
-
58
-    def __init__(self, path, history_version=None):
59
-        self._path = path
60
-        self._history_version = history_version
61
-        #
62
-        # Load data from disk
63
-        try:
64
-            with open(self.filename, 'r') as fh:
65
-                super().__init__(json.load(fh))
66
-        except (FileNotFoundError, json.decoder.JSONDecodeError) as e:
67
-            super().__init__()
68
-
69
-    def delete(self):
70
-        os.remove(self.filename)
71
-
72
-    @property
73
-    def filename(self):
74
-        if not self._history_version:
75
-            return os.path.join(self._path, self.META_FILE_NAME)
76
-        else:
77
-            return self.history_filename(self._history_version)
78
-
79
-    def history_filename(self, history_version):
80
-        return os.path.join(self._path, HISTORY_FOLDER_NAME, "%05d_%s" % (history_version, self.META_FILE_NAME))
81
-
82
-    def update_required(self, tags):
83
-        return tags != self.get(self.KEY_TAGS)
84
-
85
-    def update(self, username, tags):
86
-        if self._history_version:
87
-            logger.error("A history version %05d can not be updated!", self._history_version)
88
-            return False
89
-        else:
90
-            if username:
91
-                self[self.KEY_MODIFIED_TIME] = int(time.time())
92
-                self[self.KEY_MODIFIED_USER] = username
93
-                #
94
-                if self.KEY_CREATION_USER not in self:
95
-                    self[self.KEY_CREATION_USER] = self[self.KEY_MODIFIED_USER]
96
-                if self.KEY_CREATION_TIME not in self:
97
-                    self[self.KEY_CREATION_TIME] = self[self.KEY_MODIFIED_TIME]
98
-            if tags:
99
-                self[self.KEY_TAGS] = tags
100
-            #
101
-            if username or tags:
102
-                self.save()
103
-            return True
104
-
105
-    def save(self):
106
-        if self._history_version:
107
-            logger.error("A history version %05d can not be updated!", self._history_version)
108
-            return False
109
-        else:
110
-            with open(self.filename, 'w') as fh:
111
-                json.dump(self, fh, indent=4)
112
-            return True
113
-
114
-    def store_to_history(self, history_number):
115
-        history_filename = self.history_filename(history_number)
116
-        fstools.mkdir(os.path.dirname(history_filename))
117
-        shutil.copy(self.filename, history_filename)
118
-
119
-
120
-class page_data(base):
121
-    PAGE_FILE_NAME = 'page'
122
-
123
-    def __init__(self, path, history_version=None):
124
-        self._history_version = history_version
125
-        self._path = path
126
-        self._raw_page_src = None
127
-
128
-    def _load_page_src(self):
129
-        if self._raw_page_src is None:
130
-            try:
131
-                with open(self.filename, 'r') as fh:
132
-                    self._raw_page_src = fh.read()
133
-            except FileNotFoundError:
134
-                self._raw_page_src = ""
135
-
136
-    def delete(self):
137
-        os.remove(self.filename)
138
-
139
-    def rename(self, page_name):
140
-        # Change backslash to slash and remove double slashes
141
-        page_name = page_name.replace("\\", "/")
142
-        while "//" in page_name:
143
-            page_name = page_name.replace("//", "/")
144
-        # move path
145
-        target_path = os.path.join(settings.PAGES_ROOT, page_name.replace("/", 2*SPLITCHAR))
146
-        shutil.move(self._path, target_path)
147
-        # set my path
148
-        self._path = target_path
149
-
150
-    def update_required(self, page_txt):
151
-        return page_txt.replace("\r\n", "\n") != self.raw_page_src
152
-
153
-    def update_page(self, page_txt):
154
-        if self._history_version:
155
-            logger.error("A history version %05d can not be updated!", self._history_version)
156
-            return False
157
-        else:
158
-            # save the new page content
159
-            fstools.mkdir(os.path.dirname(self.filename))
160
-            with open(self.filename, 'w') as fh:
161
-                fh.write(page_txt)
162
-            self._raw_page_src = page_txt
163
-            return True
164
-
165
-    @property
166
-    def filename(self):
167
-        if not self._history_version:
168
-            return os.path.join(self._path, self.PAGE_FILE_NAME)
169
-        else:
170
-            return self.history_filename(self._history_version)
171
-
172
-    def history_filename(self, history_version):
173
-        return os.path.join(self._path, HISTORY_FOLDER_NAME, "%05d_%s" % (history_version, self.PAGE_FILE_NAME))
174
-
175
-    @property
176
-    def rel_path(self):
177
-        return os.path.basename(self._path).replace(2*SPLITCHAR, "/")
178
-
179
-    @property
180
-    def title(self):
181
-        return os.path.basename(self._path).split(2*SPLITCHAR)[-1]
182
-
183
-    @property
184
-    def raw_page_src(self):
185
-        self._load_page_src()
186
-        return self._raw_page_src
187
-
188
-    def store_to_history(self, history_number):
189
-        history_filename = self.history_filename(history_number)
190
-        fstools.mkdir(os.path.dirname(history_filename))
191
-        shutil.copy(self.filename, history_filename)
192
-
193
-
194
-class page_wrapped(object):
195
-    """
196
-    This class holds different page and meta instances and decides which will be used in which case.
197
-    """
198
-
199
-    def __init__(self, request, path, history_version=None):
200
-        """_summary_
201
-
202
-        Args:
203
-            request (_type_): The django request or None (if None, the page functionality is limited)
204
-            path (_type_): A rel_path of the django page or the filesystem path to the page
205
-            history_version (_type_, optional): The history version of the page to be created
206
-        """
207
-        self._request = request
208
-        #
209
-        page_path = self.__page_path__(path)
210
-        # Page
211
-        self._page = page_data(page_path, history_version=history_version)
212
-        self._page_meta = meta_data(page_path, history_version=history_version)
213
-
214
-    def __page_path__(self, path):
215
-        if path.startswith(settings.PAGES_ROOT):
216
-            # must be a filesystem path
217
-            return path
218
-        else:
219
-            # must be a relative url
220
-            return os.path.join(settings.PAGES_ROOT, path.replace("/", 2*SPLITCHAR))
221
-
222
-    def __page_choose__(self):
223
-        return self._page
224
-
225
-    def __meta_choose__(self):
226
-        return self._page_meta
227
-
228
-    def __store_history__(self):
229
-        if self._page.is_available():
230
-            try:
231
-                history_number = max(self._page.history_numbers_list()) + 1
232
-            except ValueError:
233
-                history_number = 1     # no history yet
234
-            self._page.store_to_history(history_number)
235
-            self._page_meta.store_to_history(history_number)
236
-
237
-    #
238
-    # meta_data
239
-    #
240
-    @property
241
-    def creation_time(self):
242
-        meta = self.__meta_choose__()
243
-        rv = meta.get(meta.KEY_CREATION_TIME)
244
-        return rv
245
-
246
-    @property
247
-    def creation_user(self):
248
-        meta = self.__meta_choose__()
249
-        rv = meta.get(meta.KEY_CREATION_USER)
250
-        return rv
251
-
252
-    def delete(self):
253
-        self.__store_history__()
254
-        self._page.delete()
255
-        self._page_meta.delete()
256
-
257
-    @property
258
-    def modified_time(self):
259
-        meta = self.__meta_choose__()
260
-        rv = meta.get(meta.KEY_MODIFIED_TIME)
261
-        return rv
262
-
263
-    @property
264
-    def modified_user(self):
265
-        meta = self.__meta_choose__()
266
-        rv = meta.get(meta.KEY_MODIFIED_USER)
267
-        return rv
268
-
269
-    def rename(self, page_name):
270
-        self._page.rename(page_name)
271
-
272
-    @property
273
-    def tags(self):
274
-        meta = self.__meta_choose__()
275
-        rv = meta.get(meta.KEY_TAGS)
276
-        return rv
277
-
278
-    #
279
-    # page
280
-    #
281
-    @property
282
-    def attachment_path(self):
283
-        page = self.__page_choose__()
284
-        rv = page.attachment_path
285
-        return rv
286
-
287
-    def is_available(self):
288
-        return self._page.is_available()
289
-
290
-    def userpage_is_available(self):
291
-        return self._page.is_available()
292
-
293
-    @property
294
-    def raw_page_src(self):
295
-        page = self.__page_choose__()
296
-        rv = page.raw_page_src
297
-        return rv
298
-
299
-    @property
300
-    def rel_path(self):
301
-        page = self.__page_choose__()
302
-        rv = page.rel_path
303
-        return rv
304
-
305
-    def render_meta(self):
306
-        page = self.__page_choose__()
307
-        rv = page.render_meta(self.creation_time, self.modified_time, self.creation_user, self.modified_user, self.tags)
308
-        return rv
309
-
310
-    def render_to_html(self):
311
-        page = self.__page_choose__()
312
-        rv = page.render_to_html()
313
-        return rv
314
-
315
-    def render_text(self, request, txt):
316
-        page = self.__page_choose__()
317
-        rv = page.render_text(request, txt)
318
-        return rv
319
-
320
-    @property
321
-    def title(self):
322
-        page = self.__page_choose__()
323
-        rv = page.title
324
-        return rv
325
-
326
-    def update_page(self, txt, tags):
327
-        if self._page.update_required(txt) or self._page_meta.update_required(tags):
328
-            rv = False
329
-            # Store history
330
-            self.__store_history__()
331
-            username = None
332
-            if self._page.update_required(txt):
333
-                # Update page
334
-                rv |= self._page.update_page(txt)
335
-                # Identify username, to update meta
336
-                try:
337
-                    if self._request.user.is_authenticated:
338
-                        username = self._request.user.username
339
-                    else:
340
-                        logger.warning("Page edit without having a logged in user. This is not recommended. Check your access definitions!")
341
-                except AttributeError:
342
-                    logger.exception("Page edit without having a request object. Check programming!")
343
-            rv |= self._page_meta.update(username, tags)
344
-            # Update search index
345
-            from pages.search import update_item
346
-            update_item(self)
347
-            return rv

+ 5
- 0
pages/views.py Dosyayı Görüntüle

@@ -78,6 +78,7 @@ def page(request, rel_path):
78 78
     context_adaption(
79 79
         context,
80 80
         request,
81
+        acc=acc,
81 82
         rel_path=rel_path,
82 83
         title=title,
83 84
         upload_path=rel_path,
@@ -110,6 +111,7 @@ def edit(request, rel_path):
110 111
             context_adaption(
111 112
                 context,
112 113
                 request,
114
+                acc=acc,
113 115
                 rel_path=rel_path,
114 116
                 is_available=is_available,
115 117
                 form=form,
@@ -141,6 +143,7 @@ def edit(request, rel_path):
141 143
                 context_adaption(
142 144
                     context,
143 145
                     request,
146
+                    acc=acc,
144 147
                     rel_path=rel_path,
145 148
                     is_available=is_available,
146 149
                     form=form,
@@ -176,6 +179,7 @@ def delete(request, rel_path):
176 179
             context_adaption(
177 180
                 context,
178 181
                 request,
182
+                acc=acc,
179 183
                 rel_path=rel_path,
180 184
                 is_available=is_available,
181 185
                 # TODO: Add translation
@@ -222,6 +226,7 @@ def rename(request, rel_path):
222 226
             context_adaption(
223 227
                 context,
224 228
                 request,
229
+                acc=acc,
225 230
                 rel_path=rel_path,
226 231
                 is_available=is_available,
227 232
                 form=form,

+ 1
- 0
requirements.txt Dosyayı Görüntüle

@@ -1,4 +1,5 @@
1 1
 Django
2
+django-simple-history
2 3
 Pillow
3 4
 python-creole
4 5
 pytz

Loading…
İptal
Kaydet