diff --git a/__init__.py b/__init__.py index 0942a76..2098a35 100644 --- a/__init__.py +++ b/__init__.py @@ -89,6 +89,11 @@ def render(request, text, attachment_target_path, next_anchor=''): return creole.creole2html(text) +def url_delete(request, rel_path, next_anchor=''): + nxt = request.GET.get('next', request.get_full_path()) + return reverse('mycreole-delete', kwargs={'rel_path': rel_path}) + '?next=%s' % nxt + ('' if not next_anchor else '#%s' % next_anchor) + + def url_upload(request, rel_path, next_anchor=''): nxt = request.GET.get('next', request.get_full_path()) return reverse('mycreole-upload', kwargs={'rel_path': rel_path}) + '?next=%s' % nxt + ('' if not next_anchor else '#%s' % next_anchor) diff --git a/context.py b/context.py index 298ca0a..c738181 100644 --- a/context.py +++ b/context.py @@ -1,11 +1,35 @@ +from django.utils.translation import gettext as _ +import logging +from mycreole import url_upload from users.context import menubar as user_menubar -import themes +from patt.context import navigationbar +from themes import color_icon_url + +try: + from config import APP_NAME as ROOT_LOGGER_NAME +except ImportError: + ROOT_LOGGER_NAME = 'root' +logger = logging.getLogger(ROOT_LOGGER_NAME).getChild(__name__) + +NEW_ATTACHMENT_UID = 'new_attachment' -def context_adaption(context, request, title, **kwargs): +def context_adaption(context, request, title, rel_path, **kwargs): context.set_additional_title(title) user_menubar(context[context.MENUBAR], request) - context[context.NAVIGATIONBAR].append_entry(*themes.empty_entry_parameters(request)) - context[context.ACTIONBAR].append_entry(*themes.empty_entry_parameters(request)) + navigationbar(context, request) + add_new(request, context[context.ACTIONBAR], rel_path, kwargs.get('next')) for key in kwargs: context[key] = kwargs[key] + logger.debug("context adapted: %s", repr(context)) + + +def add_new(request, bar, rel_path, nxt): + bar.append_entry( + NEW_ATTACHMENT_UID, # uid + _('New Attachment'), # name + color_icon_url(request, 'plus.png'), # icon + url_upload(request, rel_path, nxt), # url + True, # left + False # active + ) diff --git a/templates/mycreole/delete.html b/templates/mycreole/delete.html new file mode 100644 index 0000000..4e86a56 --- /dev/null +++ b/templates/mycreole/delete.html @@ -0,0 +1,17 @@ +{% extends "themes/"|add:settings.page_theme|add:"/base.html" %} +{% load static %} +{% load i18n %} + +{% block content %} +
Name | +Size | +Actions | +
---|---|---|
{{ key }} | +{{ value.size }} | +
+ {% for icon, url, alt in value.actions %}
+ |
+