Remove use of extra_columns and move logic to apps.py.
This commit is contained in:
@@ -1,8 +1,12 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from datetime import datetime
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from common import MayanAppConfig, menu_object, menu_setup, menu_sidebar
|
||||
from common.utils import encapsulate
|
||||
from navigation import SourceColumn
|
||||
|
||||
from .api import Key, KeyStub
|
||||
from .links import (
|
||||
@@ -19,6 +23,36 @@ class DjangoGPGApp(MayanAppConfig):
|
||||
def ready(self):
|
||||
super(DjangoGPGApp, self).ready()
|
||||
|
||||
SourceColumn(source=Key, label='ID', attribute='key_id')
|
||||
SourceColumn(
|
||||
source=Key, label='Owner', attribute=encapsulate(
|
||||
lambda key: ', '.join(key.uids)
|
||||
)
|
||||
)
|
||||
|
||||
SourceColumn(
|
||||
source=KeyStub, label='ID', attribute=encapsulate(
|
||||
lambda key: '...{0}'.format(key.key_id[-16:])
|
||||
)
|
||||
)
|
||||
SourceColumn(source=KeyStub, label='Type', attribute='key_type')
|
||||
SourceColumn(
|
||||
source=KeyStub, label='Creation date', attribute=encapsulate(
|
||||
lambda key: datetime.fromtimestamp(int(key.date))
|
||||
)
|
||||
)
|
||||
SourceColumn(
|
||||
source=KeyStub, label='Expiration date', attribute=encapsulate(
|
||||
lambda key: datetime.fromtimestamp(int(key.expires)) if key.expires else _('No expiration')
|
||||
)
|
||||
)
|
||||
SourceColumn(source=KeyStub, label='Length', attribute='length')
|
||||
SourceColumn(
|
||||
source=KeyStub, label='Identities', attribute=encapsulate(
|
||||
lambda key: ', '.join(key.uids)
|
||||
)
|
||||
)
|
||||
|
||||
menu_object.bind_links(links=(link_key_delete,), sources=(Key,))
|
||||
menu_object.bind_links(links=(link_key_receive,), sources=(KeyStub,))
|
||||
menu_setup.bind_links(links=(link_key_setup,))
|
||||
|
||||
@@ -69,16 +69,6 @@ class PublicKeyListView(SingleObjectListView):
|
||||
|
||||
def get_extra_context(self):
|
||||
return {
|
||||
'extra_columns': [
|
||||
{
|
||||
'name': _('Key ID'),
|
||||
'attribute': 'key_id',
|
||||
},
|
||||
{
|
||||
'name': _('Owner'),
|
||||
'attribute': encapsulate(lambda x: ', '.join(x.uids)),
|
||||
},
|
||||
],
|
||||
'hide_object': True,
|
||||
'title': self.get_title()
|
||||
}
|
||||
@@ -156,42 +146,8 @@ class KeyQueryResultView(SingleObjectListView):
|
||||
|
||||
def get_extra_context(self):
|
||||
return {
|
||||
'title': _('Key query results'),
|
||||
'hide_object': True,
|
||||
'extra_columns': (
|
||||
{
|
||||
'name': _('ID'),
|
||||
'attribute': encapsulate(
|
||||
lambda key: '...{0}'.format(key.key_id[-16:])
|
||||
),
|
||||
},
|
||||
{
|
||||
'name': _('Type'),
|
||||
'attribute': 'key_type',
|
||||
},
|
||||
{
|
||||
'name': _('Creation date'),
|
||||
'attribute': encapsulate(
|
||||
lambda key: datetime.fromtimestamp(int(key.date))
|
||||
)
|
||||
},
|
||||
{
|
||||
'name': _('Expiration date'),
|
||||
'attribute': encapsulate(
|
||||
lambda key: datetime.fromtimestamp(int(key.expires)) if key.expires else _('No expiration')
|
||||
)
|
||||
},
|
||||
{
|
||||
'name': _('Length'),
|
||||
'attribute': 'length',
|
||||
},
|
||||
{
|
||||
'name': _('Identities'),
|
||||
'attribute': encapsulate(
|
||||
lambda key: ', '.join(key.uids)
|
||||
),
|
||||
},
|
||||
)
|
||||
'title': _('Key query results'),
|
||||
}
|
||||
|
||||
def get_queryset(self):
|
||||
|
||||
Reference in New Issue
Block a user