| @@ 32-105 (lines=74) @@ | ||
| 29 | from senaite.core.permissions import AddSampleMatrix |
|
| 30 | ||
| 31 | ||
| 32 | class SampleMatricesView(ListingView): |
|
| 33 | ||
| 34 | def __init__(self, context, request): |
|
| 35 | super(SampleMatricesView, self).__init__(context, request) |
|
| 36 | ||
| 37 | self.catalog = SETUP_CATALOG |
|
| 38 | self.show_select_column = True |
|
| 39 | ||
| 40 | self.contentFilter = { |
|
| 41 | "portal_type": "SampleMatrix", |
|
| 42 | "sort_on": "sortable_title", |
|
| 43 | "sort_order": "ascending", |
|
| 44 | } |
|
| 45 | ||
| 46 | self.context_actions = { |
|
| 47 | _(u"listing_samplematrices_action_add", default=u"Add"): { |
|
| 48 | "url": "++add++SampleMatrix", |
|
| 49 | "permission": AddSampleMatrix, |
|
| 50 | "icon": "senaite_theme/icon/plus" |
|
| 51 | } |
|
| 52 | } |
|
| 53 | ||
| 54 | self.title = translate(_( |
|
| 55 | u"listing_samplematrices_title", |
|
| 56 | default=u"Sample Matrices") |
|
| 57 | ) |
|
| 58 | self.icon = api.get_icon("SampleMatrices", html_tag=False) |
|
| 59 | ||
| 60 | self.columns = collections.OrderedDict(( |
|
| 61 | ("Title", { |
|
| 62 | "title": _( |
|
| 63 | u"listing_samplematrices_column_title", |
|
| 64 | default=u"Sample Matrix" |
|
| 65 | ), |
|
| 66 | "index": "sortable_title"}), |
|
| 67 | ("Description", { |
|
| 68 | "title": _( |
|
| 69 | u"listing_samplematrices_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_samplematrices_state_active", |
|
| 80 | default=u"Active" |
|
| 81 | ), |
|
| 82 | "contentFilter": {"is_active": True}, |
|
| 83 | "columns": self.columns.keys(), |
|
| 84 | }, { |
|
| 85 | "id": "inactive", |
|
| 86 | "title": _( |
|
| 87 | u"listing_samplematrices_state_inactive", |
|
| 88 | default=u"Inactive" |
|
| 89 | ), |
|
| 90 | "contentFilter": {"is_active": False}, |
|
| 91 | "columns": self.columns.keys(), |
|
| 92 | }, { |
|
| 93 | "id": "all", |
|
| 94 | "title": _( |
|
| 95 | u"listing_samplematrices_state_all", |
|
| 96 | default=u"All" |
|
| 97 | ), |
|
| 98 | "contentFilter": {}, |
|
| 99 | "columns": self.columns.keys(), |
|
| 100 | }, |
|
| 101 | ] |
|
| 102 | ||
| 103 | def folderitem(self, obj, item, index): |
|
| 104 | item["replace"]["Title"] = get_link_for(obj) |
|
| 105 | return item |
|
| 106 | ||
| @@ 32-105 (lines=74) @@ | ||
| 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 | } |
|
| 45 | ||
| 46 | self.context_actions = { |
|
| 47 | _(u"listing_sampletemplates_action_add", default=u"Add"): { |
|
| 48 | "url": "++add++SampleTemplate", |
|
| 49 | "permission": AddSampleTemplate, |
|
| 50 | "icon": "senaite_theme/icon/plus" |
|
| 51 | } |
|
| 52 | } |
|
| 53 | ||
| 54 | self.title = translate(_( |
|
| 55 | u"listing_sampletemplates_title", |
|
| 56 | default=u"Sample Templates") |
|
| 57 | ) |
|
| 58 | self.icon = api.get_icon("SampleTemplates", html_tag=False) |
|
| 59 | ||
| 60 | self.columns = collections.OrderedDict(( |
|
| 61 | ("Title", { |
|
| 62 | "title": _( |
|
| 63 | u"listing_sampletemplates_column_title", |
|
| 64 | default=u"Sample Template" |
|
| 65 | ), |
|
| 66 | "index": "sortable_title"}), |
|
| 67 | ("Description", { |
|
| 68 | "title": _( |
|
| 69 | u"listing_sampletemplates_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_sampletemplates_state_active", |
|
| 80 | default=u"Active" |
|
| 81 | ), |
|
| 82 | "contentFilter": {"is_active": True}, |
|
| 83 | "columns": self.columns.keys(), |
|
| 84 | }, { |
|
| 85 | "id": "inactive", |
|
| 86 | "title": _( |
|
| 87 | u"listing_sampletemplates_state_inactive", |
|
| 88 | default=u"Inactive" |
|
| 89 | ), |
|
| 90 | "contentFilter": {"is_active": False}, |
|
| 91 | "columns": self.columns.keys(), |
|
| 92 | }, { |
|
| 93 | "id": "all", |
|
| 94 | "title": _( |
|
| 95 | u"listing_sampletemplates_state_all", |
|
| 96 | default=u"All" |
|
| 97 | ), |
|
| 98 | "contentFilter": {}, |
|
| 99 | "columns": self.columns.keys(), |
|
| 100 | }, |
|
| 101 | ] |
|
| 102 | ||
| 103 | def folderitem(self, obj, item, index): |
|
| 104 | item["replace"]["Title"] = get_link_for(obj) |
|
| 105 | return item |
|
| 106 | ||