Commit 9a04ef41 by benjaoming

Changing app_label for plugin models

parent ab7dc9a0
django-wiki
===========
*Last update: 2012-08-12*
*Last update: 2012-08-17*
Demo here, sign up for an account to see the notification system.
......@@ -10,7 +10,7 @@ Demo here, sign up for an account to see the notification system.
NB!! *THIS IS A WORK IN PROGRESS*
---------------------------------
This is where it all begins. In *1* week we should have a wiki system appealing to any kind of Django developer out there. Here is the manifest (so far):
This is where it all begins. In *<1 week* we should have a wiki system appealing to any kind of Django developer out there. Here is the manifest (so far):
* **Be pluggable and light-weight.** Don't integrate optional features in the core.
* **Be open.** Make an extension API that allows the ecology of the wiki to grow. After all, Wikipedia consists of some [680 extensions](http://svn.wikimedia.org/viewvc/mediawiki/trunk/extensions/) written for MediaWiki.
......
# -*- coding: utf-8 -*-
from django.conf import settings as django_settings
from django.core.urlresolvers import reverse
from django.shortcuts import redirect, get_object_or_404, render_to_response
from django.shortcuts import redirect, get_object_or_404
from django.template.context import RequestContext
from django.http import HttpResponse, HttpResponseNotFound,\
HttpResponseForbidden
......
from django.db import models
from django.utils.translation import ugettext_lazy as _
import settings
from . import settings
from wiki import managers
from wiki.models.pluginbase import ReusablePlugin
......@@ -26,6 +26,7 @@ class Attachment(ReusablePlugin):
class Meta:
verbose_name = _(u'attachment')
verbose_name_plural = _(u'attachments')
app_label = settings.APP_LABEL
def __unicode__(self):
return "%s: %s" % (self.article.current_revision.title, self.original_filename)
......@@ -75,6 +76,7 @@ class AttachmentRevision(BaseRevisionMixin, models.Model):
verbose_name_plural = _(u'attachment revisions')
ordering = ('created',)
get_latest_by = ('revision_number',)
app_label = settings.APP_LABEL
def get_filename(self):
"""Used to retrieve the filename of a revision.
......
from django.conf import settings as django_settings
APP_LABEL = 'wiki'
SLUG = "attachments"
# Allow anonymous users to upload (not nice on an open network)
......@@ -27,3 +28,4 @@ UPLOAD_PATH_OBSCURIFY = getattr(django_settings, 'WIKI_UPLOAD_PATH_OBSCURIFY', T
# You are asked to explicitly enter all file extensions that you want
# to allow. For your own safety.
FILE_EXTENSIONS = getattr(django_settings, 'WIKI_FILE_EXTENSIONS', ['pdf', 'doc', 'odt', 'docx', 'txt'])
......@@ -15,6 +15,8 @@ class Image(RevisionPlugin):
image = models.ImageField(upload_to=settings.IMAGE_PATH,
max_length=2000)
def get_filename(self):
if self.image:
return self.image.path.split('/')[-1]
......@@ -22,6 +24,7 @@ class Image(RevisionPlugin):
class Meta:
verbose_name = _(u'image')
verbose_name_plural = _(u'images')
app_label = settings.APP_LABEL
def __unicode__(self):
return _(u'Image: %s') % self.get_filename()
......@@ -6,4 +6,6 @@ IMAGE_PATH = getattr(django_settings, 'WIKI_IMAGE_PATH', "wiki/images/%aid/")
# Allow anonymous users to upload (not nice on an open network)
ANONYMOUS = getattr(django_settings, 'WIKI_ATTACHMENTS_ANONYMOUS', False)
SLUG = 'images'
\ No newline at end of file
SLUG = 'images'
APP_LABEL = 'wiki'
\ No newline at end of file
{% load i18n wiki_tags wiki_images_tags humanize %}
{% load i18n wiki_tags wiki_images_tags humanize thumbnail %}
{% load url from future %}
<h4>{% trans "Available images" %}</h4>
<p>{% trans "Click on an image below to insert in your text. The format of the code inserted is:" %}<br /><code>[image:id alignment caption text]</code></p>
<table class="table table-bordered table-striped">
<tr>
<th>{% trans "File" %}</th>
<th>{% trans "Added" %}</th>
</tr>
<table class="table table-striped">
{% for image in article|images_for_article %}
<tr>
<td>{{ image.get_filename }}</td>
<td>{{ image.created|naturaltime }}</td>
<td>
{% thumbnail image.image "100x50" crop="center" as thumb %}
<img src="{{ thumb.url }}" alt="{{ image.get_filename }}" width="{{ thumb.width }}" height="{{ thumb.height }}" />
{% endthumbnail %}
</td>
<td><span class="label">{{ image.created|naturaltime }}</span></td>
</tr>
{% endfor %}
</table>
......
......@@ -6,4 +6,4 @@ register = template.Library()
@register.filter
def images_for_article(article):
return models.Image.objects.filter(revision__article=article)
return models.Image.objects.filter(revision__article=article).order_by('-created')
{% extends "wiki/base.html" %}
{% load i18n wiki_tags %}
{% load url from future %}
{% block pagetitle %}{% trans "Log in" %}{% endblock %}
{% block wiki_contents %}
......@@ -13,6 +14,11 @@
</button>
</div>
</form>
<p>
{% trans "Don't have an account?" %} <a href="{% url 'wiki:signup' %}">{% trans "Sign up" %} &raquo;</a>
</p>
<script type="text/javascript">
$('#id_username').focus();
</script>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment