desc
stringlengths
3
26.7k
decl
stringlengths
11
7.89k
bodies
stringlengths
8
553k
'PR - use DVR menu'
@classmethod def pr(cls):
return cls.dvr()
'PROJECT - use ORG menu'
@classmethod def project(cls):
return cls.org()
'ORG / Organization Registry'
@staticmethod def org():
ADMIN = current.auth.get_system_roles().ADMIN return M(c=('org', 'project'))(M('Organizations', f='organisation')(M('Create', m='create')), M('Facilities', f='facility')(M('Create', m='create')), M('Administration', c=('org', 'project'), link=False, restrict=(ADMIN, 'ORG_ADMIN'))(M('Organization Types', f='o...
'HRM / Human Resources Management'
@staticmethod def hrm():
settings = current.deployment_settings ADMIN = current.auth.get_system_roles().ADMIN return M(c='hrm')(M(settings.get_hrm_staff_label(), f='staff')(M('Create', m='create'), M('Import', f='person', m='import', p='create', vars={'group': 'staff'})), M('Job Title Catalog', f='job_title', restrict=[ADMIN]...
'SUPPLY / Supply Item Distribution'
@staticmethod def supply():
ADMIN = current.auth.get_system_roles().ADMIN return M(c='supply')(M('Distribution Items', f='distribution_item')(M('Create', m='create')), M('Administration', link=False, restrict=(ADMIN, 'ORG_ADMIN'))(M('Items', f='item'), M('Catalogs', f='catalog'), M('Item Categories', f='item_category')))
'Custom Layout Method'
@staticmethod def layout(item):
if (not item.authorized): item.enabled = False item.visible = False elif ((item.enabled is None) or item.enabled): item.enabled = True item.visible = True if (item.enabled and item.visible): items = item.render_components() if (item.parent is not None): ...
'Render special active items'
@staticmethod def checkbox_item(item):
name = item.label link = item.url() _id = name['id'] if ('name' in name): _name = name['name'] else: _name = '' if ('value' in name): _value = name['value'] else: _value = False if ('request_type' in name): _request_type = name['request_type'] ...
'Language menu layout options for each entry: - lang_code: the language code - lang_name: the language name option for the menu - current_language: code of the current language'
@staticmethod def layout(item):
if item.enabled: if item.components: current_language = current.T.accepted_language items = item.render_components() select = SELECT(items, value=current_language, _name='_language', _title='Language Selection', _onchange="S3.reloadWithQueryStringVars({'_language':$(th...
'Check whether the language menu is enabled'
def check_enabled(self):
if current.deployment_settings.get_L10n_display_toolbar(): return True else: return False
'Volunteer Management'
def vol(self):
s3 = current.session.s3 ADMIN = s3.system_roles.ADMIN is_org_admin = (lambda i: ((s3.hrm.orgs and True) or (ADMIN in s3.roles))) settings = current.deployment_settings teams = settings.get_hrm_teams() use_teams = (lambda i: teams) return M(c='vol')(M('Volunteers', f='volunteer')(M('Create ...
'Provide a dropdown of links to shelters'
def shelter_list(self):
T = current.T s3db = current.s3db resource = s3db.resource('cr_shelter', filter=FS('status').belongs([2, None])) data = resource.select(['id', 'name']) shelter_list = UL(_id='shelter_list', _class='f-dropdown', data={'dropdown-content': ''}) rows = data['rows'] if rows: for row in ro...
'Provide a dropdown of links to events'
def event_list(self):
T = current.T s3db = current.s3db resource = s3db.resource('event_event') data = resource.select(['id', 'name']) event_list = UL(_id='event_list', _class='f-dropdown', data={'dropdown-content': ''}) rows = data['rows'] if rows: for row in rows: event_list.append(LI(A(row[...
'Custom Modules Menu'
@classmethod def menu_modules(cls):
return [homepage(name='EVASS'), homepage('gis'), homepage('org'), homepage('msg')]
'Staff'
def hrm(self):
s3 = current.session.s3 ADMIN = s3.system_roles.ADMIN is_org_admin = (lambda i: ((s3.hrm.orgs and True) or (ADMIN in s3.roles))) settings = current.deployment_settings teams = settings.get_hrm_teams() use_teams = (lambda i: teams) vol_enabled = (lambda i: settings.has_module('vol')) retu...
'Volunteer Management'
@staticmethod def vol():
s3 = current.session.s3 ADMIN = s3.system_roles.ADMIN is_org_admin = (lambda i: ((s3.hrm.orgs and True) or (ADMIN in s3.roles))) settings = current.deployment_settings show_programmes = (lambda i: (settings.get_hrm_vol_experience() == 'programme')) show_tasks = (lambda i: (settings.has_module('p...
'EVR / Evacuees Registry'
def evr(self):
return M(c='evr')(M('Persons', f='person')(M('New', m='create'), M('Reports', m='report'), M('Import', m='import')), M('Groups', f='group')(M('New', m='create')))
'Compose Menu'
@classmethod def menu(cls):
main_menu = MM()(cls.menu_climate()) return main_menu
'Climate module menu'
@classmethod def menu_climate(cls, **attr):
name_nice = current.deployment_settings.modules['climate'].name_nice ADMIN = current.session.s3.system_roles.ADMIN menu_climate = MM(name_nice, c='climate', **attr)(MM('Station Parameters', f='station_parameter'), MM('Purchase Data', f='purchase'), MM('DataSet Prices', f='prices', restrict=[ADMIN])...
'CLIMATE Controller'
def climate(self):
return M(c='climate')(M('Home', f='index'), M('Station Parameters', f='station_parameter'), M('Saved Queries', f='save_query'), M('Purchase Data', f='purchase'))
'Lookup all rows referenced by values. (in foreign key representations) @param key: the key Field @param values: the values @param fields: the fields to retrieve'
def lookup_rows(self, key, values, fields=None):
table = self.table organisation_id = self.organisation_id if (len(values) == 1): query = (key == values[0]) else: query = key.belongs(values) rows = current.db(query).select(key, table.name, table.organisation_id) new_rows = [] append = new_rows.append for row in rows: ...
'Parse a value from a piece of text'
@staticmethod def _parse_value(text, fieldname):
parts = text.split((':%s:' % fieldname), 1) parts = parts[1].split(':', 1) result = parts[0] return result
'Parse Responses - reply to mails from the Monitor service - parse mails directed to the Deploy Module @ToDo: Use template for format of field/value encoding'
@staticmethod def parse_email(message):
db = current.db s3db = current.s3db reply = None message_id = message.message_id table = s3db.msg_email record = db((table.message_id == message_id)).select(table.raw, limitby=(0, 1)).first() if (not record): return reply message_body = record.raw if (not message_body): ...
'Compose Menu'
@classmethod def menu(cls):
main_menu = MM()(cls.menu_modules()) current.menu.personal = cls.menu_personal() current.menu.dashboard = cls.menu_dashboard() current.menu.org = cls.menu_org() return main_menu
'Custom Modules Menu'
@classmethod def menu_modules(cls):
T = current.T auth = current.auth settings = current.deployment_settings has_role = auth.s3_has_role root_org = auth.root_org_name() system_roles = current.session.s3.system_roles ADMIN = system_roles.ADMIN ORG_ADMIN = system_roles.ORG_ADMIN s3db = current.s3db s3db.inv_recv_crud...
'Dashboard Menu (at bottom of page)'
@classmethod def menu_dashboard(cls):
DB = S3DashBoardMenuLayout auth = current.auth request = current.request controller = request.controller has_role = auth.s3_has_role root_org = auth.root_org_name() system_roles = current.session.s3.system_roles ORG_ADMIN = system_roles.ORG_ADMIN def hrm(item): return ((root_...
'Custom Organisation Menu'
@classmethod def menu_org(cls):
OM = S3OrgMenuLayout return OM()
'Custom Personal Menu'
@classmethod def menu_personal(cls):
auth = current.auth s3 = current.response.s3 settings = current.deployment_settings menu_lang = ML('Language', right=True) for language in s3.l10n_languages.items(): (code, name) = language menu_lang(ML(name, translate=False, lang_code=code, lang_name=name)) if (not auth.is_logge...
'ADMIN menu'
def admin(self):
menu = super(S3OptionsMenu, self).admin() menu(M('Map Settings', c='gis', f='config'), M('Content Management', c='cms', f='index')) return menu
'CMS / Content Management System'
@staticmethod def cms():
return M(c='cms')(M('Series', f='series')(M('Create', m='create'), M('View as Pages', f='blog')), M('Posts', f='post')(M('Create', m='create'), M('View as Pages', f='page'), M('Import', m='import')))
'RDRT Alerting and Deployments'
@staticmethod def deploy():
auth = current.auth user = auth.user organisation_id = ((user and user.organisation_id) or None) if organisation_id: db = current.db s3db = current.s3db otable = s3db.org_organisation rtable = s3db.org_region query = ((otable.id == organisation_id) & (otable.regio...
'Event Management'
@staticmethod def event():
return M()(M('Events', c='event', f='event')(M('Create', m='create')), M('Event Types', c='event', f='event_type')(M('Create', m='create')), M('Incident Reports', c='event', f='incident_report', m='summary')(M('Create', m='create')), M('Incident Types', c='event', f='incident_type')(M('Create', m='create')...
'GIS / GIS Controllers'
def gis(self):
if (current.request.function == 'index'): return None else: return super(S3OptionsMenu, self).gis()
'HRM Human Resource Management'
@staticmethod def hrm():
has_role = current.auth.s3_has_role ADMIN = current.session.s3.system_roles.ADMIN settings = current.deployment_settings SECTORS = ('Clusters' if settings.get_ui_label_cluster() else 'Sectors') is_org_admin = (lambda i: has_role(ADMIN)) is_super_editor = (lambda i: (has_role('staff_super') or ha...
'INV / Inventory'
@staticmethod def inv():
auth = current.auth has_role = auth.s3_has_role system_roles = current.session.s3.system_roles ADMIN = system_roles.ADMIN ORG_ADMIN = system_roles.ORG_ADMIN s3db = current.s3db s3db.inv_recv_crud_strings() inv_recv_list = current.response.s3.crud_strings.inv_recv.title_list settings ...
'Organisation Management'
def org(self):
if (current.request.function in ('capacity_assessment', 'capacity_assessment_data')): return self.survey() else: return self.hrm()
'PROJECT / Project Tracking & Management'
@staticmethod def project():
menu = M(c='project')(M('Programs', f='programme')(M('Create', m='create')), M('Projects', f='project', m='summary')(M('Create', m='create')), M('Communities', f='location')(M('Map', m='map'), M('Community Contacts', f='location_contact')), M('Reports', f='location', m='report')(M('3W', f='location', m='report')...
'Requests Management'
def req(self):
return self.inv()
'SURVEY / Survey'
@staticmethod def survey():
ADMIN = current.session.s3.system_roles.ADMIN series_id = False get_vars = Storage() try: series_id = int(current.request.args[0]) except: try: (dummy, series_id) = current.request.get_vars['viewing'].split('.') series_id = int(series_id) except: ...
'Volunteer Management'
@staticmethod def vol():
auth = current.auth has_role = auth.s3_has_role ADMIN = current.session.s3.system_roles.ADMIN root_org = auth.root_org_name() is_org_admin = (lambda i: has_role(ADMIN)) is_super_editor = (lambda i: (has_role('vol_super') or has_role('staff_super'))) settings = current.deployment_settings ...
'Custom Layout Method'
@staticmethod def layout(item):
if (not item.authorized): item.enabled = False item.visible = False elif ((item.enabled is None) or item.enabled): item.enabled = True item.visible = True if (item.enabled and item.visible): if (item.parent is None): items = item.render_components() ...
'Custom Layout Method'
@staticmethod def layout(item):
if (not item.authorized): enabled = False visible = False elif ((item.enabled is None) or item.enabled): enabled = True visible = True if (enabled and visible): if (item.parent is not None): if (item.enabled and item.authorized): if item.co...
'Language menu layout options for each entry: - lang_code: the language code - lang_name: the language name option for the menu - current_language: code of the current language'
@staticmethod def layout(item):
if item.enabled: if item.components: current_language = current.T.accepted_language items = item.render_components() select = SELECT(items, value=current_language, _name='_language', _title='Language Selection', _onchange="S3.reloadWithQueryStringVars({'_language':$(th...
'Check whether the language menu is enabled'
def check_enabled(self):
if current.deployment_settings.get_L10n_display_toolbar(): return True else: return False
'Entry point for REST API @param r: the S3Request @param attr: controller arguments'
def apply_method(self, r, **attr):
if (r.representation == 'html'): return self._html(r, **attr) raise HTTP(405, current.ERROR.BAD_METHOD)
'Handle HTML representation @param r: the S3Request @param attr: controller arguments'
def _html(self, r, **attr):
raise NotImplementedError
'Update output with a dataTable and a create_popup Update dt_init for the dataTable'
def _datatable(self, output, tablename, search=True, updateable=True, export=False, event_id=None, incident_id=None, ajax_vars=None, dt_init=None):
T = current.T s3db = current.s3db (c, f) = tablename.split('_', 1) if (ajax_vars is None): ajax_vars = {} resource = s3db.resource(tablename) if event_id: ltablename = ('event_%s' % f) if (tablename == ltablename): resource.add_filter((FS('event_id') == event_...
'Create the HTML for a Map section @param layer_name: the name of the Layer @param map_id: the id of the map @param filter: True for an S3MapFilter, otherwise optional filter string for the layer'
def _map(self, layer_name, map_id='default_map', filter=None):
s3 = current.response.s3 jqrappend = s3.jquery_ready.append if ((filter is True) and current.deployment_settings.get_gis_spatialdb()): _map = None button = A('DRAW A MAP AREA', _class='button', _id='map_filter_button') jqrappend(("$('#%s').appendTo($('#map-here'))" % map_id)...
'Create the HTML for the Alerts section'
@staticmethod def _alerts_html():
T = current.T db = current.db s3db = current.s3db tablename = 'cms_post' resource = s3db.resource(tablename) resource.add_filter((FS('~.series_id$name') == 'Public Alert')) list_fields = ['id', 'status_id', 'date', 'title', 'body', 'created_by', 'location_id$path', 'location_id$L3', 'loca...
'Create the HTML for the Events section'
@staticmethod def _events_html():
T = current.T db = current.db s3db = current.s3db tablename = 'event_event' resource = s3db.resource(tablename) resource.add_filter((FS('~.closed') == False)) list_fields = ['id', 'name', 'closed', 'start_date', 'end_date', 'exercise', 'comments', 'event_location.location_id$path', 'event_lo...
'Create the HTML for the System-wide \'Alert\' section'
@staticmethod def _system_wide_html():
ADMIN = current.auth.s3_has_role('ADMIN') table = current.s3db.cms_post record = current.db((table.name == 'SYSTEM_WIDE')).select(table.body, limitby=(0, 1)).first() if (record or ADMIN): if ADMIN: edit_btn = P(A(current.T('Edit System-wide Alert'), _href=URL(c='cms', f='post',...
'Create the HTML for the Updates section @param r: the S3Request @param attr: controller arguments'
def _updates_html(self, r, output, event_id, incident_id, updateable, **attr):
T = current.T db = current.db s3db = current.s3db s3 = current.response.s3 list_id = 'updates_datalist' ajax_vars = {'list_id': list_id} tablename = 'cms_post' resource = s3db.resource(tablename) if event_id: resource.add_filter((FS('event_post.event_id') == event_id)) ...
'Apply the View, with all things which have to be on every page @param output: the output dict @param view: view template'
def _view(self, output, view):
current.menu.options = None s3 = current.response.s3 s3.scripts.append(('/%s/static/themes/WACOP/js/bookmarks.js' % current.request.application)) s3.jquery_ready.append("S3.wacop_bookmarks()\nS3.redraw_fns.push('wacop_bookmarks')") output['system_wide'] = self._system_wide_html() S3CustomControl...
'Handle HTML representation @param r: the S3Request @param attr: controller arguments'
def _html(self, r, **attr):
T = current.T alerts = self._alerts_html() events = self._events_html() map_id = 'event-gis_location_the_geom-map-filter-map' (_map, button) = self._map('Events', map_id=map_id, filter=True) output = {'alerts': alerts, 'events': events, '_map': _map} date_filter = S3DateFilter(['start_date',...
'Handle HTML representation @param r: the S3Request @param attr: controller arguments'
def _html(self, r, **attr):
T = current.T alerts = self._alerts_html() events = self._events_html() map_id = 'incident-gis_location_the_geom-map-filter-map' (_map, button) = self._map('Incidents', map_id=map_id, filter=True) output = {'alerts': alerts, 'events': events, '_map': _map} date_filter = S3DateFilter(['date',...
'Handle HTML representation @param r: the S3Request @param attr: controller arguments'
def _html(self, r, **attr):
T = current.T alerts = self._alerts_html() events = self._events_html() map_id = 'group-gis_location_the_geom-map-filter-map' (_map, button) = self._map('Resources', map_id=map_id, filter=True) output = {'alerts': alerts, 'events': events, '_map': _map} filter_widgets = [S3TextFilter(['name'...
'Handle HTML representation @param r: the S3Request @param attr: controller arguments'
def _html(self, r, **attr):
event_id = r.id incident_id = None T = current.T auth = current.auth db = current.db s3db = current.s3db etable = s3db.event_event itable = s3db.event_incident ptable = s3db.cms_post gtable = s3db.gis_location ertable = s3db.event_team eptable = s3db.event_post ttable...
'Handle HTML representation @param r: the S3Request @param attr: controller arguments'
def _html(self, r, **attr):
incident_id = r.id T = current.T auth = current.auth db = current.db s3db = current.s3db ptable = s3db.cms_post gtable = s3db.gis_location itable = s3db.event_incident ertable = s3db.event_team eptable = s3db.event_post ttable = s3db.cms_tag ittable = s3db.event_tag d...
'Handle HTML representation @param r: the S3Request @param attr: controller arguments'
def _html(self, r, **attr):
_map = self._map('Incidents') output = {'map': _map} datatable = self._datatable dt_init = ["$('.dataTables_filter label,.dataTables_length,.dataTables_info').hide();"] tablename = 'project_task' customise = current.deployment_settings.customise_resource(tablename) if customise: c...
'Custom Modules Menu'
@classmethod def menu_modules(cls):
person_id = current.auth.s3_logged_in_person() if person_id: dashboard = MM('Dashboard', c='pr', f='person', args=[person_id, 'dashboard']) else: dashboard = None return [dashboard, MM('Map', c='gis', f='index'), MM('Incidents', c='event', f='incident', m='browse'), MM('Events', c='event...
'Custom Help Menu'
@classmethod def menu_help(cls, **attr):
menu_help = MM('About', f='about', **attr) return menu_help
'Auth Menu'
@classmethod def menu_auth(cls, **attr):
auth = current.auth logged_in = auth.is_logged_in() if (not logged_in): request = current.request login_next = URL(args=request.args, vars=request.vars) if ((request.controller == 'default') and (request.function == 'user') and ('_next' in request.get_vars)): login_next =...
'Language Selector'
@classmethod def menu_lang(cls, **attr):
s3 = current.response.s3 menu_lang = ML('Language', **attr) for language in s3.l10n_languages.items(): (code, name) = language menu_lang(ML(name, translate=False, lang_code=code, lang_name=name)) return menu_lang
'ADMIN menu'
def admin(self):
ADMIN = current.session.s3.system_roles.ADMIN settings_messaging = self.settings_messaging() return M(restrict=[ADMIN])(M('Settings', c='admin', f='setting')(settings_messaging), M('User Management', c='admin', f='user')(M('Create User', m='create'), M('List All Users'), M('Import Users', m='...
'Custom Layout Method'
@staticmethod def layout(item):
if (not item.authorized): item.enabled = False item.visible = False elif ((item.enabled is None) or item.enabled): item.enabled = True item.visible = True if (item.enabled and item.visible): items = item.render_components() if (item.parent is not None): ...
'Language menu layout options for each entry: - lang_code: the language code - lang_name: the language name'
@staticmethod def layout(item):
if item.enabled: if item.components: T = current.T items = item.render_components() select = SELECT(items, _name='_language', _title=T('Language Selection'), _onchange="S3.reloadWithQueryStringVars({'_language':$(this).val()})", value=T.accepted_language) c...
'Check whether the language menu is enabled'
def check_enabled(self):
if current.deployment_settings.get_L10n_display_toolbar(): return True else: return False
'Outer container for the subform @param data: the data dict (as returned from extract()) @param item_rows: the item rows @param action_rows: the (hidden) action rows @param empty: no data in this component @param readonly: render read-only'
def subform(self, data, item_rows, action_rows, empty=False, readonly=False):
if empty: subform = current.T('No entries currently available') else: subform = DIV(_class='embeddedComponent') headers = self.headers(data, readonly=readonly) if headers: subform.append(headers) subform.append(DIV(item_rows, _class='inline-items')) ...
'Render this component read-only (table-style) @param resource: the S3Resource @param data: the data dict (as returned from extract())'
def readonly(self, resource, data):
audit = current.audit (prefix, name) = (resource.prefix, resource.name) xml_decode = current.xml.xml_decode items = data['data'] fields = data['fields'] item_rows = [] columns = self.columns for item in items: if ('_id' in item): record_id = item['_id'] else: ...
'Render the header row with field labels @param data: the input field data as Python object @param readonly: whether the form is read-only @param attributes: HTML attributes for the header row'
def headers(self, data, readonly=False):
fields = data['fields'] render_header = False header_row = DIV(_class='label-row row') happend = header_row.append numfields = len(fields) columns = self.columns for (i, f) in enumerate(fields): label = f['label'] if label: render_header = True if (colu...
'Render subform row actions into the row @param subform: the subform row @param formname: the form name @param index: the row index @param item: the row data @param readonly: this is a read-row @param editable: this row is editable @param deletable: this row is deletable'
@staticmethod def actions(subform, formname, index, item=None, readonly=True, editable=True, deletable=True):
T = current.T action_id = ('%s-%s' % (formname, index)) def action(title, name, throbber=False): btn = DIV(_id=('%s-%s' % (name, action_id)), _class=('inline-%s' % name)) if throbber: return DIV(btn, DIV(_class='inline-throbber hide', _id=('throbber-%s' % action_id))) ...
'Formstyle for subform rows'
def rowstyle(self, form, fields, *args, **kwargs):
def render_col(col_id, label, widget, comment, width=None, end=False): if comment: col = DIV(DIV(widget, comment), _id=col_id) else: col = DIV(widget, _id=col_id) if width: column_class = ('small-%s columns' % width) if end: ...
'Inject custom JS to render new read-rows'
@staticmethod def inject_script():
appname = current.request.application scripts = current.response.s3.scripts script = ('/%s/static/themes/CRMT/js/inlinecomponent.layout.js' % appname) if (script not in scripts): scripts.append(script) return
'Constructor'
def __init__(self, profile='org_organisation'):
super(OrganisationProfileLayout, self).__init__(profile=profile)
'Render the card header @param list_id: the HTML ID of the list @param item_id: the HTML ID of the item @param resource: the S3Resource to render @param rfields: the S3ResourceFields to render @param record: the record as dict'
def render_header(self, list_id, item_id, resource, rfields, record):
toolbox = self.render_toolbox(list_id, resource, record) tablename = resource.tablename if (tablename == 'org_facility'): icon = ICON('globe') title = record['org_facility.location_id'] else: icon = None title = '' return DIV(icon, SPAN((' %s' % title), _class='car...
'Render the card body @param list_id: the HTML ID of the list @param item_id: the HTML ID of the item @param resource: the S3Resource to render @param rfields: the S3ResourceFields to render @param record: the record as dict'
def render_body(self, list_id, item_id, resource, rfields, record):
return None
'Render the toolbox @param list_id: the HTML ID of the list @param resource: the S3Resource to render @param record: the record as dict'
def render_toolbox(self, list_id, resource, record):
table = resource.table tablename = resource.tablename record_id = record[str(resource._id)] open_url = update_url = None if (tablename == 'org_facility'): update_url = URL(f='facility', args=[record_id, 'update.popup'], vars={'refresh': list_id, 'record': record_id, 'profile': self.profile})...
'Custom Modules Menu'
@classmethod def menu_modules(cls):
return [MM('Find', link=False)(MM('People', c='pr', f='person', m='summary', always_display=True), MM('Organizations', c='org', f='organisation', m='summary'), MM('Activities', c='project', f='activity', m='summary', always_display=True), MM('Points', c='gis', f='poi', m='summary', vars={'~.location_id$gis_feature_...
'Auth Menu'
@classmethod def menu_auth(cls, **attr):
auth = current.auth if (not auth.is_logged_in()): request = current.request login_next = URL(args=request.args, vars=request.get_vars) if ((request.controller == 'default') and (request.function == 'user') and ('_next' in request.get_vars)): login_next = request.get_vars['_ne...
'Registration Menu'
@classmethod def menu_register(cls, **attr):
if current.auth.is_logged_in(): return None request = current.request login_next = URL(args=request.args, vars=request.vars) if ((request.controller == 'default') and (request.function == 'user') and ('_next' in request.get_vars)): login_next = request.get_vars['_next'] menu_auth = M...
'Language menu'
@classmethod def menu_lang(cls, **attr):
if current.auth.is_logged_in(): return None request = current.request s3 = current.response.s3 languages = s3.l10n_languages current_language = s3.language menu_lang = MM('Language', **attr) for language in languages: if (language == current_language): _class = 'a...
'Custom Modules Menu'
@classmethod def menu_modules(cls):
sysname = current.deployment_settings.get_system_name_short() return [homepage(name=sysname), homepage('gis'), homepage('event', f='incident_report'), homepage('org'), homepage('hrm'), homepage('inv'), homepage('cr'), homepage('req'), homepage('vol'), homepage('project')]
'Help Menu'
@classmethod def menu_help(cls, **attr):
menu_help = MM('Help', c='default', f='help', **attr)(MM('Contact us', f='contact'), MM('About Us', f='about'), MM('User Guide', f='index/userguide')) return menu_help
'EVENT / Event Module'
@staticmethod def event():
return M()(M('Incident Reports', c='event', f='incident_report')(M('Create', m='create')))
'Entry point for REST interface. @param r: the S3Request instance @param attr: controller attributes @note: always returns PDF, disregarding the requested format'
def apply_method(self, r, **attr):
output = {} if (r.http == 'GET'): if r.id: tablename = r.tablename if (tablename == 'req_req'): output = self.request_form(r, **attr) elif (tablename == 'inv_send'): output = self.waybill(r, **attr) elif (tablename == 'inv_r...
'Request Form @param r: the S3Request instance @param attr: controller attributes'
def request_form(self, r, **attr):
T = current.T s3db = current.s3db resource = s3db.resource(r.tablename, id=r.id, components=['req_item']) header_fields = ['req_ref', 'date', 'date_required', (T('Deliver to'), 'site_id'), (T('Reason for Request'), 'purpose'), 'requester_id', 'site_id$site_id:inv_warehouse.contact', 'comments']...
'Header for Request Forms @param data: the S3ResourceData for the req_req'
@classmethod def request_form_header(cls, data):
row = data.rows[0] labels = dict(((rfield.colname, rfield.label) for rfield in data.rfields)) from gluon import DIV, H2, H4, TABLE, TD, TH, TR, P T = current.T from layouts import OM (name, logo) = OM().render() title = H2(T('Logistics Requisition')) row_ = (lambda left, right, row=ro...
'Footer for Request Forms @param r: the S3Request'
@staticmethod def request_form_footer(r):
T = current.T from gluon import TABLE, TD, TH, TR return TABLE(TR(TH(' '), TH(T('Name')), TH(T('Signature')), TH(T('Date'))), TR(TH(T('Requester'))), TR(TH(T('Budget Administrator'))), TR(TH(T('Finance'))))
'Waybill @param r: the S3Request instance @param attr: controller attributes'
def waybill(self, r, **attr):
T = current.T s3db = current.s3db s3db.add_components('inv_send', inv_warehouse=({'name': 'origin', 'joinby': 'site_id', 'pkey': 'site_id', 'filterby': False, 'multiple': False}, {'name': 'destination', 'joinby': 'site_id', 'pkey': 'to_site_id', 'filterby': False, 'multiple': False})) resource = s3db.re...
'Header for Waybills @param data: the S3ResourceData for the inv_send'
@classmethod def waybill_header(cls, data):
row = data.rows[0] labels = dict(((rfield.colname, rfield.label) for rfield in data.rfields)) from gluon import DIV, H2, H4, TABLE, TD, TH, TR, P T = current.T from layouts import OM (name, logo) = OM().render() title = H2(T('Waybill')) row_ = (lambda left, right, row=row, labels=labels:...
'Footer for Waybills @param r: the S3Request'
@staticmethod def waybill_footer(r):
T = current.T from gluon import TABLE, TD, TH, TR return TABLE(TR(TH(T('Shipment')), TH(T('Date')), TH(T('Function')), TH(T('Name')), TH(T('Signature')), TH(T('Status'))), TR(TD(T('Sent by'))), TR(TD(T('Transported by'))), TR(TH(T('Received by')), TH(T('Date')), TH(T('Function')), TH(T('Name')), TH...
'GRN (Goods Received Note) @param r: the S3Request instance @param attr: controller attributes'
def goods_received_note(self, r, **attr):
T = current.T s3db = current.s3db resource = s3db.resource(r.tablename, id=r.id, components=['track_item']) header_fields = ['eta', 'date', (T('Origin'), 'from_site_id'), (T('Destination'), 'site_id'), 'sender_id', 'recipient_id', 'send_ref', 'recv_ref', 'comments'] header_data = resource.select(hea...
'Header for Goods Received Notes @param data: the S3ResourceData for the inv_recv'
@classmethod def goods_received_note_header(cls, data):
row = data.rows[0] labels = dict(((rfield.colname, rfield.label) for rfield in data.rfields)) from gluon import DIV, H2, H4, TABLE, TD, TH, TR, P T = current.T from layouts import OM (name, logo) = OM().render() title = H2(T('Goods Received Note')) row_ = (lambda left, right, row=r...
'Footer for Goods Received Notes @param r: the S3Request'
@staticmethod def goods_received_note_footer(r):
T = current.T from gluon import TABLE, TD, TH, TR return TABLE(TR(TH(T('Delivered by')), TH(T('Date')), TH(T('Function')), TH(T('Name')), TH(T('Signature')), TH(T('Status'))), TR(TD(T(' '))), TR(TH(T('Received by')), TH(T('Date')), TH(T('Function')), TH(T('Name')), TH(T('Signature')), TH(T('Statu...
'Helper function to generate a 2-column table row for the PDF header @param left: the column name for the left column @param right: the column name for the right column, or None for an empty column @param row: the S3ResourceData row @param labels: dict of labels {colname: label}'
@staticmethod def _header_row(left, right, row=None, labels=None):
from gluon import TD, TH, TR if right: header_row = TR(TH(labels[left]), TD(row[left]), TH(labels[right]), TD(row[right])) else: header_row = TR(TH(labels[left]), TD(row[left], _colspan=3)) return header_row
'Extract, group and aggregate the data for the form body @param component: the component (S3Resource) @param list_fields: the columns for the form body (list of field selectors) @param aggregate: aggregation methods and fields, a list of tuples (method, column name)'
@staticmethod def _json_data(component, list_fields, aggregate=None):
data = component.select(list_fields, limit=None, raw_data=True, represent=True, show_links=False) columns = [] append_column = columns.append labels = {} for rfield in data.rfields: colname = rfield.colname append_column(colname) labels[colname] = rfield.label from s3 imp...
'Compose Menu'
@classmethod def menu(cls):
main_menu = MM()(cls.menu_modules()) current.menu.personal = cls.menu_personal() current.menu.lang = cls.menu_lang() current.menu.about = cls.menu_about() current.menu.org = cls.menu_org() return main_menu
'Custom Modules Menu'
@classmethod def menu_modules(cls):
auth = current.auth has_role = auth.s3_has_role s3 = current.session.s3 len_roles = len(s3.roles) if ((len_roles <= 2) or ((len_roles == 3) and has_role('RIT_MEMBER') and (not has_role('ADMIN')))): return [MM('Profile', c='hrm', f='person', args=[str(auth.s3_logged_in_person())], vars={'prof...
'Custom Organisation Menu'
@classmethod def menu_org(cls):
OM = S3OrgMenuLayout return OM()
'Custom Personal Menu'
@classmethod def menu_personal(cls):
auth = current.auth s3 = current.response.s3 settings = current.deployment_settings if (not auth.is_logged_in()): request = current.request login_next = URL(args=request.args, vars=request.vars) if ((request.controller == 'default') and (request.function == 'user') and ('_next' i...
'ADMIN menu'
def admin(self):
menu = super(S3OptionsMenu, self).admin() menu(M('Map Settings', c='gis', f='config'), M('Content Management', c='cms', f='index')) return menu