Skip to content

Commit

Permalink
Improves the admin interface.
Browse files Browse the repository at this point in the history
  • Loading branch information
BertrandBordage committed Aug 6, 2012
1 parent 0b757f7 commit d11531c
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 8 deletions.
11 changes: 7 additions & 4 deletions README.rst
Expand Up @@ -12,15 +12,18 @@ Requirements
Mandatory
---------

* ``Django`` (tested with 1.4).
* `Django <https://www.djangoproject.com/>`_ (tested with 1.4).


Optional
--------

* ``django-reversion`` (tested with 1.6.0) to recover changes and deletions;
* ``django-CMS`` (tested with 2.3), because django-terms has an apphook and
a menu.
* `django-ckeditor <https://github.com/shaunsephton/django-ckeditor>`_
(tested with 3.6.2.1) to type the definition in a beautiful GUI;
* `django-reversion <https://github.com/etianen/django-reversion>`_
(tested with 1.6.0) to recover changes and deletions;
* `django-CMS <https://www.django-cms.org/>`_ (tested with 2.3),
because django-terms has an apphook and a menu.



Expand Down
2 changes: 2 additions & 0 deletions terms/admin.py
Expand Up @@ -12,6 +12,8 @@
class TermAdmin(ModelAdmin):
model = Term
form = TermForm
list_display = ('name', 'url')
search_fields = ('name', 'definition', 'url')


site.register(Term, TermAdmin)
9 changes: 8 additions & 1 deletion terms/forms.py
@@ -1,11 +1,18 @@
# coding: utf-8

from django.forms import ModelForm, ValidationError
from django.forms import ModelForm, CharField, Textarea, ValidationError
from .models import Term
from django.utils.translation import ugettext as _
try:
from ckeditor.widgets import CKEditorWidget
Textarea = CKEditorWidget()
except ImportError:
pass


class TermForm(ModelForm):
definition = CharField(widget=Textarea)

def clean(self):
definition = self.cleaned_data.get('definition')
url = self.cleaned_data.get('url')
Expand Down
11 changes: 9 additions & 2 deletions terms/models.py
Expand Up @@ -7,11 +7,18 @@


class Term(Model):
name = CharField(_('name'), max_length=100)
name = CharField(_('name'), max_length=100, unique=True)
definition = TextField(_('definition'), blank=True)
url = URLField(_('link'), verify_exists=True, blank=True, null=True)
url = URLField(_('link'), verify_exists=True, blank=True, null=True,
help_text=_('Address to which the term will redirect '
'(instead of redirecting to the definition).'))
objects = TermManager()

class Meta:
verbose_name = _('term')
verbose_name_plural = _('terms')
ordering = ('name',)

def __unicode__(self):
return self.name

Expand Down
2 changes: 1 addition & 1 deletion terms/templates/terms/term_detail.html
@@ -1,2 +1,2 @@
<h2>{{ term }}</h2>
<p>{{ term.definition }}</p>
<p>{{ term.definition|safe }}</p>

0 comments on commit d11531c

Please sign in to comment.