1
0
Fork 1
mirror of https://github.com/coddingtonbear/django-mailbox.git synced 2026-07-10 06:48:19 +02:00

Add translation support to field names and help texts.

This commit is contained in:
Ariel Gerardo Ríos 2014-08-29 15:40:22 -03:00
parent 4f400fab48
commit 305d1c5c38

View file

@ -16,6 +16,7 @@ import mimetypes
import os.path import os.path
import sys import sys
import uuid import uuid
import six import six
from six.moves.urllib.parse import parse_qs, unquote, urlparse from six.moves.urllib.parse import parse_qs, unquote, urlparse
@ -80,10 +81,15 @@ class ActiveMailboxManager(models.Manager):
class Mailbox(models.Model): class Mailbox(models.Model):
name = models.CharField(max_length=255) name = models.CharField(
uri = models.CharField( _(u'Name'),
max_length=255, max_length=255,
help_text=( )
uri = models.CharField(
_(u'URI'),
max_length=255,
help_text=(_(
"Example: imap+ssl://myusername:mypassword@someserver <br />" "Example: imap+ssl://myusername:mypassword@someserver <br />"
"<br />" "<br />"
"Internet transports include 'imap' and 'pop3'; " "Internet transports include 'imap' and 'pop3'; "
@ -92,14 +98,16 @@ class Mailbox(models.Model):
"<br />" "<br />"
"Be sure to urlencode your username and password should they " "Be sure to urlencode your username and password should they "
"contain illegal characters (like @, :, etc)." "contain illegal characters (like @, :, etc)."
), )),
blank=True, blank=True,
null=True, null=True,
default=None, default=None,
) )
from_email = models.CharField( from_email = models.CharField(
_(u'From email'),
max_length=255, max_length=255,
help_text=( help_text=(_(
"Example: MailBot &lt;mailbot@yourdomain.com&gt;<br />" "Example: MailBot &lt;mailbot@yourdomain.com&gt;<br />"
"'From' header to set for outgoing email.<br />" "'From' header to set for outgoing email.<br />"
"<br />" "<br />"
@ -107,19 +115,21 @@ class Mailbox(models.Model):
"setting is unnecessary.<br />" "setting is unnecessary.<br />"
"If you send e-mail without setting this, your 'From' header will'" "If you send e-mail without setting this, your 'From' header will'"
"be set to match the setting `DEFAULT_FROM_EMAIL`." "be set to match the setting `DEFAULT_FROM_EMAIL`."
), )),
blank=True, blank=True,
null=True, null=True,
default=None, default=None,
) )
active = models.BooleanField( active = models.BooleanField(
help_text=( _(u'Active'),
help_text=(_(
"Check this e-mail inbox for new e-mail messages during polling " "Check this e-mail inbox for new e-mail messages during polling "
"cycles. This checkbox does not have an effect upon whether " "cycles. This checkbox does not have an effect upon whether "
"mail is collected here when this mailbox receives mail from a " "mail is collected here when this mailbox receives mail from a "
"pipe, and does not affect whether e-mail messages can be " "pipe, and does not affect whether e-mail messages can be "
"dispatched from this mailbox. " "dispatched from this mailbox. "
), )),
blank=True, blank=True,
default=True, default=True,
) )
@ -362,34 +372,62 @@ class UnreadMessageManager(models.Manager):
class Message(models.Model): class Message(models.Model):
mailbox = models.ForeignKey(Mailbox, related_name='messages') mailbox = models.ForeignKey(
subject = models.CharField(max_length=255) Mailbox,
message_id = models.CharField(max_length=255) related_name='messages',
verbose_name=_(u'Mailbox'),
)
subject = models.CharField(
_(u'Subject'),
max_length=255
)
message_id = models.CharField(
_(u'Message ID'),
max_length=255
)
in_reply_to = models.ForeignKey( in_reply_to = models.ForeignKey(
'django_mailbox.Message', 'django_mailbox.Message',
related_name='replies', related_name='replies',
blank=True, blank=True,
null=True, null=True,
verbose_name=_(u'In reply to'),
) )
from_header = models.CharField( from_header = models.CharField(
_('From header'),
max_length=255, max_length=255,
) )
to_header = models.TextField()
to_header = models.TextField(
_(u'To header'),
)
outgoing = models.BooleanField( outgoing = models.BooleanField(
_(u'Outgoing'),
default=False, default=False,
blank=True, blank=True,
) )
body = models.TextField() body = models.TextField(
_(u'Body'),
)
encoded = models.BooleanField( encoded = models.BooleanField(
_(u'Encoded'),
default=False, default=False,
help_text='True if the e-mail body is Base64 encoded' help_text=_('True if the e-mail body is Base64 encoded'),
) )
processed = models.DateTimeField( processed = models.DateTimeField(
_('Processed'),
auto_now_add=True auto_now_add=True
) )
read = models.DateTimeField( read = models.DateTimeField(
_(u'Read'),
default=None, default=None,
blank=True, blank=True,
null=True, null=True,
@ -584,9 +622,19 @@ class MessageAttachment(models.Model):
related_name='attachments', related_name='attachments',
null=True, null=True,
blank=True, blank=True,
verbose_name=_('Message'),
)
headers = models.TextField(
_(u'Headers'),
null=True,
blank=True,
)
document = models.FileField(
_(u'Document'),
upload_to='mailbox_attachments/%Y/%m/%d/'
) )
headers = models.TextField(null=True, blank=True)
document = models.FileField(upload_to='mailbox_attachments/%Y/%m/%d/')
def delete(self, *args, **kwargs): def delete(self, *args, **kwargs):
self.document.delete() self.document.delete()