app/django/contrib/redirects/models.py
changeset 323 ff1a9aa48cfd
parent 54 03e267d67478
equal deleted inserted replaced
322:6641e941ef1e 323:ff1a9aa48cfd
     1 from django.db import models
     1 from django.db import models
     2 from django.contrib.sites.models import Site
     2 from django.contrib.sites.models import Site
     3 from django.utils.translation import ugettext_lazy as _
     3 from django.utils.translation import ugettext_lazy as _
     4 
     4 
     5 class Redirect(models.Model):
     5 class Redirect(models.Model):
     6     site = models.ForeignKey(Site, radio_admin=models.VERTICAL)
     6     site = models.ForeignKey(Site)
     7     old_path = models.CharField(_('redirect from'), max_length=200, db_index=True,
     7     old_path = models.CharField(_('redirect from'), max_length=200, db_index=True,
     8         help_text=_("This should be an absolute path, excluding the domain name. Example: '/events/search/'."))
     8         help_text=_("This should be an absolute path, excluding the domain name. Example: '/events/search/'."))
     9     new_path = models.CharField(_('redirect to'), max_length=200, blank=True,
     9     new_path = models.CharField(_('redirect to'), max_length=200, blank=True,
    10         help_text=_("This can be either an absolute path (as above) or a full URL starting with 'http://'."))
    10         help_text=_("This can be either an absolute path (as above) or a full URL starting with 'http://'."))
    11 
    11 
    13         verbose_name = _('redirect')
    13         verbose_name = _('redirect')
    14         verbose_name_plural = _('redirects')
    14         verbose_name_plural = _('redirects')
    15         db_table = 'django_redirect'
    15         db_table = 'django_redirect'
    16         unique_together=(('site', 'old_path'),)
    16         unique_together=(('site', 'old_path'),)
    17         ordering = ('old_path',)
    17         ordering = ('old_path',)
    18 
    18     
    19     class Admin:
       
    20         list_filter = ('site',)
       
    21         search_fields = ('old_path', 'new_path')
       
    22 
       
    23     def __unicode__(self):
    19     def __unicode__(self):
    24         return u"%s ---> %s" % (self.old_path, self.new_path)
    20         return "%s ---> %s" % (self.old_path, self.new_path)