Convert the two_state_widget to a class and update it to use the new icon class.
Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
@@ -16,6 +16,9 @@ icon_current_user_locale_profile_edit = Icon(
|
|||||||
driver_name='fontawesome', symbol='globe'
|
driver_name='fontawesome', symbol='globe'
|
||||||
)
|
)
|
||||||
icon_documentation = Icon(driver_name='fontawesome', symbol='book')
|
icon_documentation = Icon(driver_name='fontawesome', symbol='book')
|
||||||
|
icon_fail = Icon(
|
||||||
|
driver_name='fontawesome', symbol='times'
|
||||||
|
)
|
||||||
icon_forum = Icon(
|
icon_forum = Icon(
|
||||||
driver_name='fontawesome', symbol='life-ring'
|
driver_name='fontawesome', symbol='life-ring'
|
||||||
)
|
)
|
||||||
@@ -31,6 +34,9 @@ icon_menu_user = Icon(
|
|||||||
icon_object_error_list_with_icon = Icon(
|
icon_object_error_list_with_icon = Icon(
|
||||||
driver_name='fontawesome', symbol='lock'
|
driver_name='fontawesome', symbol='lock'
|
||||||
)
|
)
|
||||||
|
icon_ok = Icon(
|
||||||
|
driver_name='fontawesome', symbol='check'
|
||||||
|
)
|
||||||
icon_packages_licenses = Icon(
|
icon_packages_licenses = Icon(
|
||||||
driver_name='fontawesome', symbol='certificate'
|
driver_name='fontawesome', symbol='certificate'
|
||||||
)
|
)
|
||||||
@@ -43,3 +49,4 @@ icon_support = Icon(
|
|||||||
icon_tools = Icon(
|
icon_tools = Icon(
|
||||||
driver_name='fontawesome', symbol='wrench'
|
driver_name='fontawesome', symbol='wrench'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ from django.utils.encoding import force_text
|
|||||||
from django.utils.html import format_html
|
from django.utils.html import format_html
|
||||||
from django.utils.safestring import mark_safe
|
from django.utils.safestring import mark_safe
|
||||||
|
|
||||||
|
from icons import icon_fail as default_icon_fail, icon_ok as default_icon_ok
|
||||||
|
|
||||||
|
|
||||||
class DisableableSelectWidget(forms.SelectMultiple):
|
class DisableableSelectWidget(forms.SelectMultiple):
|
||||||
allow_multiple_selected = True
|
allow_multiple_selected = True
|
||||||
@@ -76,8 +78,22 @@ class TextAreaDiv(forms.widgets.Widget):
|
|||||||
super(TextAreaDiv, self).__init__(default_attrs)
|
super(TextAreaDiv, self).__init__(default_attrs)
|
||||||
|
|
||||||
|
|
||||||
def two_state_template(state, ok_icon='fa fa-check', fail_icon='fa fa-times'):
|
class TwoStateWidget(object):
|
||||||
if state:
|
def __init__(self, state, icon_ok=None, icon_fail=None):
|
||||||
return mark_safe('<i class="text-success {}"></i>'.format(ok_icon))
|
self.state = state
|
||||||
else:
|
self.icon_ok = icon_ok or default_icon_ok
|
||||||
return mark_safe('<i class="text-danger {}"></i>'.format(fail_icon))
|
self.icon_fail = icon_fail or default_icon_fail
|
||||||
|
|
||||||
|
def render(self):
|
||||||
|
if self.state:
|
||||||
|
return mark_safe(
|
||||||
|
'<div class="text-success">{}</div>'.format(
|
||||||
|
self.icon_ok.render()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
return mark_safe(
|
||||||
|
'<div class="text-danger">{}</div>'.format(
|
||||||
|
self.icon_fail.render()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ from common import (
|
|||||||
MayanAppConfig, menu_facet, menu_main, menu_object, menu_secondary,
|
MayanAppConfig, menu_facet, menu_main, menu_object, menu_secondary,
|
||||||
menu_setup, menu_tools
|
menu_setup, menu_tools
|
||||||
)
|
)
|
||||||
from common.widgets import two_state_template
|
from common.widgets import TwoStateWidget
|
||||||
from documents.signals import post_document_created, post_initial_document_type
|
from documents.signals import post_document_created, post_initial_document_type
|
||||||
from mayan.celery import app
|
from mayan.celery import app
|
||||||
from navigation import SourceColumn
|
from navigation import SourceColumn
|
||||||
@@ -80,7 +80,9 @@ class DocumentIndexingApp(MayanAppConfig):
|
|||||||
SourceColumn(source=Index, label=_('Slug'), attribute='slug')
|
SourceColumn(source=Index, label=_('Slug'), attribute='slug')
|
||||||
SourceColumn(
|
SourceColumn(
|
||||||
source=Index, label=_('Enabled'),
|
source=Index, label=_('Enabled'),
|
||||||
func=lambda context: two_state_template(context['object'].enabled)
|
func=lambda context: TwoStateWidget(
|
||||||
|
state=context['object'].enabled
|
||||||
|
).render()
|
||||||
)
|
)
|
||||||
|
|
||||||
SourceColumn(
|
SourceColumn(
|
||||||
@@ -108,13 +110,15 @@ class DocumentIndexingApp(MayanAppConfig):
|
|||||||
)
|
)
|
||||||
SourceColumn(
|
SourceColumn(
|
||||||
source=IndexTemplateNode, label=_('Enabled'),
|
source=IndexTemplateNode, label=_('Enabled'),
|
||||||
func=lambda context: two_state_template(context['object'].enabled)
|
func=lambda context: TwoStateWidget(
|
||||||
|
state=context['object'].enabled
|
||||||
|
).render()
|
||||||
)
|
)
|
||||||
SourceColumn(
|
SourceColumn(
|
||||||
source=IndexTemplateNode, label=_('Has document links?'),
|
source=IndexTemplateNode, label=_('Has document links?'),
|
||||||
func=lambda context: two_state_template(
|
func=lambda context: TwoStateWidget(
|
||||||
context['object'].link_documents
|
state=context['object'].link_documents
|
||||||
)
|
).render()
|
||||||
)
|
)
|
||||||
|
|
||||||
SourceColumn(
|
SourceColumn(
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ from common import (
|
|||||||
from common.classes import ModelAttribute
|
from common.classes import ModelAttribute
|
||||||
from common.links import link_object_error_list
|
from common.links import link_object_error_list
|
||||||
from common.permissions_runtime import permission_error_log_view
|
from common.permissions_runtime import permission_error_log_view
|
||||||
from common.widgets import two_state_template
|
from common.widgets import TwoStateWidget
|
||||||
from mayan.celery import app
|
from mayan.celery import app
|
||||||
from navigation import SourceColumn
|
from navigation import SourceColumn
|
||||||
|
|
||||||
@@ -198,7 +198,9 @@ class DocumentStatesApp(MayanAppConfig):
|
|||||||
|
|
||||||
SourceColumn(
|
SourceColumn(
|
||||||
source=WorkflowState, label=_('Is initial state?'),
|
source=WorkflowState, label=_('Is initial state?'),
|
||||||
func=lambda context: two_state_template(context['object'].initial)
|
func=lambda context: TwoStateWidget(
|
||||||
|
state=context['object'].initial
|
||||||
|
).render()
|
||||||
)
|
)
|
||||||
SourceColumn(
|
SourceColumn(
|
||||||
source=WorkflowState, label=_('Completion'), attribute='completion'
|
source=WorkflowState, label=_('Completion'), attribute='completion'
|
||||||
@@ -209,7 +211,9 @@ class DocumentStatesApp(MayanAppConfig):
|
|||||||
)
|
)
|
||||||
SourceColumn(
|
SourceColumn(
|
||||||
source=WorkflowStateAction, label=_('Enabled?'),
|
source=WorkflowStateAction, label=_('Enabled?'),
|
||||||
func=lambda context: two_state_template(context['object'].enabled)
|
func=lambda context: TwoStateWidget(
|
||||||
|
state=context['object'].enabled
|
||||||
|
).render()
|
||||||
)
|
)
|
||||||
SourceColumn(
|
SourceColumn(
|
||||||
source=WorkflowStateAction, label=_('When?'),
|
source=WorkflowStateAction, label=_('When?'),
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ from common import (
|
|||||||
from common.classes import ModelAttribute
|
from common.classes import ModelAttribute
|
||||||
from common.dashboards import dashboard_main
|
from common.dashboards import dashboard_main
|
||||||
from common.signals import post_initial_setup
|
from common.signals import post_initial_setup
|
||||||
from common.widgets import two_state_template
|
from common.widgets import TwoStateWidget
|
||||||
from converter.links import link_transformation_list
|
from converter.links import link_transformation_list
|
||||||
from converter.permissions import (
|
from converter.permissions import (
|
||||||
permission_transformation_create,
|
permission_transformation_create,
|
||||||
@@ -251,7 +251,9 @@ class DocumentsApp(MayanAppConfig):
|
|||||||
|
|
||||||
SourceColumn(
|
SourceColumn(
|
||||||
source=DocumentTypeFilename, label=_('Enabled'),
|
source=DocumentTypeFilename, label=_('Enabled'),
|
||||||
func=lambda context: two_state_template(context['object'].enabled)
|
func=lambda context: TwoStateWidget(
|
||||||
|
state=context['object'].enabled
|
||||||
|
).render()
|
||||||
)
|
)
|
||||||
|
|
||||||
# DeletedDocument
|
# DeletedDocument
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ from common import (
|
|||||||
MayanAppConfig, menu_main, menu_object, menu_secondary, menu_tools,
|
MayanAppConfig, menu_main, menu_object, menu_secondary, menu_tools,
|
||||||
menu_user
|
menu_user
|
||||||
)
|
)
|
||||||
from common.widgets import two_state_template
|
from common.widgets import TwoStateWidget
|
||||||
from navigation import SourceColumn
|
from navigation import SourceColumn
|
||||||
|
|
||||||
from .links import (
|
from .links import (
|
||||||
@@ -75,9 +75,9 @@ class EventsApp(MayanAppConfig):
|
|||||||
)
|
)
|
||||||
SourceColumn(
|
SourceColumn(
|
||||||
source=Notification, label=_('Seen'),
|
source=Notification, label=_('Seen'),
|
||||||
func=lambda context: two_state_template(
|
func=lambda context: TwoStateWidget(
|
||||||
state=context['object'].read
|
state=context['object'].read
|
||||||
)
|
).render()
|
||||||
)
|
)
|
||||||
|
|
||||||
menu_main.bind_links(
|
menu_main.bind_links(
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ from common import (
|
|||||||
MayanAppConfig, menu_facet, menu_object, menu_secondary, menu_setup,
|
MayanAppConfig, menu_facet, menu_object, menu_secondary, menu_setup,
|
||||||
menu_sidebar
|
menu_sidebar
|
||||||
)
|
)
|
||||||
from common.widgets import two_state_template
|
from common.widgets import TwoStateWidget
|
||||||
from navigation import SourceColumn
|
from navigation import SourceColumn
|
||||||
|
|
||||||
from .links import (
|
from .links import (
|
||||||
@@ -65,12 +65,16 @@ class LinkingApp(MayanAppConfig):
|
|||||||
)
|
)
|
||||||
SourceColumn(
|
SourceColumn(
|
||||||
source=SmartLink, label=_('Enabled'),
|
source=SmartLink, label=_('Enabled'),
|
||||||
func=lambda context: two_state_template(context['object'].enabled)
|
func=lambda context: TwoStateWidget(
|
||||||
|
state=context['object'].enabled
|
||||||
|
).render()
|
||||||
)
|
)
|
||||||
|
|
||||||
SourceColumn(
|
SourceColumn(
|
||||||
source=SmartLinkCondition, label=_('Enabled'),
|
source=SmartLinkCondition, label=_('Enabled'),
|
||||||
func=lambda context: two_state_template(context['object'].enabled)
|
func=lambda context: TwoStateWidget(
|
||||||
|
state=context['object'].enabled
|
||||||
|
).render()
|
||||||
)
|
)
|
||||||
|
|
||||||
menu_facet.bind_links(
|
menu_facet.bind_links(
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ from common import (
|
|||||||
MayanAppConfig, menu_object, menu_multi_item, menu_secondary, menu_setup,
|
MayanAppConfig, menu_object, menu_multi_item, menu_secondary, menu_setup,
|
||||||
menu_tools
|
menu_tools
|
||||||
)
|
)
|
||||||
from common.widgets import two_state_template
|
from common.widgets import TwoStateWidget
|
||||||
from mayan.celery import app
|
from mayan.celery import app
|
||||||
from navigation import SourceColumn
|
from navigation import SourceColumn
|
||||||
|
|
||||||
@@ -60,15 +60,15 @@ class MailerApp(MayanAppConfig):
|
|||||||
)
|
)
|
||||||
SourceColumn(
|
SourceColumn(
|
||||||
source=UserMailer, label=_('Default?'),
|
source=UserMailer, label=_('Default?'),
|
||||||
func=lambda context: two_state_template(
|
func=lambda context: TwoStateWidget(
|
||||||
context['object'].default
|
state=context['object'].default
|
||||||
)
|
).render()
|
||||||
)
|
)
|
||||||
SourceColumn(
|
SourceColumn(
|
||||||
source=UserMailer, label=_('Enabled?'),
|
source=UserMailer, label=_('Enabled?'),
|
||||||
func=lambda context: two_state_template(
|
func=lambda context: TwoStateWidget(
|
||||||
context['object'].enabled
|
state=context['object'].enabled
|
||||||
)
|
).render()
|
||||||
)
|
)
|
||||||
SourceColumn(
|
SourceColumn(
|
||||||
source=UserMailer, label=_('Label'), attribute='backend_label'
|
source=UserMailer, label=_('Label'), attribute='backend_label'
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ from common import (
|
|||||||
menu_setup, menu_sidebar
|
menu_setup, menu_sidebar
|
||||||
)
|
)
|
||||||
from common.classes import ModelAttribute
|
from common.classes import ModelAttribute
|
||||||
from common.widgets import two_state_template
|
from common.widgets import TwoStateWidget
|
||||||
from documents.search import document_page_search, document_search
|
from documents.search import document_page_search, document_search
|
||||||
from documents.signals import post_document_type_change
|
from documents.signals import post_document_type_change
|
||||||
from mayan.celery import app
|
from mayan.celery import app
|
||||||
@@ -135,9 +135,9 @@ class MetadataApp(MayanAppConfig):
|
|||||||
)
|
)
|
||||||
SourceColumn(
|
SourceColumn(
|
||||||
source=DocumentMetadata, label=_('Required'),
|
source=DocumentMetadata, label=_('Required'),
|
||||||
func=lambda context: two_state_template(
|
func=lambda context: TwoStateWidget(
|
||||||
context['object'].is_required
|
state=context['object'].is_required
|
||||||
)
|
).render()
|
||||||
)
|
)
|
||||||
|
|
||||||
app.conf.CELERY_QUEUES.append(
|
app.conf.CELERY_QUEUES.append(
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ from common.views import (
|
|||||||
ConfirmView, MultiFormView, SingleObjectCreateView,
|
ConfirmView, MultiFormView, SingleObjectCreateView,
|
||||||
SingleObjectDeleteView, SingleObjectEditView, SingleObjectListView
|
SingleObjectDeleteView, SingleObjectEditView, SingleObjectListView
|
||||||
)
|
)
|
||||||
from common.widgets import two_state_template
|
from common.widgets import TwoStateWidget
|
||||||
from documents.models import DocumentType, Document
|
from documents.models import DocumentType, Document
|
||||||
from documents.permissions import (
|
from documents.permissions import (
|
||||||
permission_document_create, permission_document_new_version
|
permission_document_create, permission_document_new_version
|
||||||
@@ -574,7 +574,7 @@ class SetupSourceListView(SingleObjectListView):
|
|||||||
{
|
{
|
||||||
'name': _('Enabled'),
|
'name': _('Enabled'),
|
||||||
'attribute': encapsulate(
|
'attribute': encapsulate(
|
||||||
lambda entry: two_state_template(entry.enabled)
|
lambda entry: TwoStateWidget(state=entry.enabled).render()
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ from django.utils.translation import ugettext_lazy as _
|
|||||||
from common import (
|
from common import (
|
||||||
MayanAppConfig, menu_object, menu_secondary, menu_tools
|
MayanAppConfig, menu_object, menu_secondary, menu_tools
|
||||||
)
|
)
|
||||||
from common.widgets import two_state_template
|
from common.widgets import TwoStateWidget
|
||||||
from navigation import SourceColumn
|
from navigation import SourceColumn
|
||||||
|
|
||||||
from .classes import CeleryQueue, Task
|
from .classes import CeleryQueue, Task
|
||||||
@@ -34,15 +34,15 @@ class TaskManagerApp(MayanAppConfig):
|
|||||||
)
|
)
|
||||||
SourceColumn(
|
SourceColumn(
|
||||||
source=CeleryQueue, label=_('Default queue?'),
|
source=CeleryQueue, label=_('Default queue?'),
|
||||||
func=lambda context: two_state_template(
|
func=lambda context: TwoStateWidget(
|
||||||
context['object'].is_default_queue
|
state=context['object'].is_default_queue
|
||||||
)
|
).render()
|
||||||
)
|
)
|
||||||
SourceColumn(
|
SourceColumn(
|
||||||
source=CeleryQueue, label=_('Is transient?'),
|
source=CeleryQueue, label=_('Is transient?'),
|
||||||
func=lambda context: two_state_template(
|
func=lambda context: TwoStateWidget(
|
||||||
context['object'].is_transient
|
state=context['object'].is_transient
|
||||||
)
|
).render()
|
||||||
)
|
)
|
||||||
SourceColumn(
|
SourceColumn(
|
||||||
source=Task, label=_('Type'), attribute='task_type'
|
source=Task, label=_('Type'), attribute='task_type'
|
||||||
@@ -56,9 +56,9 @@ class TaskManagerApp(MayanAppConfig):
|
|||||||
)
|
)
|
||||||
SourceColumn(
|
SourceColumn(
|
||||||
source=Task, label=_('Acknowledged'),
|
source=Task, label=_('Acknowledged'),
|
||||||
func=lambda context: two_state_template(
|
func=lambda context: TwoStateWidget(
|
||||||
context['object'].kwargs['acknowledged']
|
state=context['object'].kwargs['acknowledged']
|
||||||
)
|
).render()
|
||||||
)
|
)
|
||||||
SourceColumn(
|
SourceColumn(
|
||||||
source=Task, label=_('Arguments'),
|
source=Task, label=_('Arguments'),
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ from acls.links import link_acl_list
|
|||||||
from acls.permissions import permission_acl_edit, permission_acl_view
|
from acls.permissions import permission_acl_edit, permission_acl_view
|
||||||
from common import menu_multi_item, menu_object, menu_secondary, menu_setup
|
from common import menu_multi_item, menu_object, menu_secondary, menu_setup
|
||||||
from common.apps import MayanAppConfig
|
from common.apps import MayanAppConfig
|
||||||
from common.widgets import two_state_template
|
from common.widgets import TwoStateWidget
|
||||||
from metadata import MetadataLookup
|
from metadata import MetadataLookup
|
||||||
from navigation import SourceColumn
|
from navigation import SourceColumn
|
||||||
from rest_api.fields import DynamicSerializerField
|
from rest_api.fields import DynamicSerializerField
|
||||||
@@ -96,15 +96,15 @@ class UserManagementApp(MayanAppConfig):
|
|||||||
)
|
)
|
||||||
SourceColumn(
|
SourceColumn(
|
||||||
source=User, label=_('Active'),
|
source=User, label=_('Active'),
|
||||||
func=lambda context: two_state_template(
|
func=lambda context: TwoStateWidget(
|
||||||
context['object'].is_active
|
state=context['object'].is_active
|
||||||
)
|
).render()
|
||||||
)
|
)
|
||||||
SourceColumn(
|
SourceColumn(
|
||||||
source=User, label=_('Has usable password?'),
|
source=User, label=_('Has usable password?'),
|
||||||
func=lambda context: two_state_template(
|
func=lambda context: TwoStateWidget(
|
||||||
context['object'].has_usable_password()
|
state=context['object'].has_usable_password()
|
||||||
)
|
).render()
|
||||||
)
|
)
|
||||||
|
|
||||||
menu_multi_item.bind_links(
|
menu_multi_item.bind_links(
|
||||||
|
|||||||
Reference in New Issue
Block a user