Added forwards on mailboxes.display_addresses
This commit is contained in:
parent
3e1d9f7d22
commit
8a44b99377
4
TODO.md
4
TODO.md
|
@ -463,4 +463,6 @@ with open(file) as handler:
|
|||
|
||||
# Mark transaction process as executed should not override higher transaction states
|
||||
|
||||
# Show password and set password management commands -sam -A|--all --systemuser --account --mailbox vs raw passwords on forms
|
||||
# mailbox.addresses get_Queryset SQL contact @ with mailboxes and forwards
|
||||
|
||||
# Remove membership fee when changing account.type
|
||||
|
|
|
@ -285,8 +285,7 @@ class ChangePasswordAdminMixin(object):
|
|||
form = self.change_password_form(obj, request.POST, related=related, raw=raw)
|
||||
if form.is_valid():
|
||||
form.save()
|
||||
change_message = self.construct_change_message(request, form, None)
|
||||
self.log_change(request, obj, change_message)
|
||||
self.log_change(request, obj, _("Password changed."))
|
||||
msg = _('Password changed successfully.')
|
||||
messages.success(request, msg)
|
||||
update_session_auth_hash(request, form.user) # This is safe
|
||||
|
|
|
@ -15,6 +15,7 @@ class LogEntryAdmin(admin.ModelAdmin):
|
|||
)
|
||||
list_filter = (
|
||||
'action_flag',
|
||||
('user', admin.RelatedOnlyFieldListFilter),
|
||||
('content_type', admin.RelatedOnlyFieldListFilter),
|
||||
)
|
||||
date_hierarchy = 'action_time'
|
||||
|
|
|
@ -15,6 +15,7 @@ from orchestra.admin.utils import admin_link, change_url
|
|||
from orchestra.contrib.accounts.actions import list_accounts
|
||||
from orchestra.contrib.accounts.admin import SelectAccountAdminMixin
|
||||
from orchestra.contrib.accounts.filters import IsActiveListFilter
|
||||
from orchestra.core import caches
|
||||
|
||||
from . import settings
|
||||
from .actions import SendMailboxEmail, SendAddressEmail
|
||||
|
@ -82,11 +83,33 @@ class MailboxAdmin(ChangePasswordAdminMixin, SelectAccountAdminMixin, ExtendedMo
|
|||
type(self).actions = self.actions + (SendMailboxEmail(),)
|
||||
|
||||
def display_addresses(self, mailbox):
|
||||
# Get from forwards
|
||||
cache = caches.get_request_cache()
|
||||
cached_forwards = cache.get('forwards')
|
||||
if cached_forwards is None:
|
||||
cached_forwards = {}
|
||||
qs = Address.objects.filter(forward__regex=r'(^|.*\s)[^@]+(\s.*|$)')
|
||||
qs = qs.select_related('domain')
|
||||
qs = qs.annotate(email=Concat('name', V('@'), 'domain__name'))
|
||||
qs = qs.values_list('id', 'email', 'forward')
|
||||
for addr_id, email, mbox in qs:
|
||||
url = reverse('admin:mailboxes_address_change', args=(addr_id,))
|
||||
link = '<a href="%s">%s</a>' % (url, email)
|
||||
try:
|
||||
cached_forwards[mbox].append(link)
|
||||
except KeyError:
|
||||
cached_forwards[mbox] = [link]
|
||||
cache.set('forwards', cached_forwards)
|
||||
try:
|
||||
forwards = cached_forwards[mailbox.name]
|
||||
except KeyError:
|
||||
forwards = []
|
||||
# Get from mailboxes
|
||||
addresses = []
|
||||
for addr in mailbox.addresses.all():
|
||||
url = change_url(addr)
|
||||
addresses.append('<a href="%s">%s</a>' % (url, addr.email))
|
||||
return '<br>'.join(addresses)
|
||||
return '<br>'.join(addresses+forwards)
|
||||
display_addresses.short_description = _("Addresses")
|
||||
display_addresses.allow_tags = True
|
||||
|
||||
|
|
|
@ -35,6 +35,14 @@ def m2m_collector(sender, *args, **kwargs):
|
|||
|
||||
|
||||
class orchestrate(ContextDecorator):
|
||||
"""
|
||||
Context manager for triggering backend operations out of request-response cycle, e.g. shell
|
||||
|
||||
with orchestrate():
|
||||
user = SystemUser.objects.get(username='rata')
|
||||
user.shell = '/dev/null'
|
||||
user.save(update_fields=('shell',))
|
||||
"""
|
||||
thread_locals = local()
|
||||
thread_locals.pending_operations = None
|
||||
thread_locals.route_cache = None
|
||||
|
|
|
@ -56,7 +56,8 @@ class OrderAdmin(AccountAdminMixin, ExtendedModelAdmin):
|
|||
'display_metric'
|
||||
)
|
||||
list_filter = (
|
||||
ActiveOrderListFilter, IgnoreOrderListFilter, BilledOrderListFilter, 'service'
|
||||
ActiveOrderListFilter, IgnoreOrderListFilter, BilledOrderListFilter, 'account__type',
|
||||
'service',
|
||||
)
|
||||
default_changelist_filters = (
|
||||
('ignore', '0'),
|
||||
|
|
|
@ -47,7 +47,7 @@ def set_permission(modeladmin, request, queryset):
|
|||
user.set_perm_perms)
|
||||
context = {
|
||||
'action': verbose_action,
|
||||
'perms': verbose_permissions,
|
||||
'perms': verbose_permissions.lower(),
|
||||
'to': os.path.join(user.set_perm_base_home, user.set_perm_home_extension),
|
||||
}
|
||||
msg = _("%(action)s %(perms)s permission to %(to)s") % context
|
||||
|
|
Loading…
Reference in New Issue