Fixed bug on humanize.date
This commit is contained in:
parent
4869e55168
commit
257b627a3e
4
TODO.md
4
TODO.md
|
@ -412,4 +412,6 @@ mkhomedir_helper or create ssh homes with bash.rc and such
|
||||||
# warnings if some plugins are disabled, like make routes red
|
# warnings if some plugins are disabled, like make routes red
|
||||||
# replace show emails by https://docs.python.org/3/library/email.contentmanager.html#module-email.contentmanager
|
# replace show emails by https://docs.python.org/3/library/email.contentmanager.html#module-email.contentmanager
|
||||||
|
|
||||||
# put addressform.clean on model.clean and search for other places?
|
|
||||||
|
|
||||||
|
# setupforbiddendomains --url alexa -n 5000
|
||||||
|
|
|
@ -76,7 +76,7 @@ class MailboxAdmin(ChangePasswordAdminMixin, SelectAccountAdminMixin, ExtendedMo
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(MailboxAdmin, self).__init__(*args, **kwargs)
|
super(MailboxAdmin, self).__init__(*args, **kwargs)
|
||||||
if settings.MAILBOXES_LOCAL_ADDRESS_DOMAIN:
|
if settings.MAILBOXES_LOCAL_DOMAIN:
|
||||||
type(self).actions = self.actions + (SendMailboxEmail(),)
|
type(self).actions = self.actions + (SendMailboxEmail(),)
|
||||||
|
|
||||||
def display_addresses(self, mailbox):
|
def display_addresses(self, mailbox):
|
||||||
|
|
|
@ -51,7 +51,8 @@ class MailboxForm(forms.ModelForm):
|
||||||
local_domain = settings.MAILBOXES_LOCAL_DOMAIN
|
local_domain = settings.MAILBOXES_LOCAL_DOMAIN
|
||||||
if name and local_domain:
|
if name and local_domain:
|
||||||
try:
|
try:
|
||||||
addr = Address.objects.get(name=name, domain__name=local_domain, account_id=self.modeladmin.account.pk)
|
addr = Address.objects.get(
|
||||||
|
name=name, domain__name=local_domain, account_id=self.modeladmin.account.pk)
|
||||||
except Address.DoesNotExist:
|
except Address.DoesNotExist:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import os
|
import os
|
||||||
|
import re
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
|
|
||||||
from django.contrib.auth.hashers import make_password
|
from django.contrib.auth.hashers import make_password
|
||||||
|
@ -72,9 +73,9 @@ class Mailbox(models.Model):
|
||||||
return (name, content)
|
return (name, content)
|
||||||
|
|
||||||
def get_local_address(self):
|
def get_local_address(self):
|
||||||
if not settings.MAILBOXES_LOCAL_ADDRESS_DOMAIN:
|
if not settings.MAILBOXES_LOCAL_DOMAIN:
|
||||||
raise AttributeError("Mailboxes do not have a defined local address domain.")
|
raise AttributeError("Mailboxes do not have a defined local address domain.")
|
||||||
return '@'.join((self.name, settings.MAILBOXES_LOCAL_ADDRESS_DOMAIN))
|
return '@'.join((self.name, settings.MAILBOXES_LOCAL_DOMAIN))
|
||||||
|
|
||||||
|
|
||||||
class Address(models.Model):
|
class Address(models.Model):
|
||||||
|
@ -136,7 +137,9 @@ class Address(models.Model):
|
||||||
raise ValidationError(errors)
|
raise ValidationError(errors)
|
||||||
|
|
||||||
def get_forward_mailboxes(self):
|
def get_forward_mailboxes(self):
|
||||||
|
rm_local_domain = re.compile(r'@%s$' % settings.MAILBOXES_LOCAL_DOMAIN)
|
||||||
for forward in self.forward.split():
|
for forward in self.forward.split():
|
||||||
|
forward = rm_local_domain.sub('', forward)
|
||||||
if '@' not in forward:
|
if '@' not in forward:
|
||||||
try:
|
try:
|
||||||
yield Mailbox.objects.get(name=forward)
|
yield Mailbox.objects.get(name=forward)
|
||||||
|
|
|
@ -186,12 +186,6 @@ MAILBOXES_MAILDIRSIZE_PATH = Setting('MAILBOXES_MAILDIRSIZE_PATH',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
MAILBOXES_LOCAL_ADDRESS_DOMAIN = Setting('MAILBOXES_LOCAL_ADDRESS_DOMAIN',
|
|
||||||
ORCHESTRA_BASE_DOMAIN,
|
|
||||||
validators=[validate_name],
|
|
||||||
help_text="Defaults to <tt>ORCHESTRA_BASE_DOMAIN</tt>."
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
MAILBOXES_MAIL_LOG_PATH = Setting('MAILBOXES_MAIL_LOG_PATH',
|
MAILBOXES_MAIL_LOG_PATH = Setting('MAILBOXES_MAIL_LOG_PATH',
|
||||||
'/var/log/mail.log'
|
'/var/log/mail.log'
|
||||||
|
|
|
@ -86,15 +86,15 @@ def naturaldate(date):
|
||||||
delta_midnight = today - date
|
delta_midnight = today - date
|
||||||
|
|
||||||
count = 0
|
count = 0
|
||||||
for chunk, pluralizefun in OLDER_CHUNKS:
|
for chunk, units in OLDER_CHUNKS:
|
||||||
if days < 7.0:
|
if days < 7.0:
|
||||||
count = days
|
count = days
|
||||||
fmt = pluralize_day(count)
|
fmt = verbose_time(count, 'days')
|
||||||
return fmt.format(num=count, ago=ago)
|
return fmt.format(num=count, ago=ago)
|
||||||
if days >= chunk:
|
if days >= chunk:
|
||||||
count = (delta_midnight.days + 1) / chunk
|
count = (delta_midnight.days + 1) / chunk
|
||||||
count = abs(count)
|
count = abs(count)
|
||||||
fmt = pluralizefun(count)
|
fmt = verbose_time(count, units)
|
||||||
return fmt.format(num=count, ago=ago)
|
return fmt.format(num=count, ago=ago)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue