Exemple #1
0
class Redirect(TranslatableModel):
    site = models.ForeignKey(Site, related_name='redirects_hvad_set')
    old_path = models.CharField(
        _('redirect from'),
        max_length=200,
        db_index=True,
        help_text=
        _("This should be an absolute path, excluding the domain name. Example: '/events/search/'."
          ))
    translations = TranslatedFields(new_path=models.CharField(
        _('redirect to'),
        max_length=200,
        blank=True,
        help_text=
        _("This can be either an absolute path (as above) or a full URL starting with 'http://'."
          )), )

    class Meta:
        verbose_name = _('redirect')
        verbose_name_plural = _('redirects')
        unique_together = (('site', 'old_path'), )
        ordering = ('old_path', )

    def __unicode__(self):
        return "%s ---> %s" % (self.old_path,
                               self.lazy_translation_getter(
                                   'new_path', ugettext('None')))
Exemple #2
0
class NewsLetter(TranslatableModel):
    date = models.DateTimeField(_("Date"), unique=True, choices=[])

    sender_email = models.EmailField(
        _("Sender email"),
        help_text=
        "Only use email addresses for your main domain to ensure deliverability"
    )
    sender_name = models.CharField(_("Sender name"), max_length=255)

    published = models.BooleanField(
        "Is published",
        help_text=
        "Uncheck this box to postpone sending of this newsletter until the box is checked.",
        default=True)

    translations = TranslatedFields(
        subject=models.CharField(max_length=255),
        message=models.TextField(
            help_text=
            "The strings {{ url }} and {{ unsubscribe_url }} may be used to refer to the profile url and unsubscribe url."
        ),
    )

    def __unicode__(self):
        return self.subject

    class Meta:
        ordering = ("-date", )
Exemple #3
0
class NewsLetterTemplate(TranslatableModel):
    is_default_reminder = models.BooleanField(
        _("Is default reminder"),
        help_text=
        _("If this option is checked this template is the standard template for reminder emails."
          ))
    is_default_newsitem = models.BooleanField(
        _("Is default newsitem"),
        help_text=
        _("If this option is checked this template is the standard template for new news items."
          ))
    sender_email = models.EmailField(
        _("Sender email"),
        help_text=
        "Only use email addresses for your main domain to ensure deliverability"
    )
    sender_name = models.CharField(_("Sender name"), max_length=255)

    translations = TranslatedFields(
        subject=models.CharField(max_length=255),
        message=models.TextField(
            help_text=
            "The strings {{ url }} and {{ unsubscribe_url }} may be used to refer to the profile url and unsubscribe url."
        ),
    )

    def __unicode__(self):
        return self.subject
Exemple #4
0
class Normal(TranslatableModel):
    shared_field = models.CharField(max_length=255)
    translations = TranslatedFields(translated_field=models.CharField(
        max_length=255))

    def __unicode__(self):
        return self.safe_translation_getter('translated_field',
                                            self.shared_field)
Exemple #5
0
class Related(TranslatableModel):
    normal = models.ForeignKey(Normal, related_name='rel1', null=True)

    translated_fields = TranslatedFields(
        translated=models.ForeignKey(Normal, related_name='rel3', null=True),
        translated_to_translated=models.ForeignKey(Normal,
                                                   related_name='rel4',
                                                   null=True),
    )
class Category(TranslatableModel):
    slug = models.SlugField(
        _('Slug'),
        unique=True,
        help_text=_(
            'A slug is a short name which uniquely identifies the category'))

    translations = TranslatedFields(title=models.CharField(_('Title'),
                                                           max_length=255), )

    class Meta:
        verbose_name = _('Category')
        verbose_name_plural = _('Categories')
        ordering = ('slug', )

    def __unicode__(self):
        return self.title
Exemple #7
0
class NewsLetter(TranslatableModel):
    date = models.DateTimeField(_("Date"), unique=True, choices=[])

    sender_email = models.EmailField(
        _("Sender email"),
        help_text=
        "Only use email addresses for your main domain to ensure deliverability"
    )
    sender_name = models.CharField(_("Sender name"), max_length=255)

    translations = TranslatedFields(
        subject=models.CharField(max_length=255),
        message=models.TextField(
            help_text=
            "The strings {{ url }} and {{ unsubscribe_url }} may be used to refer to the profile url and unsubscribe url."
        ),
    )

    def __unicode__(self):
        return self.subject

    class Meta:
        ordering = ("-date", )
Exemple #8
0
 class MyNamedModel(TranslatableModel):
     translations = TranslatedFields(
         hello=models.CharField(max_length=128),
         meta={'db_table': 'tests_mymodel_i18n'},
     )
Exemple #9
0
 class MyOtherModel(TranslatableModel):
     translations = TranslatedFields(hello=models.CharField(
         max_length=128))
Exemple #10
0
 class MyModel(TranslatableModel):
     translations = TranslatedFields(
         hello=models.CharField(default=DEFAULT, max_length=128))
class Objective(TranslatableModel):
    translations = TranslatedFields(name=models.CharField(max_length=255))

    def __unicode__(self):
        return self.safe_translation_getter('name', 'Objective: %s' % self.pk)
class Entry(TranslatableModel):
    """
    Entry
    """

    slug = models.SlugField(
        _('Slug'),
        unique_for_date='pub_date',
        help_text=
        _('A slug is a short name which uniquely identifies the news item for this day'
          ))

    translations = TranslatedFields(
        title=models.CharField(_('Title'), max_length=255),
        excerpt=models.TextField(_('Excerpt'), blank=True),
        content=models.TextField(_('Content'), blank=True),
    )

    image = models.ImageField(_('Image'),
                              upload_to="journal_images",
                              blank=True,
                              null=True)
    alignment = models.CharField(_("Alignment"),
                                 help_text=_("Alignment of the image"),
                                 max_length=5,
                                 choices=((_("Left"), "left"), (_("Right"),
                                                                "right")),
                                 blank=True,
                                 null=True)

    is_published = models.BooleanField(_('Published'), default=True)
    pub_date = models.DateTimeField(_('Publication date'),
                                    default=datetime.datetime.now())

    created = models.DateTimeField(auto_now_add=True, editable=False)
    updated = models.DateTimeField(auto_now=True, editable=False)

    category = models.ForeignKey(Category, null=True)

    class Meta:
        verbose_name = _('Entry')
        verbose_name_plural = _('Entries')
        ordering = ('-pub_date', )

    def __unicode__(self):
        return self.title

    def get_relative_url_archive_index(self):
        return '%s/%s/' % (self.pub_date.strftime('%Y/%m/%d'), self.slug)

    def get_relative_url_archive_year(self):
        return '%s/%s/' % (self.pub_date.strftime('%m/%d'), self.slug)

    def get_relative_url_archive_month(self):
        return '%s/%s/' % (self.pub_date.strftime('%d'), self.slug)

    def get_relative_url_archive_day(self):
        return '%s/' % self.slug

    def get_relative_url(self):
        return self.get_relative_url_archive_index()
Exemple #13
0
class AggregateModel(TranslatableModel):
    number = models.IntegerField()
    translated_fields = TranslatedFields(
        translated_number=models.IntegerField(), )
Exemple #14
0
class Date(TranslatableModel):
    shared_date = models.DateTimeField()

    translated_fields = TranslatedFields(
        translated_date=models.DateTimeField())
Exemple #15
0
class SimpleRelated(TranslatableModel):
    normal = models.ForeignKey(Normal, related_name='simplerel')

    translated_fields = TranslatedFields(
        translated_field=models.CharField(max_length=255), )