desc
stringlengths
3
26.7k
decl
stringlengths
11
7.89k
bodies
stringlengths
8
553k
'Main entry point, configuration'
def __call__(self):
T = current.T auth = current.auth if (not auth.s3_logged_in()): auth.permission.fail() form = self.create_form() if form: output = {'title': T('Subscription Settings'), 'form': form} else: output = {'title': T('No Subscriptions')} self._view(THEME, 'subscription...
'Build form for subscription settings'
def create_form(self):
T = current.T db = current.db response = current.response user = current.auth.user.pe_id stable = current.s3db.pr_subscription formstyle = current.deployment_settings.get_ui_formstyle() query = ((stable.pe_id == user) & (stable.deleted != True)) row = db(query).select(stable.id, stable.f...
'Compose Menu'
@classmethod def menu(cls):
main_menu = MM()(cls.menu_modules(), cls.menu_lang(right=True), cls.menu_auth()) return main_menu
'Custom Modules Menu'
@classmethod def menu_modules(cls):
T = current.T project_filter = {'sector.name': 'None,Project'} deployment_filter = {'sector.name': 'None,Deployment'} return [MM('Home', c='default', f='index'), MM('Contributors', c='pr', f='person'), MM('Deployments', c='project', f='project', vars=deployment_filter, tags='deployment'), MM('Projects',...
'Auth Menu'
@classmethod def menu_auth(cls, **attr):
auth = current.auth user_id = auth.s3_logged_in_person() menu_auth = None if (not user_id): menu_auth = MM('Login', c='default', f='user', m='login', right=True) else: user = auth.user options = [MM('Edit Profile', c='pr', f='person', args=[user_id]), MM('Details', c='defa...
'Project Options Menu'
def project(self):
project_filter = {'sector.name': 'None,Project'} return M(c='project')(M('Projects', c='project', f='project', vars=project_filter)(M('Create', m='create'), M('Map', m='map', vars=project_filter), M('Import', m='import')))
'Task Options Menu'
def task(self):
return M(c='project')(M('Tasks', f='task')(M('Create', m='create'), M('Import', m='import')))
'Deployments Options Menu'
def deployment(self):
deployment_filter = {'sector.name': 'None,Deployment'} return M(c='project')(M('Deployments', c='project', f='project', vars=deployment_filter)(M('Create', m='create', vars=deployment_filter), M('Map', m='map', vars=deployment_filter), M('Import', m='import')))
'Filter unstructured tweets'
@staticmethod def parse_twitter(message):
db = current.db s3db = current.s3db cache = s3db.cache priority = 0 category = 'Unknown' service = 'twitter' table = s3db.msg_sender ctable = s3db.pr_contact query = (((table.deleted == False) & (ctable.pe_id == table.pe_id)) & (ctable.contact_method == 'TWITTER')) senders = db(q...
'Parse Keywords - helper function for search_resource, etc'
@staticmethod def _parse_keywords(message_body):
primary_keywords = ['get', 'give', 'show'] contact_keywords = ['email', 'mobile', 'facility', 'clinical', 'security', 'phone', 'status', 'hospital', 'person', 'organisation'] pkeywords = (primary_keywords + contact_keywords) keywords = message_body.split(' ') pquery = [] name = '' for wor...
'1st Pass Parser for searching resources - currently supports people, hospitals and organisations.'
def search_resource(self, message):
message_body = message.body if (not message_body): return None (pquery, name) = self._parse_keywords(message_body) if ('person' in pquery): reply = self.search_person(message, pquery, name) elif ('hospital' in pquery): reply = self.search_hospital(message, pquery, name) e...
'Search for People - can be called direct - can be called from search_by_keyword'
def search_person(self, message, pquery=None, name=None):
message_body = message.body if (not message_body): return None if ((not pquery) or (not name)): (pquery, name) = self._parse_keywords(message_body) T = current.T db = current.db s3db = current.s3db reply = None result = [] s3_accessible_query = current.auth.s3_accessi...
'Search for Hospitals - can be called direct - can be called from search_by_keyword'
def search_hospital(self, message, pquery=None, name=None):
message_body = message.body if (not message_body): return None if ((not pquery) or (not name)): (pquery, name) = self._parse_keywords(message_body) T = current.T db = current.db s3db = current.s3db reply = None result = [] table = s3db.hms_hospital stable = s3db.h...
'Search for Organisations - can be called direct - can be called from search_by_keyword'
def search_organisation(self, message, pquery=None, name=None):
message_body = message.body if (not message_body): return None if ((not pquery) or (not name)): (pquery, name) = self._parse_keywords(message_body) T = current.T db = current.db s3db = current.s3db reply = None result = [] s3_accessible_query = current.auth.s3_accessi...
'Parse Messages directed to the IRS Module - logging new incidents - responses to deployment requests'
def parse_ireport(self, message):
message_body = message.body if (not message_body): return None (lat, lon, code, text) = current.msg.parse_opengeosms(message_body) if (code == 'SI'): reply = self._create_ireport(lat, lon, text) else: words = message_body.split(' ') text = '' reponse = '' ...
'Create New Incident Report'
@staticmethod def _create_ireport(lat, lon, text):
s3db = current.s3db rtable = s3db.irs_ireport gtable = s3db.gis_location info = text.split(' ') name = info[(len(info) - 1)] category = '' for a in range(0, (len(info) - 1)): category = ((category + info[a]) + ' ') location_id = gtable.insert(name=('Incident:%s' % name), la...
'Parse Replies To Deployment Request'
@staticmethod def _respond_drequest(message, report_id, response, text):
hr_id = S3Parsing().lookup_human_resource(message.from_address) if hr_id: rtable = current.s3db.irs_ireport_human_resource query = ((rtable.ireport_id == report_id) & (rtable.human_resource_id == hr_id)) current.db(query).update(reply=text, response=response) reply = ('Response ...
'Regional Organisations - Filtered subset of Organisations'
@staticmethod def _regional():
T = current.T s3request = s3_request('org', 'organisation', extension='aadata') f = FS('organisation_type.name').anyof(['Regional Organisation', 'Regional Office', 'Regional Center']) s3request.resource.add_filter(f) list_fields = ['id', 'name', 'acronym', (T('Type'), 'organisation_organisa...
'Committees/Mechanisms/Forums & Networks - Filtered subset of Organisations'
@staticmethod def _groups():
T = current.T s3db = current.s3db table = s3db.org_organisation table.address = Field.Method('address', s3db.org_organisation_address) s3request = s3_request('org', 'organisation', extension='aadata') f = FS('organisation_type.name').anyof(['Committees/Mechanism/Forum', 'Network']) s3request...
'Generate a datatable in the organisations custom page'
@staticmethod def _table(name, resource, field_list, limit=10, orderby='name'):
data = resource.select(field_list, limit=None, orderby=orderby, count=True, represent=True) rfields = data['rfields'] records = data['rows'] numrows = len(records) rows = [] cols = [] for rfield in rfields: colname = rfield.colname cols.append({'name': colname, 'label': rfiel...
'Compose Menu'
@classmethod def menu(cls):
main_menu = MM()(cls.menu_modules()) current.menu.top = cls.menu_top() return main_menu
'Custom Modules Menu'
@classmethod def menu_modules(cls):
return [MM('Home', c='default', f='index'), MM('Project List', c='project', f='project'), MM('Project Analysis', c='default', f='index', args='analysis'), MM('Regional Organizations', c='default', f='index', args='organisations'), MM('Policies & Strategies', c='project', f='framework'), MM('My Pag...
'Custom Top Menu'
@classmethod def menu_top(cls, **attr):
auth = current.auth if (not auth.is_logged_in()): self_registration = current.deployment_settings.get_security_registration_visible() request = current.request login_next = URL(args=request.args, vars=request.vars) if ((request.controller == 'default') and (request.function == 'u...
'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): ...
'Custom Layout Method'
@staticmethod def layout(item):
if (item.parent is None): items = item.render_components() if items: return UL(items) else: return '' elif (item.enabled and item.authorized): return LI(A(DIV(item.label, _class='hoverable'), _href=item.url()), _class='fleft') else: return None...
'Main entry point, configuration'
def __call__(self):
logged_in = current.auth.s3_logged_in() if logged_in: fn = 'alert' else: fn = 'public' T = current.T s3db = current.s3db request = current.request output = {} ftable = s3db.gis_layer_feature query = ((ftable.controller == 'cap') & (ftable.function == fn)) layer = ...
'Main entry point, configuration'
def __call__(self):
T = current.T auth = current.auth if (not auth.s3_logged_in()): auth.permission.fail() has_role = auth.s3_has_role resources = [dict(resource='cap_alert', url='cap/alert', label=T('Updates'))] filters = [S3OptionsFilter('event_type_id', label=T('Event Type'), options=self._options('ev...
'Lookup the full set of options for a Filter Widget - for Subscriptions we don\'t want to see just the options available in current data'
@staticmethod def _options(fieldname):
if (fieldname == 'event_type_id'): T = current.T etable = current.s3db.event_event_type rows = current.db((etable.deleted == False)).select(etable.id, etable.name) options = {} for row in rows: options[row.id] = T(row.name) elif (fieldname == 'priority'): ...
'Custom form to manage subscriptions @param resources: available resources config @param filters: subscription filter widgets @param recipient_filters: recipient filter widgets @param group_filters: pr_group filter widgets'
def _manage_subscriptions(self, resources, filters, recipient_filters, group_filters):
from gluon.http import redirect from gluon.validators import IS_IN_SET from s3.s3widgets import S3GroupedOptionsWidget, S3MultiSelectWidget from s3layouts import S3PopupLink from s3theme import formstyle_foundation_2col as formstyle T = current.T db = current.db s3db = current.s3db a...
'Get current subscription settings'
def _get_subscription(self, subscription_id=None):
db = current.db s3db = current.s3db pe_id = current.auth.user.pe_id stable = s3db.pr_subscription if (subscription_id is not None): ftable = s3db.pr_filter rows = db(stable).select() query = (((((stable.deleted != True) & (stable.id == subscription_id)) & (stable.pe_id == pe_...
'Get current admin subscription settings'
def _get_admin_subscription(self, subscription_id=None, pe_id=None):
s3db = current.s3db stable = s3db.pr_subscription ftable = s3db.pr_filter output = {} get_vars = {} if (pe_id and subscription_id): query = (((stable.id == subscription_id) & (stable.deleted != True)) & (stable.pe_id == pe_id)) left = ftable.on((ftable.id == stable.filter_id)) ...
'Get current recipient and the current group settings'
def _get_recipients_and_groups(self, subscription_id=None, pe_id=None, caller=None):
stable = current.s3db.pr_subscription get_vars = {} if ((pe_id is not None) and (subscription_id is not None)): query = (((stable.id == subscription_id) & (stable.deleted != True)) & (stable.pe_id == pe_id)) row = current.db(query).select(stable.comments, limitby=(0, 1)).first() comm...
'Update subscription settings'
def _update_subscription(self, subscription, pe_id, filter_id=None, subscription_id=None, attachment=False):
db = current.db s3db = current.s3db ftable = s3db.pr_filter filters = subscription.get('filters') filters = json.loads(filters) for filter in filters: if (filter[0] == 'language__belongs'): filter[0] = 'info.language__belongs' if (filter[0] == 'priority__belongs'): ...
'Update Admin subscription'
def _update_admin_subscription(self, subscription, pe_id, alert_editor_id, user_id=None, group_id=None, filter_id=None, subscription_id=None):
db = current.db s3db = current.s3db stable = s3db.pr_subscription filters = subscription.get('filters') if (user_id is not None): comment_filter = {'auth_user.id': str(user_id)} elif (group_id is not None): comment_filter = {'pr_group.id': str(group_id)} else: comment...
'Update synchronization settings @param resource: available resources config @param filters: filter applied on the resource @param selected_repository_id: repository that is under current selection @param properties: comment field of the pr_subscription; used to store the ids of FTP Sync'
def _update_sync(self, resource, filters, selected_repository_id, properties):
db = current.db s3db = current.s3db auth = current.auth user_id = auth.user.id utcnow = current.request.utcnow if properties: old_repository_id = properties['repository_id'] if (old_repository_id != selected_repository_id): properties['repository_id'] = selected_repos...
'Remove synchronization settings'
def _remove_sync(self, properties):
if properties: current.s3db.resource('sync_repository', id=properties['repository_id']).delete()
'Returns the event type and list of priorities for the filters'
def _get_event_type_priorities(self, filters):
event_types = [] priorities = [] filters_ = json.loads(filters) filters_ = [filter_ for filter_ in filters_ if (filter_[1] is not None)] if (len(filters_) > 0): for filter_ in filters_: prefix = s3_str(filter_[0]).strip('[]') values = filter_[1].split(',') ...
'Get the PE-ID for list of group_ids @param group_ids: the list of group_ids @return: dictionary of pe_id and group_id'
def _get_group_pe_id(self, group_ids):
if group_ids: gtable = current.s3db.pr_group rows = current.db(gtable.id.belongs(group_ids)).select(gtable.id, gtable.pe_id) if rows: return {row.pe_id: row.id for row in rows} return None
'Main entry point, configuration'
def __call__(self):
logged_in = current.auth.s3_logged_in() if logged_in: fn = 'alert' else: fn = 'public' T = current.T s3db = current.s3db request = current.request output = {} ftable = s3db.gis_layer_feature query = ((ftable.controller == 'cap') & (ftable.function == fn)) layer = ...
'Parse Email Messages into the CAP Module'
@staticmethod def parse_email(message):
pass
'Parse Feeds into the CMS Module'
@staticmethod def parse_rss_2_cms(message):
db = current.db s3db = current.s3db table = s3db.msg_rss record = db((table.message_id == message.message_id)).select(table.channel_id, table.title, table.from_address, table.body, table.date, table.location_id, table.tags, table.author, limitby=(0, 1)).first() if ((not record) or (not record.body))...
'Parse RSS Feeds into the CAP Module'
@staticmethod def parse_rss_2_cap(message):
db = current.db s3db = current.s3db table = s3db.msg_rss message_id = message.message_id record = db((table.message_id == message_id)).select(table.id, table.channel_id, table.title, table.from_address, table.body, table.date, table.location_id, table.author, limitby=(0, 1)).first() if (not reco...
'Parse Tweets into the CMS Module'
@staticmethod def parse_tweet(message):
db = current.db s3db = current.s3db table = s3db.msg_twitter record = db((table.message_id == message.message_id)).select(table.channel_id, table.from_address, table.body, table.date, limitby=(0, 1)).first() if (not record): return channel_id = record.channel_id post_table = s3db.cms...
'Compose Menu'
@classmethod def menu(cls):
main_menu = MM()(cls.menu_modules(), cls.menu_lang(right=True), cls.menu_auth(), cls.menu_admin()) return main_menu
'Custom Modules Menu'
@classmethod def menu_modules(cls):
auth = current.auth has_role = auth.s3_has_role alert_hub_menu = MM('Alert Hub', c='default', f='index', args=['alert_hub_cop']) if auth.s3_logged_in(): alerting_menu = MM('Alerts', c='cap', f='alert') mapping_menu = MM('Map', c='gis', f='index') recipient_menu = MM('Recipient...
'Auth Menu'
@classmethod def menu_auth(cls, **attr):
auth = current.auth if (not auth.is_logged_in()): menu_auth = MM('Login', link=False, right=True)(MM('Login', c='default', f='user', m='login', vars={'_next': URL(c='cap', f='alert')}), MM('Lost Password', c='default', f='user', m='retrieve_password'), MM('Request for Account', c='default', f='...
'Administrator Menu'
@classmethod def menu_admin(cls, **attr):
if current.auth.s3_has_role('ADMIN'): name_nice = current.deployment_settings.modules['admin'].name_nice menu_admin = MM(name_nice, c='admin', right=True, **attr)(MM('Settings', f='setting'), MM('Manage Users', f='user'), MM('Database', c='appadmin', f='index'), MM('Error Tickets', f='errors')...
'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='...
'CAP menu'
@staticmethod def cap():
if (current.request.get_vars['~.external'] == 'True'): return M(c='cap')(M('Alert Hub', f='alert', vars={'~.external': True})(M('Map View', c='default', f='index', args=['alert_hub_cop']))) else: s3_has_role = current.auth.s3_has_role cap_editors = (lambda i: (s3_has_role('ALERT_ED...
'ORG / Organization Registry'
@staticmethod def org():
return M(c='org')(M('Organizations', f='organisation')(M('Create', m='create'), M('Import', m='import')))
'PR / Person Registry'
@staticmethod def pr():
ADMIN = current.session.s3.system_roles.ADMIN if (current.request.vars.option == 'manage_recipient'): return M(c='pr', restrict=ADMIN)(M('Manage Recipients', f='subscription', vars={'option': 'manage_recipient'})(M('Add Recipient to List', c='default', f='index', m='subscriptions', vars={'op...
'Messaging settings menu items: These items are used in multiple menus, but each item instance can always only belong to one parent, so we need to re-instantiate with the same parameters, and therefore this is defined as a function here. This separates the RSS containing CAP Feeds or CMS Feeds'
@classmethod def settings_messaging(cls):
return [M('Email Channels (Inbound)', c='msg', f='email_channel'), M('Facebook Channels', c='msg', f='facebook_channel'), M('RSS Channels', link=False)(M('Create RSS Feed for CAP', c='msg', f='rss_channel', vars={'type': 'cap'}), M('Create RSS Feed for CMS', c='msg', f='rss_chann...
'Compose Menu'
@classmethod def menu(cls):
main_menu = MM()(cls.menu_modules(), cls.menu_lang(right=True), cls.menu_auth(), cls.menu_admin()) return main_menu
'Custom Modules Menu'
@classmethod def menu_modules(cls):
auth = current.auth has_role = auth.s3_has_role home_page_menu = homepage() if auth.s3_logged_in(): alerting_menu = MM('Alerts', c='cap', f='alert') mapping_menu = MM('Map', c='gis', f='index') recipient_menu = MM('Recipients', c='pr', f='subscription', vars={'option': 'manage_re...
'Auth Menu'
@classmethod def menu_auth(cls, **attr):
auth = current.auth if (not auth.is_logged_in()): menu_auth = MM('Login', link=False, right=True)(MM('Login', c='default', f='user', m='login', vars={'_next': URL(c='cap', f='alert')}), MM('Lost Password', c='default', f='user', m='retrieve_password'), MM('Request for Account', c='default', f='...
'Administrator Menu'
@classmethod def menu_admin(cls, **attr):
if current.auth.s3_has_role('ADMIN'): name_nice = current.deployment_settings.modules['admin'].name_nice menu_admin = MM(name_nice, c='admin', right=True, **attr)(MM('Settings', f='setting'), MM('Manage Users', f='user'), MM('Database', c='appadmin', f='index'), MM('Error Tickets', f='errors')...
'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='...
'CAP menu'
@staticmethod def cap():
if (current.request.get_vars['~.external'] == 'True'): return M(c='cap')(M('Alert Hub', f='alert', vars={'~.external': True})(M('Map View', c='default', f='index', args=['alert_hub_cop']))) else: s3_has_role = current.auth.s3_has_role cap_editors = (lambda i: (s3_has_role('ALERT_ED...
'ORG / Organization Registry'
@staticmethod def org():
return M(c='org')(M('Organizations', f='organisation')(M('Create', m='create'), M('Import', m='import')))
'PR / Person Registry'
@staticmethod def pr():
ADMIN = current.session.s3.system_roles.ADMIN if (current.request.vars.option == 'manage_recipient'): return M(c='pr', restrict=ADMIN)(M('Manage Recipients', f='subscription', vars={'option': 'manage_recipient'})(M('Add Recipient to List', c='default', f='index', m='subscriptions', vars={'op...
'Messaging settings menu items: These items are used in multiple menus, but each item instance can always only belong to one parent, so we need to re-instantiate with the same parameters, and therefore this is defined as a function here. This separates the RSS containing CAP Feeds or CMS Feeds'
@classmethod def settings_messaging(cls):
return [M('Email Channels (Inbound)', c='msg', f='email_channel'), M('Facebook Channels', c='msg', f='facebook_channel'), M('RSS Channels', link=False)(M('Create RSS Feed for CAP', c='msg', f='rss_channel', vars={'type': 'cap'}), M('Create RSS Feed for CMS', c='msg', f='rss_chann...
'Main entry point, configuration'
def __call__(self):
T = current.T auth = current.auth if (not auth.s3_logged_in()): auth.permission.fail() resources = [dict(resource='cms_post', url='default/index/newsfeed', label=T('Updates'))] filters = [S3OptionsFilter('series_id', label=T('Subscribe to'), represent='%(name)s', resource='cms_post', _nam...
'Lookup the full set of options for a Filter Widget - for Subscriptions we don\'t want to see just the options available in current data'
@staticmethod def _options(fieldname):
db = current.db if (fieldname == 'series_id'): table = current.s3db.cms_series rows = db((table.deleted == False)).select(table.id, table.name) options = {} for row in rows: options[row.id] = row.name elif (fieldname == 'location_id'): table = current.s3db...
'Custom form to manage subscriptions @param resources: available resources config @param filters: filter widgets'
def _manage_subscriptions(self, resources, filters):
from gluon.sqlhtml import SQLFORM from gluon.validators import IS_IN_SET from s3 import S3GroupedOptionsWidget T = current.T labels = Storage(RESOURCES=T('Subscribe To'), NOTIFY_ON=T('Notify On'), FREQUENCY=T('Frequency'), NOTIFY_BY=T('Notify By'), MORE=T('More Options'), LESS=T('Less ...
'Get current subscription settings'
def _get_subscription(self):
db = current.db s3db = current.s3db pe_id = current.auth.user.pe_id stable = s3db.pr_subscription ftable = s3db.pr_filter query = ((stable.pe_id == pe_id) & (stable.deleted != True)) left = ftable.on((ftable.id == stable.filter_id)) row = db(query).select(stable.id, stable.notify_on, sta...
'Update subscription settings'
def _update_subscription(self, subscription):
db = current.db s3db = current.s3db pe_id = subscription['pe_id'] filter_id = subscription['filter_id'] filters = subscription.get('filters') if filters: ftable = s3db.pr_filter if (not filter_id): success = ftable.insert(pe_id=pe_id, query=filters) filter...
'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 return [homepage('gis')(), homepage('cms', f='newsfeed', m='datalist', name=T('News'))(), homepage('event', name='Situational Awareness')(MM('Incidents', c='event', f='incident'), MM('Deployments', c='deploy', f='mission'), MM('Assessments', c='survey', f='series'), MM('Situation Reports', c...
'Dashboard Menu (at bottom of page)'
@classmethod def menu_dashboard(cls):
DB = S3DashBoardMenuLayout request = current.request controller = request.controller if (controller == 'vol'): dashboard = DB()(DB('Volunteers', c='vol', image='graphic_staff_wide.png', title='Volunteers')(DB('Manage Volunteer Data', f='volunteer', m='summary'), DB('Manage Teams Data...
'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() gis_item = M('Map Settings', c='gis', f='config') menu.append(gis_item) return menu
'ASSET Controller'
@staticmethod def asset():
ADMIN = current.session.s3.system_roles.ADMIN return M(c='asset')(M('Assets', f='asset', m='summary')(M('Create', m='create'), M('Import', m='import', p='create')), M('Items', f='item', m='summary')(M('Create', m='create'), M('Import', f='catalog_item', m='import', p='create')), M('Item Categories', f='item_...
'Situation Reports'
def doc(self):
return self.event()
'Incidents'
@staticmethod def event():
return M()(M('Incidents', c='event', f='incident', args='summary')(M('Create', m='create')), M('Assessments', c='survey', f='series')(M('Create', m='create')), M('Situation Reports', c='doc', f='sitrep')(M('Create', m='create')), M('Incident Types', c='event', f='incident_type', check=current.auth.s3_has_role...
'GIS / Mapping'
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('ORG_ADMIN')) is_super_editor = (lambda i: (has_role('staff_super')...
'INV / Inventory'
@staticmethod def inv():
ADMIN = current.session.s3.system_roles.ADMIN s3db = current.s3db s3db.inv_recv_crud_strings() inv_recv_list = current.response.s3.crud_strings.inv_recv.title_list return M()(M('Warehouses', c='inv', f='warehouse')(M('Create', m='create'), M('Import', m='import', p='create')), M('Warehouse Stock'...
'Organisation Management'
def org(self):
return self.hrm()
'Requests Management'
def req(self):
return self.inv()
'Survey'
def survey(self):
return self.event() 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_i...
'Volunteer Management'
@staticmethod def vol():
auth = current.auth has_role = auth.s3_has_role s3 = current.session.s3 ADMIN = s3.system_roles.ADMIN is_org_admin = (lambda i: has_role('ORG_ADMIN')) is_super_editor = (lambda i: (has_role('vol_super') or has_role('staff_super'))) settings = current.deployment_settings show_programmes =...
'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
'Help Menu'
@classmethod def menu_help(cls, **attr):
return MM('About', link=False, right=True)(MM('About this Site', f='about', right=True), MM('User Manual', c='default', f='index', args=['docs'], vars={'name': 'UserManual'}), MM('Contact us', f='contact', right=True))
'Custom Modules Menu'
@classmethod def menu_modules(cls):
return [MM('News', c='cms', f='newsfeed', args='datalist', icon='icon-news'), MM('Current Needs', c='req', f='organisation_needs'), MM('Organizations', c='org', f='organisation'), MM('Facilities', c='org', f='facility', m='summary'), homepage('gis'), MM('More', link=False)(MM('Requests', c='req', f='req', vars={...
'ORG / Organization Registry'
@staticmethod def org():
ADMIN = current.session.s3.system_roles.ADMIN SECTORS = ('Clusters' if current.deployment_settings.get_ui_label_cluster() else 'Sectors') return M(c='org')(M('Organizations', f='organisation')(M('Create', m='create'), M('Import', m='import')), M('Facilities', f='facility', m='summary')(M('Create', m='create...
'PROJECT / Project Tracking & Management'
@staticmethod def project():
ADMIN = current.session.s3.system_roles.ADMIN menu = M(c='project')(M('Projects', f='project', m='summary')(M('Create', m='create')), M('Locations', f='location')(M('Map', m='map'), M('Contacts', f='location_contact')), M('Reports', f='location', m='report')(M('3W', f='location', m='report'), M('Beneficiaries',...
'REQ / Request Management'
@staticmethod def req():
if (not current.auth.s3_logged_in()): return None ADMIN = current.session.s3.system_roles.ADMIN settings = current.deployment_settings types = settings.get_req_req_type() get_vars = {} if (len(types) == 1): t = types[0] if (t == 'Stock'): get_vars = {'type': '...
'Main entry point, configuration'
def __call__(self):
T = current.T auth = current.auth if (not auth.s3_logged_in()): auth.permission.fail() resources = [dict(resource='cms_post', url='default/index/newsfeed', label=T('Updates'))] filters = [S3OptionsFilter('series_id', label=T('Subscribe to'), represent='%(name)s', resource='cms_post', _nam...
'Lookup the full set of options for a Filter Widget - for Subscriptions we don\'t want to see just the options available in current data'
@staticmethod def _options(fieldname):
db = current.db if (fieldname == 'series_id'): table = current.s3db.cms_series rows = db((table.deleted == False)).select(table.id, table.name) options = {} for row in rows: options[row.id] = row.name elif (fieldname == 'location_id'): table = current.s3db...
'Custom form to manage subscriptions @param resources: available resources config @param filters: filter widgets'
def _manage_subscriptions(self, resources, filters):
from gluon.sqlhtml import SQLFORM from gluon.validators import IS_IN_SET from s3.s3widgets import S3GroupedOptionsWidget T = current.T labels = Storage(RESOURCES=T('Subscribe To'), NOTIFY_ON=T('Notify On'), FREQUENCY=T('Frequency'), NOTIFY_BY=T('Notify By'), MORE=T('More Options'), LESS=...
'Get current subscription settings'
def _get_subscription(self):
db = current.db s3db = current.s3db pe_id = current.auth.user.pe_id stable = s3db.pr_subscription ftable = s3db.pr_filter query = ((stable.pe_id == pe_id) & (stable.deleted != True)) left = ftable.on((ftable.id == stable.filter_id)) row = db(query).select(stable.id, stable.notify_on, sta...
'Update subscription settings'
def _update_subscription(self, subscription):
db = current.db s3db = current.s3db pe_id = subscription['pe_id'] filter_id = subscription['filter_id'] filters = subscription.get('filters') if filters: ftable = s3db.pr_filter if (not filter_id): success = ftable.insert(pe_id=pe_id, query=filters) filter...
'Compose Menu'
@classmethod def menu(cls):
main_menu = MM()(cls.menu_modules(), cls.menu_help(right=True), cls.menu_auth(right=True), cls.menu_admin(right=True), cls.menu_gis(right=True)) return main_menu
'Custom Admin Menu'
@classmethod def menu_admin(cls, **attr):
menu = super(S3MainMenu, cls).menu_admin(**attr) if menu: item = MM('Edit Contacts', c='cms', f='post', args=['update'], vars={'~.title': 'Contacts'}) menu.append(item) return menu
'Custom Modules Menu'
@classmethod def menu_modules(cls):
has_role = current.auth.s3_has_role if has_role('ADMIN'): return [homepage(), MM('Users', c='admin', f='user'), MM('Master Data', link=False)(M('Locations', c='gis', f='location'), M('Demographics', c='stats', f='demographic_data'), M('Organizations', c='org', f='organisation'), M('Disasters', c='eve...
'DOC / Documents Module'
def cms(self):
if current.auth.s3_has_role('ADMIN'): return super(S3OptionsMenu, self).cms() else: return None