~anubhav929/sahana-eden/websetup

« back to all changes in this revision

Viewing changes to controllers/hms.py

  • Committer: Fran Boon
  • Date: 2011-03-26 15:41:31 UTC
  • mfrom: (1612.1.96 eden)
  • Revision ID: fran@aidiq.com-20110326154131-wvoa7xyo3rip11zh
merge michael: Improved error messages for shn_site_based_permissions & separate inv & req menus; Make Modules less intertwined: Tabs/Menus appended optionally, remove HMS FK from CR

Show diffs side-by-side

added added

removed removed

Lines of Context:
9
9
module = request.controller
10
10
resourcename = request.function
11
11
 
12
 
if module not in deployment_settings.modules:
 
12
if not deployment_settings.has_module(module):
13
13
    session.error = T("Module disabled!")
14
14
    redirect(URL(r=request, c="default", f="index"))
15
15
 
79
79
 
80
80
    # Pre-processor
81
81
    def prep(r):
82
 
        if r.representation in shn_interactive_view_formats:
 
82
        # Filter out people which are already staff for this warehouse
 
83
        shn_staff_prep(r) 
 
84
        if deployment_settings.has_module("inv"):
 
85
            # Filter out items which are already in this inventory
 
86
            shn_inv_prep(r)
 
87
          
 
88
        # Cascade the organisation_id from the Warehouse to the staff
 
89
        if r.record:
 
90
            db.org_staff.organisation_id.default = r.record.organisation_id
 
91
            db.org_staff.organisation_id.writable = False
 
92
                
 
93
        if r.interactive:
83
94
            # Don't send the locations list to client (pulled by AJAX instead)
84
95
            r.table.location_id.requires = IS_NULL_OR(IS_ONE_OF_EMPTY(db, "gis_location.id"))
85
96
 
140
151
                #db.rms_req.location_id.comment = ""
141
152
 
142
153
        elif r.representation == "aadata":
 
154
            pass
143
155
            # Hide the Implied fields here too to make columns match
144
 
            db.rms_req.shelter_id.readable = False
145
 
            db.rms_req.organisation_id.readable = False
 
156
            #db.rms_req.shelter_id.readable = False
 
157
            #db.rms_req.organisation_id.readable = False
146
158
 
147
159
        return True
148
160
    response.s3.prep = prep
157
169
        return output
158
170
    response.s3.postp = postp
159
171
 
160
 
    tabs = [(T("Status Report"), ""),
161
 
            (T("Bed Capacity"), "bed_capacity"),
162
 
            (T("Activity Report"), "activity"),
163
 
            #(T("Requests"), "req"), # Included in Inventory Tabs
164
 
            (T("Images"), "image"),
165
 
            (T("Services"), "services"),
166
 
            (T("Contacts"), "contact"),
167
 
            (T("Cholera Treatment Capability"), "ctc_capability"),
168
 
            (T("Staff"), "staff")]
169
 
 
170
 
    rheader = lambda r: shn_hms_hospital_rheader(r,
171
 
                                                 tabs=tabs + shn_show_inv_tabs(r))
 
172
    rheader = lambda r: shn_hms_hospital_rheader(r)
172
173
 
173
174
    output = s3_rest_controller(module, resourcename, rheader=rheader)
174
175
    shn_menu()
187
188
            if hospital:
188
189
                _next = r.here()
189
190
                _same = r.same()
 
191
                
 
192
                if not tabs:
 
193
                    tabs = [(T("Status Report"), ""),
 
194
                            (T("Services"), "services"),
 
195
                            (T("Contacts"), "contact"),
 
196
                            (T("Bed Capacity"), "bed_capacity"),
 
197
                            (T("Cholera Treatment Capability"), "ctc_capability"), # @ToDo: make this a deployemnt_setting?
 
198
                            (T("Activity Report"), "activity"),
 
199
                            (T("Images"), "image"),
 
200
                            (T("Staff"), "staff")]
 
201
 
 
202
                    if deployment_settings.has_module("req"):
 
203
                        tabs.append((T("Requests"), "req"))
 
204
                    if deployment_settings.has_module("inv"):
 
205
                        tabs = tabs + shn_show_inv_tabs(r)
190
206
 
191
207
                rheader_tabs = shn_rheader_tabs(r, tabs)
192
208