1 | # -*- coding: utf-8 -*- |
||
2 | # |
||
3 | # This file is part of SENAITE.HEALTH. |
||
4 | # |
||
5 | # SENAITE.HEALTH is free software: you can redistribute it and/or modify it |
||
6 | # under the terms of the GNU General Public License as published by the Free |
||
7 | # Software Foundation, version 2. |
||
8 | # |
||
9 | # This program is distributed in the hope that it will be useful, but WITHOUT |
||
10 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
||
11 | # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
||
12 | # details. |
||
13 | # |
||
14 | # You should have received a copy of the GNU General Public License along with |
||
15 | # this program; if not, write to the Free Software Foundation, Inc., 51 |
||
16 | # Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
||
17 | # |
||
18 | # Copyright 2018-2019 by it's authors. |
||
19 | # Some rights reserved, see README and LICENSE. |
||
20 | |||
21 | from AccessControl.SecurityInfo import ClassSecurityInfo |
||
22 | from Products.ATContentTypes.content import schemata |
||
23 | from Products.Archetypes import atapi |
||
24 | from Products.Archetypes.ArchetypeTool import registerType |
||
25 | from Products.Archetypes.public import * |
||
26 | from Products.CMFCore import permissions |
||
27 | from Products.CMFCore.utils import getToolByName |
||
28 | from ZODB.POSException import ConflictError |
||
29 | from bika.lims import bikaMessageFactory as _b |
||
30 | from bika.health import bikaMessageFactory as _ |
||
31 | from bika.lims.browser.bika_listing import BikaListingView |
||
32 | from bika.health.config import PROJECTNAME |
||
33 | from bika.lims.content.bikaschema import BikaFolderSchema |
||
34 | from bika.health.interfaces import IVaccinationCenters |
||
35 | from bika.lims.interfaces import IHaveNoBreadCrumbs |
||
36 | from operator import itemgetter |
||
37 | from plone.app.content.browser.interfaces import IFolderContentsView |
||
38 | from plone.app.folder.folder import ATFolder, ATFolderSchema |
||
39 | from plone.app.layout.globals.interfaces import IViewView |
||
40 | from zope.interface import implements |
||
41 | |||
42 | class VaccinationCentersView(BikaListingView): |
||
43 | implements(IFolderContentsView, IViewView) |
||
44 | View Code Duplication | def __init__(self, context, request): |
|
0 ignored issues
–
show
Duplication
introduced
by
Loading history...
|
|||
45 | super(VaccinationCentersView, self).__init__(context, request) |
||
46 | self.catalog = 'bika_setup_catalog' |
||
47 | self.contentFilter = {'portal_type': 'VaccinationCenter', |
||
48 | 'sort_on': 'getName'} |
||
49 | self.context_actions = {_('Add'): |
||
50 | {'url': 'createObject?type_name=VaccinationCenter', |
||
51 | 'icon': '++resource++bika.lims.images/add.png'}} |
||
52 | self.title = self.context.translate(_("Vaccination Centers")) |
||
53 | self.icon = self.portal_url + "/++resource++bika.health.images/vaccinationcenter_big.png" |
||
54 | self.description = "" |
||
55 | self.show_sort_column = False |
||
56 | self.show_select_row = False |
||
57 | self.show_select_column = True |
||
58 | self.pagesize = 50 |
||
59 | |||
60 | self.columns = { |
||
61 | 'Name': {'title': _('Name'), |
||
62 | 'index': 'getName'}, |
||
63 | 'Email': {'title': _('Email'), |
||
64 | 'toggle': True}, |
||
65 | 'Phone': {'title': _('Phone'), |
||
66 | 'toggle': True}, |
||
67 | 'Fax': {'title': _('Fax'), |
||
68 | 'toggle': True}, |
||
69 | } |
||
70 | self.review_states = [ |
||
71 | {'id':'default', |
||
72 | 'title': _('Active'), |
||
73 | 'contentFilter': {'is_active': True}, |
||
74 | 'transitions': [{'id':'deactivate'}, ], |
||
75 | 'columns': ['Name', |
||
76 | 'Email', |
||
77 | 'Phone', |
||
78 | 'Fax']}, |
||
79 | {'id':'inactive', |
||
80 | 'title': _('Dormant'), |
||
81 | 'contentFilter': {'is_active': False}, |
||
82 | 'transitions': [{'id':'activate'}, ], |
||
83 | 'columns': ['Name', |
||
84 | 'Email', |
||
85 | 'Phone', |
||
86 | 'Fax']}, |
||
87 | {'id':'all', |
||
88 | 'title': _('All'), |
||
89 | 'contentFilter':{}, |
||
90 | 'columns': ['Name', |
||
91 | 'Email', |
||
92 | 'Phone', |
||
93 | 'Fax']}, |
||
94 | ] |
||
95 | |||
96 | def before_render(self): |
||
97 | """Before template render hook |
||
98 | """ |
||
99 | super(VaccinationCentersView, self).before_render() |
||
100 | # Don't allow any context actions on Vaccination Centers folder |
||
101 | self.request.set("disable_border", 1) |
||
102 | |||
103 | def folderitems(self): |
||
104 | items = BikaListingView.folderitems(self) |
||
105 | for x in range(len(items)): |
||
106 | if not items[x].has_key('obj'): continue |
||
107 | obj = items[x]['obj'] |
||
108 | items[x]['Name'] = obj.getName() |
||
109 | items[x]['Email'] = obj.getEmailAddress() |
||
110 | items[x]['Phone'] = obj.getPhone() |
||
111 | items[x]['Fax'] = obj.getFax() |
||
112 | items[x]['replace']['Name'] = "<a href='%s'>%s</a>" % \ |
||
113 | (items[x]['url'], items[x]['Name']) |
||
114 | |||
115 | return items |
||
116 | |||
117 | schema = ATFolderSchema.copy() |
||
118 | class VaccinationCenters(ATFolder): |
||
119 | implements(IVaccinationCenters) |
||
120 | displayContentsTab = False |
||
121 | schema = schema |
||
122 | |||
123 | schemata.finalizeATCTSchema(schema, folderish = True, moveDiscussion = False) |
||
124 | atapi.registerType(VaccinationCenters, PROJECTNAME) |
||
125 |