Instead of inserting the path of the apps into the Python app, the apps are now referenced by their full import path. This solves name clashes with external or native Python libraries. Example: Mayan statistics app vs. Python new statistics library. Every app reference is now prepended with 'mayan.apps'. Existing config.yml files need to be updated manually. Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
50 lines
1.5 KiB
Python
50 lines
1.5 KiB
Python
from __future__ import unicode_literals
|
|
|
|
from django import forms
|
|
from django.utils.html import escape
|
|
from django.utils.translation import ugettext_lazy as _
|
|
|
|
from mayan.apps.common.forms import DetailForm
|
|
|
|
from .models import Key
|
|
|
|
|
|
class KeyDetailForm(DetailForm):
|
|
def __init__(self, *args, **kwargs):
|
|
instance = kwargs['instance']
|
|
|
|
extra_fields = (
|
|
{'label': _('Key ID'), 'field': 'key_id'},
|
|
{
|
|
'label': _('User ID'),
|
|
'field': lambda x: escape(instance.user_id),
|
|
},
|
|
{
|
|
'label': _('Creation date'), 'field': 'creation_date',
|
|
'widget': forms.widgets.DateInput
|
|
},
|
|
{
|
|
'label': _('Expiration date'),
|
|
'field': lambda x: instance.expiration_date or _('None'),
|
|
'widget': forms.widgets.DateInput
|
|
},
|
|
{'label': _('Fingerprint'), 'field': 'fingerprint'},
|
|
{'label': _('Length'), 'field': 'length'},
|
|
{'label': _('Algorithm'), 'field': 'algorithm'},
|
|
{'label': _('Type'), 'field': lambda x: instance.get_key_type_display()},
|
|
)
|
|
|
|
kwargs['extra_fields'] = extra_fields
|
|
super(KeyDetailForm, self).__init__(*args, **kwargs)
|
|
|
|
class Meta:
|
|
fields = ()
|
|
model = Key
|
|
|
|
|
|
class KeySearchForm(forms.Form):
|
|
term = forms.CharField(
|
|
label=_('Term'),
|
|
help_text=_('Name, e-mail, key ID or key fingerprint to look for.')
|
|
)
|