diff --git a/docs/content.rst b/docs/content.rst deleted file mode 100644 index e7de2376..00000000 --- a/docs/content.rst +++ /dev/null @@ -1,25 +0,0 @@ -Content Management -================== - -The content management system allows organizers to create pages and page -sections for a conference. You may want to have an entire page about a job -fair, or may only want to have an editable section at the top of a tutorial -schedule with some instructions for all of the tutorial attendees. - -CMS App -------- - -The ``cms`` app provides functionality for creating wiki pages. These pages can -be created using the django admin. The django admin form has controls for -specifying: - -* title -* markup content -* url path -* tags -* public or draft mode -* publication date - -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. diff --git a/symposion/cms/__init__.py b/symposion/cms/__init__.py deleted file mode 100644 index 010e607a..00000000 --- a/symposion/cms/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -# @@@ Consider replacing with pinax-wiki [1] -default_app_config = "symposion.cms.apps.CMSConfig" diff --git a/symposion/cms/admin.py b/symposion/cms/admin.py deleted file mode 100644 index 83b4c176..00000000 --- a/symposion/cms/admin.py +++ /dev/null @@ -1,13 +0,0 @@ -from django.contrib import admin - -import reversion - -from .models import Page - - -class PageAdmin(reversion.VersionAdmin): - - pass - - -admin.site.register(Page, PageAdmin) diff --git a/symposion/cms/apps.py b/symposion/cms/apps.py deleted file mode 100644 index d506db12..00000000 --- a/symposion/cms/apps.py +++ /dev/null @@ -1,7 +0,0 @@ -from django.apps import AppConfig - - -class CMSConfig(AppConfig): - name = "symposion.cms" - label = "symposion_cms" - verbose_name = "Symposion CMS" diff --git a/symposion/cms/forms.py b/symposion/cms/forms.py deleted file mode 100644 index 5eecca31..00000000 --- a/symposion/cms/forms.py +++ /dev/null @@ -1,21 +0,0 @@ -from django import forms - -from markitup.widgets import MarkItUpWidget - -from .models import Page - - -class PageForm(forms.ModelForm): - - class Meta: - model = Page - fields = ["title", "body", "path"] - widgets = { - "body": MarkItUpWidget(), - "path": forms.HiddenInput(), - } - - -class FileUploadForm(forms.Form): - - file = forms.FileField() diff --git a/symposion/cms/managers.py b/symposion/cms/managers.py deleted file mode 100644 index 9ffb6592..00000000 --- a/symposion/cms/managers.py +++ /dev/null @@ -1,10 +0,0 @@ -from django.utils import timezone - -from django.db import models - - -class PublishedPageManager(models.Manager): - - def get_queryset(self): - qs = super(PublishedPageManager, self).get_queryset() - return qs.filter(publish_date__lte=timezone.now()) diff --git a/symposion/cms/models.py b/symposion/cms/models.py deleted file mode 100644 index 9c8ce003..00000000 --- a/symposion/cms/models.py +++ /dev/null @@ -1,79 +0,0 @@ -import datetime -import os -import re - -from django.conf import settings -from django.core.urlresolvers import reverse -from django.core.exceptions import ValidationError -from django.db import models -from django.utils.encoding import python_2_unicode_compatible -from django.utils.translation import ugettext_lazy as _ - -from markitup.fields import MarkupField - -from taggit.managers import TaggableManager - -import reversion - -from .managers import PublishedPageManager - - -@python_2_unicode_compatible -class Page(models.Model): - - STATUS_CHOICES = ( - (1, _("Draft")), - (2, _("Public")), - ) - - title = models.CharField(max_length=100) - path = models.CharField(max_length=100, unique=True) - body = MarkupField() - status = models.IntegerField(choices=STATUS_CHOICES, default=2) - publish_date = models.DateTimeField(default=datetime.datetime.now) - created = models.DateTimeField(editable=False, default=datetime.datetime.now) - updated = models.DateTimeField(editable=False, default=datetime.datetime.now) - tags = TaggableManager(blank=True) - - published = PublishedPageManager() - - def __str__(self): - return self.title - - class Meta: - verbose_name = _("page") - verbose_name_plural = _("pages") - - @models.permalink - def get_absolute_url(self): - return ("cms_page", [self.path]) - - @property - def is_community(self): - return self.path.lower().startswith("community/") - - def save(self, *args, **kwargs): - self.updated = datetime.datetime.now() - super(Page, self).save(*args, **kwargs) - - def clean_fields(self, exclude=None): - super(Page, self).clean_fields(exclude) - if not re.match(settings.SYMPOSION_PAGE_REGEX, self.path): - raise ValidationError( - {"path": [_("Path can only contain letters, numbers and hyphens and end with /")]}) - - -reversion.register(Page) - - -def generate_filename(instance, filename): - return filename - - -class File(models.Model): - - file = models.FileField(upload_to=generate_filename) - created = models.DateTimeField(default=datetime.datetime.now) - - def download_url(self): - return reverse("file_download", args=[self.pk, os.path.basename(self.file.name).lower()]) diff --git a/symposion/cms/urls.py b/symposion/cms/urls.py deleted file mode 100644 index af3ef981..00000000 --- a/symposion/cms/urls.py +++ /dev/null @@ -1,14 +0,0 @@ -from django.conf.urls import url, patterns - - -PAGE_RE = r"(([\w-]{1,})(/[\w-]{1,})*)/" - -urlpatterns = patterns( - "symposion.cms.views", - url(r"^files/$", "file_index", name="file_index"), - url(r"^files/create/$", "file_create", name="file_create"), - url(r"^files/(\d+)/([^/]+)$", "file_download", name="file_download"), - url(r"^files/(\d+)/delete/$", "file_delete", name="file_delete"), - url(r"^(?P%s)_edit/$" % PAGE_RE, "page_edit", name="cms_page_edit"), - url(r"^(?P%s)$" % PAGE_RE, "page", name="cms_page"), -) diff --git a/symposion/cms/views.py b/symposion/cms/views.py deleted file mode 100644 index 2f58381a..00000000 --- a/symposion/cms/views.py +++ /dev/null @@ -1,130 +0,0 @@ -from django.conf import settings -from django.db import transaction -from django.http import Http404, HttpResponse -from django.shortcuts import render, redirect, get_object_or_404 -from django.views import static - -from django.contrib.auth.decorators import login_required -from .models import Page, File -from .forms import PageForm, FileUploadForm - - -def can_edit(page, user): - if page and page.is_community: - return True - else: - return user.has_perm("cms.change_page") - - -def can_upload(user): - if user.is_staff or user.is_superuser: - return True - return False - - -def page(request, path): - - try: - page = Page.published.get(path=path) - except Page.DoesNotExist: - page = None - - editable = can_edit(page, request.user) - - if page is None: - if editable: - return redirect("cms_page_edit", path=path) - else: - raise Http404 - - return render(request, "cms/page_detail.html", { - "page": page, - "editable": editable, - }) - - -@login_required -def page_edit(request, path): - - try: - page = Page.published.get(path=path) - except Page.DoesNotExist: - page = None - - if not can_edit(page, request.user): - raise Http404 - - if request.method == "POST": - form = PageForm(request.POST, instance=page) - if form.is_valid(): - page = form.save(commit=False) - page.path = path - page.save() - return redirect(page) - else: - print form.errors - else: - form = PageForm(instance=page, initial={"path": path}) - - return render(request, "cms/page_edit.html", { - "path": path, - "form": form - }) - - -def file_index(request): - if not can_upload(request.user): - raise Http404 - - ctx = { - "files": File.objects.all(), - } - return render(request, "cms/file_index.html", ctx) - - -def file_create(request): - if not can_upload(request.user): - raise Http404 - - if request.method == "POST": - form = FileUploadForm(request.POST, request.FILES) - if form.is_valid(): - with transaction.commit_on_success(): - kwargs = { - "file": form.cleaned_data["file"], - } - File.objects.create(**kwargs) - return redirect("file_index") - else: - form = FileUploadForm() - - ctx = { - "form": form, - } - return render(request, "cms/file_create.html", ctx) - - -def file_download(request, pk, *args): - file = get_object_or_404(File, pk=pk) - - if getattr(settings, "USE_X_ACCEL_REDIRECT", False): - response = HttpResponse() - response["X-Accel-Redirect"] = file.file.url - # delete content-type to allow Gondor to determine the filetype and - # we definitely don't want Django's default :-) - del response["content-type"] - else: - response = static.serve(request, file.file.name, document_root=settings.MEDIA_ROOT) - - return response - - -def file_delete(request, pk): - if not can_upload(request.user): - raise Http404 - - file = get_object_or_404(File, pk=pk) - if request.method == "POST": - file.delete() - # @@@ message - return redirect("file_index")