| @@ 32-120 (lines=89) @@ | ||
| 29 | from senaite.core.permissions import AddAnalysisSpec |
|
| 30 | ||
| 31 | ||
| 32 | class DynamicAnalysisSpecsView(ListingView): |
|
| 33 | """Displays all system's dynamic analysis specifications |
|
| 34 | """ |
|
| 35 | ||
| 36 | def __init__(self, context, request): |
|
| 37 | super(DynamicAnalysisSpecsView, self).__init__(context, request) |
|
| 38 | ||
| 39 | self.catalog = SETUP_CATALOG |
|
| 40 | ||
| 41 | self.contentFilter = { |
|
| 42 | "portal_type": "DynamicAnalysisSpec", |
|
| 43 | "sort_on": "created", |
|
| 44 | "sort_order": "descending", |
|
| 45 | "path": { |
|
| 46 | "query": api.get_path(self.context), |
|
| 47 | "depth": 1, |
|
| 48 | }, |
|
| 49 | } |
|
| 50 | ||
| 51 | self.context_actions = { |
|
| 52 | _("listing_dynamic_analysisspec_action_add", default="Add"): { |
|
| 53 | "url": "++add++DynamicAnalysisSpec", |
|
| 54 | "permission": AddAnalysisSpec, |
|
| 55 | "icon": "senaite_theme/icon/plus" |
|
| 56 | } |
|
| 57 | } |
|
| 58 | ||
| 59 | self.icon = api.get_icon("DynamicAnalysisSpecs", html_tag=False) |
|
| 60 | ||
| 61 | self.title = translate(_( |
|
| 62 | u"listing_dynamic_analysisspecs_title", |
|
| 63 | default=u"Dynamic Analysis Specifications") |
|
| 64 | ) |
|
| 65 | self.description = self.context.Description() |
|
| 66 | self.show_select_column = True |
|
| 67 | ||
| 68 | self.columns = collections.OrderedDict(( |
|
| 69 | ("Title", { |
|
| 70 | "title": _( |
|
| 71 | u"listing_dynamic_analysisspecs_column_title", |
|
| 72 | default=u"Title" |
|
| 73 | ), |
|
| 74 | "index": "sortable_title"}), |
|
| 75 | ("Description", { |
|
| 76 | "title": _( |
|
| 77 | u"listing_dynamic_analysisspecs_column_description", |
|
| 78 | default=u"Description" |
|
| 79 | ), |
|
| 80 | "toggle": True}), |
|
| 81 | )) |
|
| 82 | ||
| 83 | self.review_states = [ |
|
| 84 | { |
|
| 85 | "id": "default", |
|
| 86 | "title": _( |
|
| 87 | u"listing_dynamic_analysisspecs_state_active", |
|
| 88 | default=u"Active" |
|
| 89 | ), |
|
| 90 | "contentFilter": {"is_active": True}, |
|
| 91 | "columns": self.columns.keys(), |
|
| 92 | }, { |
|
| 93 | "id": "inactive", |
|
| 94 | "title": _( |
|
| 95 | u"listing_dynamic_analysisspecs_state_inactive", |
|
| 96 | default=u"Inactive" |
|
| 97 | ), |
|
| 98 | "contentFilter": {"is_active": False}, |
|
| 99 | "columns": self.columns.keys(), |
|
| 100 | }, { |
|
| 101 | "id": "all", |
|
| 102 | "title": _( |
|
| 103 | u"listing_dynamic_analysisspecs_state_all", |
|
| 104 | default=u"All" |
|
| 105 | ), |
|
| 106 | "contentFilter": {}, |
|
| 107 | "columns": self.columns.keys(), |
|
| 108 | }, |
|
| 109 | ] |
|
| 110 | ||
| 111 | def folderitem(self, obj, item, index): |
|
| 112 | """Service triggered each time an item is iterated in folderitems. |
|
| 113 | The use of this service prevents the extra-loops in child objects. |
|
| 114 | :obj: the instance of the class to be foldered |
|
| 115 | :item: dict containing the properties of the object to be used by |
|
| 116 | the template |
|
| 117 | :index: current index of the item |
|
| 118 | """ |
|
| 119 | item["replace"]["Title"] = get_link_for(obj) |
|
| 120 | return item |
|
| 121 | ||
| @@ 32-114 (lines=83) @@ | ||
| 29 | from senaite.core.permissions import AddSampleCondition |
|
| 30 | ||
| 31 | ||
| 32 | class SampleConditionsView(ListingView): |
|
| 33 | ||
| 34 | def __init__(self, context, request): |
|
| 35 | super(SampleConditionsView, self).__init__(context, request) |
|
| 36 | ||
| 37 | self.catalog = SETUP_CATALOG |
|
| 38 | self.show_select_column = True |
|
| 39 | ||
| 40 | self.contentFilter = { |
|
| 41 | "portal_type": "SampleCondition", |
|
| 42 | "sort_on": "sortable_title", |
|
| 43 | "sort_order": "ascending", |
|
| 44 | } |
|
| 45 | ||
| 46 | self.context_actions = { |
|
| 47 | _(u"listing_sampleconditions_action_add", default=u"Add"): { |
|
| 48 | "url": "++add++SampleCondition", |
|
| 49 | "permission": AddSampleCondition, |
|
| 50 | "icon": "++resource++bika.lims.images/add.png" |
|
| 51 | } |
|
| 52 | } |
|
| 53 | ||
| 54 | self.title = translate(_( |
|
| 55 | u"listing_sampleconditions_title", |
|
| 56 | default=u"Sample Conditions") |
|
| 57 | ) |
|
| 58 | self.icon = api.get_icon("SampleConditions", html_tag=False) |
|
| 59 | ||
| 60 | self.columns = collections.OrderedDict(( |
|
| 61 | ("Title", { |
|
| 62 | "title": _( |
|
| 63 | u"listing_sampleconditions_column_title", |
|
| 64 | default=u"Sample Condition" |
|
| 65 | ), |
|
| 66 | "index": "sortable_title"}), |
|
| 67 | ("Description", { |
|
| 68 | "title": _( |
|
| 69 | u"listing_sampleconditions_column_description", |
|
| 70 | default=u"Description" |
|
| 71 | ), |
|
| 72 | "toggle": True}), |
|
| 73 | )) |
|
| 74 | ||
| 75 | self.review_states = [ |
|
| 76 | { |
|
| 77 | "id": "default", |
|
| 78 | "title": _( |
|
| 79 | u"listing_sampleconditions_state_active", |
|
| 80 | default=u"Active" |
|
| 81 | ), |
|
| 82 | "contentFilter": {"is_active": True}, |
|
| 83 | "transitions": [{"id": "deactivate"}, ], |
|
| 84 | "columns": self.columns.keys(), |
|
| 85 | }, { |
|
| 86 | "id": "inactive", |
|
| 87 | "title": _( |
|
| 88 | u"listing_sampleconditions_state_inactive", |
|
| 89 | default=u"Inactive" |
|
| 90 | ), |
|
| 91 | "contentFilter": {'is_active': False}, |
|
| 92 | "transitions": [{"id": "activate"}, ], |
|
| 93 | "columns": self.columns.keys(), |
|
| 94 | }, { |
|
| 95 | "id": "all", |
|
| 96 | "title": _( |
|
| 97 | u"listing_sampleconditions_state_all", |
|
| 98 | default=u"All" |
|
| 99 | ), |
|
| 100 | "contentFilter": {}, |
|
| 101 | "columns": self.columns.keys(), |
|
| 102 | }, |
|
| 103 | ] |
|
| 104 | ||
| 105 | def folderitem(self, obj, item, index): |
|
| 106 | """Service triggered each time an item is iterated in folderitems. |
|
| 107 | The use of this service prevents the extra-loops in child objects. |
|
| 108 | :obj: the instance of the class to be foldered |
|
| 109 | :item: dict containing the properties of the object to be used by |
|
| 110 | the template |
|
| 111 | :index: current index of the item |
|
| 112 | """ |
|
| 113 | item["replace"]["Title"] = get_link_for(obj) |
|
| 114 | return item |
|
| 115 | ||
| @@ 32-110 (lines=79) @@ | ||
| 29 | from senaite.core.permissions import AddSampleTemplate |
|
| 30 | ||
| 31 | ||
| 32 | class SampleTemplatesView(ListingView): |
|
| 33 | ||
| 34 | def __init__(self, context, request): |
|
| 35 | super(SampleTemplatesView, self).__init__(context, request) |
|
| 36 | ||
| 37 | self.catalog = SETUP_CATALOG |
|
| 38 | self.show_select_column = True |
|
| 39 | ||
| 40 | self.contentFilter = { |
|
| 41 | "portal_type": "SampleTemplate", |
|
| 42 | "sort_on": "sortable_title", |
|
| 43 | "sort_order": "ascending", |
|
| 44 | # restrict the search to the current folder only |
|
| 45 | "path": { |
|
| 46 | "query": api.get_path(context), |
|
| 47 | "level": 0, |
|
| 48 | } |
|
| 49 | } |
|
| 50 | ||
| 51 | self.context_actions = { |
|
| 52 | _(u"listing_sampletemplates_action_add", default=u"Add"): { |
|
| 53 | "url": "++add++SampleTemplate", |
|
| 54 | "permission": AddSampleTemplate, |
|
| 55 | "icon": "senaite_theme/icon/plus" |
|
| 56 | } |
|
| 57 | } |
|
| 58 | ||
| 59 | self.title = translate(_( |
|
| 60 | u"listing_sampletemplates_title", |
|
| 61 | default=u"Sample Templates") |
|
| 62 | ) |
|
| 63 | self.icon = api.get_icon("SampleTemplates", html_tag=False) |
|
| 64 | ||
| 65 | self.columns = collections.OrderedDict(( |
|
| 66 | ("Title", { |
|
| 67 | "title": _( |
|
| 68 | u"listing_sampletemplates_column_title", |
|
| 69 | default=u"Sample Template" |
|
| 70 | ), |
|
| 71 | "index": "sortable_title"}), |
|
| 72 | ("Description", { |
|
| 73 | "title": _( |
|
| 74 | u"listing_sampletemplates_column_description", |
|
| 75 | default=u"Description" |
|
| 76 | ), |
|
| 77 | "toggle": True}), |
|
| 78 | )) |
|
| 79 | ||
| 80 | self.review_states = [ |
|
| 81 | { |
|
| 82 | "id": "default", |
|
| 83 | "title": _( |
|
| 84 | u"listing_sampletemplates_state_active", |
|
| 85 | default=u"Active" |
|
| 86 | ), |
|
| 87 | "contentFilter": {"is_active": True}, |
|
| 88 | "columns": self.columns.keys(), |
|
| 89 | }, { |
|
| 90 | "id": "inactive", |
|
| 91 | "title": _( |
|
| 92 | u"listing_sampletemplates_state_inactive", |
|
| 93 | default=u"Inactive" |
|
| 94 | ), |
|
| 95 | "contentFilter": {"is_active": False}, |
|
| 96 | "columns": self.columns.keys(), |
|
| 97 | }, { |
|
| 98 | "id": "all", |
|
| 99 | "title": _( |
|
| 100 | u"listing_sampletemplates_state_all", |
|
| 101 | default=u"All" |
|
| 102 | ), |
|
| 103 | "contentFilter": {}, |
|
| 104 | "columns": self.columns.keys(), |
|
| 105 | }, |
|
| 106 | ] |
|
| 107 | ||
| 108 | def folderitem(self, obj, item, index): |
|
| 109 | item["replace"]["Title"] = get_link_for(obj) |
|
| 110 | return item |
|
| 111 | ||
| @@ 32-109 (lines=78) @@ | ||
| 29 | from senaite.core.permissions import AddContainerType |
|
| 30 | ||
| 31 | ||
| 32 | class ContainerTypesView(ListingView): |
|
| 33 | ||
| 34 | def __init__(self, context, request): |
|
| 35 | super(ContainerTypesView, self).__init__(context, request) |
|
| 36 | ||
| 37 | self.catalog = SETUP_CATALOG |
|
| 38 | self.show_select_column = True |
|
| 39 | ||
| 40 | self.contentFilter = { |
|
| 41 | "portal_type": "ContainerType", |
|
| 42 | "sort_on": "sortable_title", |
|
| 43 | "sort_order": "ascending", |
|
| 44 | "path": { |
|
| 45 | "query": api.get_path(context), |
|
| 46 | "depth": 1, |
|
| 47 | } |
|
| 48 | } |
|
| 49 | ||
| 50 | self.context_actions = { |
|
| 51 | _("listing_containertypes_action_add", default="Add"): { |
|
| 52 | "url": "++add++ContainerType", |
|
| 53 | "permission": AddContainerType, |
|
| 54 | "icon": "senaite_theme/icon/plus" |
|
| 55 | } |
|
| 56 | } |
|
| 57 | ||
| 58 | self.title = translate(_( |
|
| 59 | "listing_containertypes_title", |
|
| 60 | default="Container Types") |
|
| 61 | ) |
|
| 62 | self.icon = api.get_icon("ContainerTypes", html_tag=False) |
|
| 63 | ||
| 64 | self.columns = collections.OrderedDict(( |
|
| 65 | ("Title", { |
|
| 66 | "title": _( |
|
| 67 | "listing_containertypes_column_title", |
|
| 68 | default="Title" |
|
| 69 | ), |
|
| 70 | "index": "sortable_title"}), |
|
| 71 | ("Description", { |
|
| 72 | "title": _( |
|
| 73 | "listing_containertypes_column_description", |
|
| 74 | default="Description" |
|
| 75 | ), |
|
| 76 | "toggle": True}), |
|
| 77 | )) |
|
| 78 | ||
| 79 | self.review_states = [ |
|
| 80 | { |
|
| 81 | "id": "default", |
|
| 82 | "title": _( |
|
| 83 | "listing_containertypes_state_active", |
|
| 84 | default="Active" |
|
| 85 | ), |
|
| 86 | "contentFilter": {"is_active": True}, |
|
| 87 | "columns": self.columns.keys(), |
|
| 88 | }, { |
|
| 89 | "id": "inactive", |
|
| 90 | "title": _( |
|
| 91 | "listing_containertypes_state_inactive", |
|
| 92 | default="Inactive" |
|
| 93 | ), |
|
| 94 | "contentFilter": {"is_active": False}, |
|
| 95 | "columns": self.columns.keys(), |
|
| 96 | }, { |
|
| 97 | "id": "all", |
|
| 98 | "title": _( |
|
| 99 | "listing_containertypes_state_all", |
|
| 100 | default="All" |
|
| 101 | ), |
|
| 102 | "contentFilter": {}, |
|
| 103 | "columns": self.columns.keys(), |
|
| 104 | }, |
|
| 105 | ] |
|
| 106 | ||
| 107 | def folderitem(self, obj, item, index): |
|
| 108 | item["replace"]["Title"] = get_link_for(obj) |
|
| 109 | return item |
|
| 110 | ||
| @@ 32-107 (lines=76) @@ | ||
| 29 | from senaite.core.permissions import AddPreservation |
|
| 30 | ||
| 31 | ||
| 32 | class SamplePreservationsView(ListingView): |
|
| 33 | ||
| 34 | def __init__(self, context, request): |
|
| 35 | super(SamplePreservationsView, self).__init__(context, request) |
|
| 36 | ||
| 37 | self.catalog = SETUP_CATALOG |
|
| 38 | self.show_select_column = True |
|
| 39 | ||
| 40 | self.contentFilter = { |
|
| 41 | "portal_type": "SamplePreservation", |
|
| 42 | "sort_on": "sortable_title", |
|
| 43 | "sort_order": "ascending", |
|
| 44 | } |
|
| 45 | ||
| 46 | self.context_actions = { |
|
| 47 | _(u"listing_samplepreservations_action_add", default=u"Add"): { |
|
| 48 | "url": "++add++SamplePreservation", |
|
| 49 | "permission": AddPreservation, |
|
| 50 | "icon": "senaite_theme/icon/plus" |
|
| 51 | } |
|
| 52 | } |
|
| 53 | ||
| 54 | self.title = translate(_( |
|
| 55 | u"listing_samplepreservations_title", |
|
| 56 | default=u"Sample Preservations") |
|
| 57 | ) |
|
| 58 | self.icon = api.get_icon("SamplePreservations", html_tag=False) |
|
| 59 | ||
| 60 | self.columns = collections.OrderedDict(( |
|
| 61 | ("Title", { |
|
| 62 | "title": _( |
|
| 63 | u"listing_samplepreservations_column_title", |
|
| 64 | default=u"Sample Preservation" |
|
| 65 | ), |
|
| 66 | "index": "sortable_title"}), |
|
| 67 | ("Description", { |
|
| 68 | "title": _( |
|
| 69 | u"listing_samplepreservations_column_description", |
|
| 70 | default=u"Description" |
|
| 71 | ), |
|
| 72 | "toggle": True}), |
|
| 73 | )) |
|
| 74 | ||
| 75 | self.review_states = [ |
|
| 76 | { |
|
| 77 | "id": "default", |
|
| 78 | "title": _( |
|
| 79 | u"listing_samplepreservations_state_active", |
|
| 80 | default=u"Active" |
|
| 81 | ), |
|
| 82 | "contentFilter": {"is_active": True}, |
|
| 83 | "transitions": [{"id": "deactivate"}, ], |
|
| 84 | "columns": self.columns.keys(), |
|
| 85 | }, { |
|
| 86 | "id": "inactive", |
|
| 87 | "title": _( |
|
| 88 | u"listing_samplepreservations_state_inactive", |
|
| 89 | default=u"Inactive" |
|
| 90 | ), |
|
| 91 | "contentFilter": {'is_active': False}, |
|
| 92 | "transitions": [{"id": "activate"}, ], |
|
| 93 | "columns": self.columns.keys(), |
|
| 94 | }, { |
|
| 95 | "id": "all", |
|
| 96 | "title": _( |
|
| 97 | u"listing_samplepreservations_state_all", |
|
| 98 | default=u"All" |
|
| 99 | ), |
|
| 100 | "contentFilter": {}, |
|
| 101 | "columns": self.columns.keys(), |
|
| 102 | }, |
|
| 103 | ] |
|
| 104 | ||
| 105 | def folderitem(self, obj, item, index): |
|
| 106 | item["replace"]["Title"] = get_link_for(obj) |
|
| 107 | return item |
|
| 108 | ||