Skip to content

Commit b6fe4e1

Browse files
committed
deployment_settings & Frontpage
1 parent 6e2877f commit b6fe4e1

File tree

5 files changed

+42
-155
lines changed

5 files changed

+42
-155
lines changed

VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2afe5f1 (2012-03-16 13:27:39)
1+
6e2877f (2012-03-16 13:41:59)

controllers/default.py

+30-139
Original file line numberDiff line numberDiff line change
@@ -135,139 +135,33 @@ def index():
135135
else:
136136
item = ""
137137

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-
144138
# 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-
205139
datatable_ajax_source = ""
206140
# Check logged in AND permissions
207141
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" % \
211145
request.application
212146
response.s3.actions = None
213147
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",
254161
_class = "menu_box fleft"
255162
)
256163
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 = ""
271165

272166
# Login/Registration forms
273167
self_registration = deployment_settings.get_security_self_registration()
@@ -374,12 +268,7 @@ def index():
374268

375269
return dict(title = title,
376270
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,
383272
r = None, # Required for dataTable to work
384273
datatable_ajax_source = datatable_ajax_source,
385274
#admin_name=admin_name,
@@ -394,28 +283,30 @@ def index():
394283
)
395284

396285
# -----------------------------------------------------------------------------
397-
def organisation():
286+
def project():
398287
"""
399-
Function to handle pagination for the org list on the homepage
288+
Function to handle pagination for the project list on the homepage
400289
"""
401290

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)
405295

406296
response.s3.dataTable_sPaginationType = "two_button"
407297
response.s3.dataTable_sDom = "rtip" #"frtip" - filter broken
408298
response.s3.dataTable_iDisplayLength = 25
409299

410-
s3mgr.configure("org_organisation",
300+
s3mgr.configure("project_project",
411301
listadd = False,
412302
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"),
416306
list_fields = ["id",])
417307

418-
return s3_rest_controller("org", "organisation")
308+
return s3_rest_controller("project", "project")
309+
419310
# -----------------------------------------------------------------------------
420311
def site():
421312
"""

deployment-templates/models/000_config.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@
385385
# Uncomment to allow Staff & Volunteers to be registered without an email address
386386
#deployment_settings.hrm.email_required = False
387387
# Uncomment to hide the Staff resource
388-
#deployment_settings.hrm.show_staff = False
388+
deployment_settings.hrm.show_staff = False
389389
# Uncomment to hide the Volunteer resource
390390
#deployment_settings.hrm.show_vols = False
391391
# Uncomment to allow hierarchical categories of Skills, which each need their own set of competency levels.
@@ -461,7 +461,7 @@
461461
)),
462462
# All modules below here should be possible to disable safely
463463
("hrm", Storage(
464-
name_nice = T("Staff & Volunteers"),
464+
name_nice = T("Volunteers"),
465465
description = T("Human Resource Management"),
466466
restricted = True,
467467
module_type = 2,
@@ -616,12 +616,12 @@
616616
restricted = False,
617617
module_type = 10,
618618
)),
619-
#("cms", Storage(
620-
# name_nice = T("Content Management"),
621-
# description = T("Content Management System"),
622-
# restricted = True,
623-
# module_type = 10,
624-
# )),
619+
("cms", Storage(
620+
name_nice = T("Content Management"),
621+
description = T("Content Management System"),
622+
restricted = True,
623+
module_type = 10,
624+
)),
625625
#("fire", Storage(
626626
# name_nice = T("Fire Stations"),
627627
# description = T("Fire Station Management"),

languages/en-gb.py

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
'A task is a piece of work that an individual or team can do in 1-2 days': 'A task is a piece of work that an individual or team can do in 1-2 days',
4141
'ABOUT THIS MODULE': 'ABOUT THIS MODULE',
4242
'ACCESS DATA': 'ACCESS DATA',
43+
'ACTION REQUIRED': 'ACTION REQUIRED',
4344
'ANY': 'ANY',
4445
'API Key': 'API Key',
4546
'API is documented here': 'API is documented here',

views/default/index.html

+2-7
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@ <h2>{{=title}}</h2>
55
{{except:}}{{pass}}
66
{{=XML(item)}}
77
<div id='menu_box_1'>
8-
{{try:}}
9-
{{=sit_dec_res_box}}
10-
{{except:}}{{pass}}
11-
{{=facility_box}}
128
{{if AUTHENTICATED not in session.s3.roles:}}
139
<div id='login_box' class='menu_box'>
1410
{{if not self_registration or registered:}}
@@ -31,8 +27,7 @@ <h2>{{=title}}</h2>
3127
{{pass}}
3228
</div>
3329
{{pass}}
34-
{{=manage_facility_box}}
35-
{{=org_box}}
30+
{{=project_box}}
3631
</div>
3732
<div id='menu_box_2'>
3833
<!-- More boxes can go here -->
@@ -57,6 +52,6 @@ <h2>{{=title}}</h2>
5752
<span style="color:#676767;font-size:11px;margin:10px;padding:4px;">{{=T("Loading")}}...</span>
5853
</div>
5954
{{pass}}
60-
{{if org_box:}}
55+
{{if project_box:}}
6156
{{include "dataTables.html"}}
6257
{{pass}}

0 commit comments

Comments
 (0)