Page for Metadata added
This commit is contained in:
bovenliggende
bab3b58816
commit
4b231c0b39
@ -1,8 +1,11 @@
|
||||
from django.urls.base import reverse
|
||||
|
||||
|
||||
def url_page(request, rel_path):
|
||||
return reverse('page-page', kwargs={'rel_path': rel_path})
|
||||
def url_page(request, rel_path, **kwargs):
|
||||
params = "&".join([f"{key}" + ("" if kwargs[key] is None else f"={kwargs[key]}") for key in kwargs])
|
||||
if len(params) > 0:
|
||||
params = "?" + params
|
||||
return reverse('page-page', kwargs={'rel_path': rel_path}) + params
|
||||
|
||||
|
||||
def url_helpview(request, page):
|
||||
|
@ -113,6 +113,8 @@ def actionbar(context, request, caller_name, **kwargs):
|
||||
add_edit_menu(request, bar, kwargs["rel_path"])
|
||||
if access.modify_attachment(request, kwargs["rel_path"]):
|
||||
add_manageupload_menu(request, bar, kwargs['upload_path'])
|
||||
if access.read_page(request, kwargs["rel_path"]):
|
||||
add_meta_menu(request, bar, kwargs["rel_path"])
|
||||
elif caller_name == 'helpview':
|
||||
actionbar_add_help(context, request, **kwargs)
|
||||
finalise_bar(request, bar)
|
||||
@ -140,6 +142,27 @@ def add_manageupload_menu(request, bar, upload_path):
|
||||
)
|
||||
|
||||
|
||||
def add_meta_menu(request, bar, rel_path):
|
||||
if "meta" in request.GET:
|
||||
bar.append_entry(
|
||||
EDIT_UID, # uid
|
||||
_('Page'), # name
|
||||
color_icon_url(request, 'display.png'), # icon
|
||||
pages.url_page(request, rel_path), # url
|
||||
True, # left
|
||||
False # active
|
||||
)
|
||||
else:
|
||||
bar.append_entry(
|
||||
EDIT_UID, # uid
|
||||
_('Meta'), # name
|
||||
color_icon_url(request, 'info.png'), # icon
|
||||
pages.url_page(request, rel_path, meta=None), # url
|
||||
True, # left
|
||||
False # active
|
||||
)
|
||||
|
||||
|
||||
def finalise_bar(request, bar):
|
||||
if len(bar) == 0:
|
||||
bar.append_entry(*empty_entry_parameters(request))
|
||||
|
@ -1,5 +1,6 @@
|
||||
from datetime import datetime
|
||||
from django.conf import settings
|
||||
|
||||
from django.utils.translation import gettext as _
|
||||
import fstools
|
||||
import json
|
||||
import logging
|
||||
@ -7,6 +8,8 @@ from pages import messages, url_page
|
||||
import mycreole
|
||||
import os
|
||||
import time
|
||||
from users.models import get_userprofile
|
||||
import zoneinfo
|
||||
|
||||
logger = logging.getLogger(settings.ROOT_LOGGER_NAME).getChild(__name__)
|
||||
|
||||
@ -141,6 +144,23 @@ class creole_page(base_page):
|
||||
messages.unavailable_msg_page(self._request, self.rel_path)
|
||||
return ""
|
||||
|
||||
def render_meta(self):
|
||||
def str_date(tm):
|
||||
up = get_userprofile(self._request.user)
|
||||
tz = zoneinfo.ZoneInfo(up.timezone)
|
||||
#
|
||||
return datetime.fromtimestamp(tm, tz).strftime('%Y-%m-%d %H:%M')
|
||||
#
|
||||
ctime = str_date(self._meta_data.get(self._meta_data.KEY_CREATION_TIME))
|
||||
mtime = str_date(self._meta_data.get(self._meta_data.KEY_MODIFIED_TIME))
|
||||
user = self._meta_data.get(self._meta_data.KEY_MODIFIED_USER)
|
||||
#
|
||||
meta = f'|{_("Created")}:|{ctime}|\n'
|
||||
meta += f'|{_("Modified")}:|{mtime}|\n'
|
||||
meta += f'|{_("Editor")}|{user}|\n\n'
|
||||
#
|
||||
return mycreole.render_simple(meta)
|
||||
|
||||
def render_text(self, request, txt):
|
||||
macros = {
|
||||
"subpages": self.macro_subpages,
|
||||
|
@ -28,9 +28,14 @@ def root(request):
|
||||
def page(request, rel_path):
|
||||
context = Context(request) # needs to be executed first because of time mesurement
|
||||
#
|
||||
meta = "meta" in request.GET
|
||||
#
|
||||
p = creole_page(request, rel_path)
|
||||
if access.read_page(request, rel_path):
|
||||
page_content = p.render_to_html()
|
||||
if meta:
|
||||
page_content = p.render_meta()
|
||||
else:
|
||||
page_content = p.render_to_html()
|
||||
else:
|
||||
messages.permission_denied_msg_page(request, rel_path)
|
||||
page_content = ""
|
||||
|
Laden…
x
Verwijs in nieuw issue
Block a user