@@ -135,139 +135,33 @@ def index():
135
135
else :
136
136
item = ""
137
137
138
- if deployment_settings .has_module ("cr" ):
139
- s3mgr .load ("cr_shelter" )
140
- SHELTERS = s3 .crud_strings ["cr_shelter" ].subtitle_list
141
- else :
142
- SHELTERS = ""
143
-
144
138
# Menu Boxes
145
- menu_btns = [#div, label, app, function
146
- ["facility" , SHELTERS , "cr" , "shelter" ],
147
- ["facility" , T ("Warehouses" ), "inv" , "warehouse" ],
148
- ["facility" , T ("Hospitals" ), "hms" , "hospital" ],
149
- ["facility" , T ("Offices" ), "org" , "office" ],
150
- ["sit" , T ("Incidents" ), "irs" , "ireport" ],
151
- ["sit" , T ("Assessments" ), "survey" , "series" ],
152
- ["sit" , T ("Assets" ), "asset" , "asset" ],
153
- ["sit" , T ("Inventory Items" ), "inv" , "inv_item" ],
154
- #["dec", T("Gap Map"), "project", "gap_map"],
155
- #["dec", T("Gap Report"), "project", "gap_report"],
156
- ["dec" , T ("Requests" ), "req" , "req" ],
157
- ["res" , T ("Projects" ), "project" , "project" ],
158
- ["res" , T ("Activities" ), "project" , "activity" ],
159
- ["res" , T ("Commitments" ), "req" , "commit" ],
160
- ["res" , T ("Sent Shipments" ), "inv" , "send" ],
161
- ["res" , T ("Received Shipments" ), "inv" , "recv" ]
162
- ]
163
-
164
- # Change to (Mitigation)/Preparedness/Response/Recovery?
165
- menu_divs = {"facility" : DIV ( H3 (T ("Facilities" )),
166
- _id = "facility_box" , _class = "menu_box" ),
167
- "sit" : DIV ( H3 (T ("Situation" )),
168
- _id = "menu_div_sit" , _class = "menu_div" ),
169
- "dec" : DIV ( H3 (T ("Decision" )),
170
- _id = "menu_div_dec" , _class = "menu_div" ),
171
- "res" : DIV ( H3 (T ("Response" )),
172
- _id = "menu_div_res" , _class = "menu_div" ),
173
- }
174
-
175
- for div , label , app , function in menu_btns :
176
- if deployment_settings .has_module (app ):
177
- # @ToDo: Also check permissions (e.g. for anonymous users)
178
- menu_divs [div ].append (A ( DIV (label ,
179
- _class = "menu-btn-r" ),
180
- _class = "menu-btn-l" ,
181
- _href = URL (app ,function )
182
- )
183
- )
184
-
185
- div_arrow = DIV (IMG (_src = "/%s/static/img/arrow_blue_right.png" % \
186
- request .application ),
187
- _class = "div_arrow" )
188
- sit_dec_res_box = DIV (menu_divs ["sit" ],
189
- div_arrow ,
190
- menu_divs ["dec" ],
191
- div_arrow ,
192
- menu_divs ["res" ],
193
- _id = "sit_dec_res_box" ,
194
- _class = "menu_box fleft swidth"
195
- #div_additional,
196
- )
197
- facility_box = menu_divs ["facility" ]
198
- facility_box .append ( A ( IMG (_src = "/%s/static/img/map_icon_128.png" % \
199
- request .application ),
200
- _href = URL (c = "gis" , f = "index" ),
201
- _title = T ("Map" )
202
- )
203
- )
204
-
205
139
datatable_ajax_source = ""
206
140
# Check logged in AND permissions
207
141
if AUTHENTICATED in session .s3 .roles and \
208
- auth .s3_has_permission ("read" , db . org_organisation ):
209
- org_items = organisation ()
210
- datatable_ajax_source = "/%s/default/organisation .aaData" % \
142
+ auth .s3_has_permission ("read" , s3db . project_project ):
143
+ project_items = project ()
144
+ datatable_ajax_source = "/%s/default/project .aaData" % \
211
145
request .application
212
146
response .s3 .actions = None
213
147
response .view = "default/index.html"
214
- auth .permission .controller = "org"
215
- auth .permission .function = "site"
216
- permitted_facilities = auth .permission .permitted_facilities (redirect_on_error = False )
217
- manage_facility_box = ""
218
- if permitted_facilities :
219
- facility_list = s3_represent_facilities (db , permitted_facilities ,
220
- link = False )
221
- facility_opts = [OPTION (opt [1 ], _value = opt [0 ])
222
- for opt in facility_list ]
223
- if facility_list :
224
- manage_facility_box = DIV (H3 (T ("Manage Your Facilities" )),
225
- SELECT (_id = "manage_facility_select" ,
226
- _style = "max-width:400px;" ,
227
- * facility_opts
228
- ),
229
- A (T ("Go" ),
230
- _href = URL (c = "default" , f = "site" ,
231
- args = [facility_list [0 ][0 ]]),
232
- #_disabled = "disabled",
233
- _id = "manage_facility_btn" ,
234
- _class = "action-btn"
235
- ),
236
- _id = "manage_facility_box" ,
237
- _class = "menu_box fleft" )
238
- response .s3 .jquery_ready .append ( """
239
- $('#manage_facility_select').change(function() {
240
- $('#manage_facility_btn').attr('href', S3.Ap.concat('/default/site/', $('#manage_facility_select').val()));
241
- })""" )
242
- else :
243
- manage_facility_box = DIV ()
244
-
245
- org_box = DIV ( H3 (T ("Organizations" )),
246
- A (T ("Add Organization" ),
247
- _href = URL (c = "org" , f = "organisation" ,
248
- args = ["create" ]),
249
- _id = "add-btn" ,
250
- _class = "action-btn" ,
251
- _style = "margin-right: 10px;" ),
252
- org_items ["items" ],
253
- _id = "org_box" ,
148
+ if auth .s3_has_role (ADMIN ):
149
+ add_btn = A (T ("Add Project" ),
150
+ _href = URL (c = "project" , f = "project" ,
151
+ args = ["create" ]),
152
+ _id = "add-btn" ,
153
+ _class = "action-btn" ,
154
+ _style = "margin-right: 10px;" )
155
+ else :
156
+ add_btn = ""
157
+ project_box = DIV ( H3 (T ("Projects" )),
158
+ add_btn ,
159
+ project_items ["items" ],
160
+ _id = "project_box" ,
254
161
_class = "menu_box fleft"
255
162
)
256
163
else :
257
- manage_facility_box = ""
258
- org_box = ""
259
-
260
- # @ToDo: Replace this with an easily-customisable section on the homepage
261
- #settings = db(db.s3_setting.id == 1).select(limitby=(0, 1)).first()
262
- #if settings:
263
- # admin_name = settings.admin_name
264
- # admin_email = settings.admin_email
265
- # admin_tel = settings.admin_tel
266
- #else:
267
- # # db empty and prepopulate is false
268
- # admin_name = T("Sahana Administrator").xml(),
269
- # admin_email = "support@Not Set",
270
- # admin_tel = T("Not Set").xml(),
164
+ project_box = ""
271
165
272
166
# Login/Registration forms
273
167
self_registration = deployment_settings .get_security_self_registration ()
@@ -374,12 +268,7 @@ def index():
374
268
375
269
return dict (title = title ,
376
270
item = item ,
377
-
378
- sit_dec_res_box = sit_dec_res_box ,
379
- facility_box = facility_box ,
380
- manage_facility_box = manage_facility_box ,
381
- org_box = org_box ,
382
-
271
+ project_box = project_box ,
383
272
r = None , # Required for dataTable to work
384
273
datatable_ajax_source = datatable_ajax_source ,
385
274
#admin_name=admin_name,
@@ -394,28 +283,30 @@ def index():
394
283
)
395
284
396
285
# -----------------------------------------------------------------------------
397
- def organisation ():
286
+ def project ():
398
287
"""
399
- Function to handle pagination for the org list on the homepage
288
+ Function to handle pagination for the project list on the homepage
400
289
"""
401
290
402
- table = db .org_organisation
403
- table .id .label = T ("Organization" )
404
- table .id .represent = organisation_represent
291
+ table = s3db .project_project
292
+ table .id .label = T ("Project" )
293
+ table .id .represent = lambda id : \
294
+ s3db .project_project_represent (id , show_link = False )
405
295
406
296
response .s3 .dataTable_sPaginationType = "two_button"
407
297
response .s3 .dataTable_sDom = "rtip" #"frtip" - filter broken
408
298
response .s3 .dataTable_iDisplayLength = 25
409
299
410
- s3mgr .configure ("org_organisation " ,
300
+ s3mgr .configure ("project_project " ,
411
301
listadd = False ,
412
302
addbtn = True ,
413
- super_entity = db . pr_pentity ,
414
- linkto = "/%s/org/organisation /%s" % ( request . application ,
415
- "%s" ),
303
+ # Link straight to Tasks view & filter to just those which are open
304
+ linkto = "/%s/project/project /%s/task?open=1 " % \
305
+ ( request . application , "%s" ),
416
306
list_fields = ["id" ,])
417
307
418
- return s3_rest_controller ("org" , "organisation" )
308
+ return s3_rest_controller ("project" , "project" )
309
+
419
310
# -----------------------------------------------------------------------------
420
311
def site ():
421
312
"""
0 commit comments