diff --git a/docs/content.rst b/docs/content.rst index 59c0b3ef..e7de2376 100644 --- a/docs/content.rst +++ b/docs/content.rst @@ -23,18 +23,3 @@ specifying: Page content and title can also be edited directly at the url. The ``cms`` app uses the `django-reversion `_ package, thus content is version controlled. - -Boxes App ---------- - -The ``boxes`` app allows for sections of a page to be edited like a wiki. To use this in a template -use the ``boxes_tags`` and specify a box section of a page using the ``boxes`` tag: - -.. code-block:: django - - {% load boxes_tags %} - {% boxes "intro_section" %} - -This template will render an editable content box. When a staff user visits the -page, they will see an ``Edit this content`` button. The ``boxes`` app also uses the -``django-reversion`` package. diff --git a/symposion/boxes/__init__.py b/symposion/boxes/__init__.py deleted file mode 100644 index 8a6e37e9..00000000 --- a/symposion/boxes/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -# @@@ Reconcile differences with django-boxes [1] and remove from Symposion - -# [1] http://github.com/eldarion/django-boxes/ diff --git a/symposion/boxes/admin.py b/symposion/boxes/admin.py deleted file mode 100644 index 189db64b..00000000 --- a/symposion/boxes/admin.py +++ /dev/null @@ -1,12 +0,0 @@ -from django.contrib import admin - -import reversion - -from symposion.boxes.models import Box - - -class BoxAdmin(reversion.VersionAdmin): - - pass - -admin.site.register(Box, BoxAdmin) diff --git a/symposion/boxes/authorization.py b/symposion/boxes/authorization.py deleted file mode 100644 index e898b0cf..00000000 --- a/symposion/boxes/authorization.py +++ /dev/null @@ -1,20 +0,0 @@ -from django.conf import settings - -from symposion.boxes.utils import load_path_attr - - -def default_can_edit(request, *args, **kwargs): - """ - This is meant to be overridden in your project per domain specific - requirements. - """ - return request.user.is_staff or request.user.is_superuser - - -def load_can_edit(): - import_path = getattr(settings, "BOXES_CAN_EDIT_CALLABLE", None) - - if import_path is None: - return default_can_edit - - return load_path_attr(import_path) diff --git a/symposion/boxes/forms.py b/symposion/boxes/forms.py deleted file mode 100644 index 7f881acc..00000000 --- a/symposion/boxes/forms.py +++ /dev/null @@ -1,10 +0,0 @@ -from django import forms - -from symposion.boxes.models import Box - - -class BoxForm(forms.ModelForm): - - class Meta: - model = Box - fields = ["content"] diff --git a/symposion/boxes/models.py b/symposion/boxes/models.py deleted file mode 100644 index 65e38d7b..00000000 --- a/symposion/boxes/models.py +++ /dev/null @@ -1,28 +0,0 @@ -from __future__ import unicode_literals -from django.db import models -from django.contrib.auth.models import User -from django.utils.encoding import python_2_unicode_compatible -from django.utils.translation import ugettext_lazy as _ - -import reversion - -from markitup.fields import MarkupField - - -@python_2_unicode_compatible -class Box(models.Model): - - label = models.CharField(max_length=100, db_index=True, verbose_name=_("Label")) - content = MarkupField(blank=True) - - created_by = models.ForeignKey(User, related_name="boxes", verbose_name=_("Created by")) - last_updated_by = models.ForeignKey(User, related_name="updated_boxes", verbose_name=_("Last updated by")) - - def __str__(self): - return self.label - - class Meta: - verbose_name = _("Box") - verbose_name_plural = _("Boxes") - -reversion.register(Box) diff --git a/symposion/boxes/templatetags/__init__.py b/symposion/boxes/templatetags/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/symposion/boxes/templatetags/boxes_tags.py b/symposion/boxes/templatetags/boxes_tags.py deleted file mode 100644 index 53765e56..00000000 --- a/symposion/boxes/templatetags/boxes_tags.py +++ /dev/null @@ -1,36 +0,0 @@ -from django import template -from django.core.urlresolvers import reverse - -from symposion.boxes.models import Box -from symposion.boxes.forms import BoxForm -from symposion.boxes.authorization import load_can_edit - - -register = template.Library() - - -@register.inclusion_tag("boxes/box.html", takes_context=True) -def box(context, label, show_edit=True, *args, **kwargs): - - request = context["request"] - can_edit = load_can_edit()(request, *args, **kwargs) - - try: - box = Box.objects.get(label=label) - except Box.DoesNotExist: - box = None - - if can_edit and show_edit: - form = BoxForm(instance=box, prefix=label) - form_action = reverse("box_edit", args=[label]) - else: - form = None - form_action = None - - return { - "request": request, - "label": label, - "box": box, - "form": form, - "form_action": form_action, - } diff --git a/symposion/boxes/urls.py b/symposion/boxes/urls.py deleted file mode 100644 index 96464b66..00000000 --- a/symposion/boxes/urls.py +++ /dev/null @@ -1,7 +0,0 @@ -from django.conf.urls import patterns, url - - -urlpatterns = patterns( - "symposion.boxes.views", - url(r"^([-\w]+)/edit/$", "box_edit", name="box_edit"), -) diff --git a/symposion/boxes/utils.py b/symposion/boxes/utils.py deleted file mode 100644 index 3d2b4c76..00000000 --- a/symposion/boxes/utils.py +++ /dev/null @@ -1,19 +0,0 @@ -from django.core.exceptions import ImproperlyConfigured -try: - from django.utils.importlib import import_module -except ImportError: - from importlib import import_module - - -def load_path_attr(path): - i = path.rfind(".") - module, attr = path[:i], path[i + 1:] - try: - mod = import_module(module) - except ImportError, e: - raise ImproperlyConfigured("Error importing %s: '%s'" % (module, e)) - try: - attr = getattr(mod, attr) - except AttributeError: - raise ImproperlyConfigured("Module '%s' does not define a '%s'" % (module, attr)) - return attr diff --git a/symposion/boxes/views.py b/symposion/boxes/views.py deleted file mode 100644 index 1e93675d..00000000 --- a/symposion/boxes/views.py +++ /dev/null @@ -1,46 +0,0 @@ -from django.http import HttpResponseForbidden -from django.shortcuts import redirect -from django.views.decorators.http import require_POST - -from symposion.boxes.authorization import load_can_edit -from symposion.boxes.forms import BoxForm -from symposion.boxes.models import Box - - -# @@@ problem with this is that the box_edit.html and box_create.html won't have domain objects in -# context -def get_auth_vars(request): - auth_vars = {} - if request.method == "POST": - keys = [k for k in request.POST.keys() if k.startswith("boxes_auth_")] - for key in keys: - auth_vars[key.replace("boxes_auth_", "")] = request.POST.get(key) - auth_vars["user"] = request.user - return auth_vars - - -@require_POST -def box_edit(request, label): - - if not load_can_edit()(request, **get_auth_vars(request)): - return HttpResponseForbidden() - - next = request.GET.get("next") - - try: - box = Box.objects.get(label=label) - except Box.DoesNotExist: - box = None - - form = BoxForm(request.POST, instance=box, prefix=label) - - if form.is_valid(): - if box is None: - box = form.save(commit=False) - box.label = label - box.created_by = request.user - box.last_updated_by = request.user - box.save() - else: - form.save() - return redirect(next)