desc
stringlengths
3
26.7k
decl
stringlengths
11
7.89k
bodies
stringlengths
8
553k
'Warn if total weightings are not equal to 1.0 Update Project Status'
def project_goal_onaccept(self, form, create=False):
db = current.db form_vars = form.vars record_id = form_vars.id table = current.s3db.project_goal record = db((table.id == record_id)).select(table.project_id, limitby=(0, 1)).first() try: project_id = record.project_id except: current.log.error('Cannot find Project G...
'Import item de-duplication'
@staticmethod def project_outcome_deduplicate(item):
data = item.data name = data.get('name') if name: table = item.table query = (table.name == name) project_id = data.get('project_id') if project_id: query &= ((table.project_id == project_id) | (table.project_id == None)) duplicate = current.db(query).sele...
'Default all weightings to an even spread @ToDo: Handle deployment_settings which have Outcomes directly attached to Projects'
def project_outcome_create_onaccept(self, form):
db = current.db record_id = form.vars.id table = current.s3db.project_outcome record = db((table.id == record_id)).select(table.goal_id, limitby=(0, 1)).first() try: goal_id = record.goal_id except: error = 'Cannot find Project Outcome record (no record for ...
'Warn if totals are not equal to 1.0 @ToDo: Handle deployment_settings which have Outcomes directly attached to Projects'
def project_outcome_onaccept(self, form, create=False):
db = current.db form_vars = form.vars record_id = form_vars.id table = current.s3db.project_outcome record = db((table.id == record_id)).select(table.goal_id, table.project_id, limitby=(0, 1)).first() try: project_id = record.project_id except: error = 'Cannot find Proj...
'Import item de-duplication'
@staticmethod def project_output_deduplicate(item):
data = item.data name = data.get('name') if name: table = item.table query = (table.name == name) project_id = data.get('project_id') if project_id: query &= ((table.project_id == project_id) | (table.project_id == None)) duplicate = current.db(query).sele...
'Default all weightings to an even spread @ToDo: Handle deployment_settings which have Outputs directly attached to Projects'
def project_output_create_onaccept(self, form):
db = current.db record_id = form.vars.id table = current.s3db.project_output record = db((table.id == record_id)).select(table.outcome_id, limitby=(0, 1)).first() try: outcome_id = record.outcome_id except: current.log.error('Cannot find Project Output record (no ...
'Update all ancestor fields from immediate parent Warn if totals are not equal to 1.0 @ToDo: Handle deployment_settings which have Outputs directly attached to Projects Update Project Status at all levels'
def project_output_onaccept(self, form, create=False):
db = current.db s3db = current.s3db form_vars = form.vars record_id = form_vars.id table = s3db.project_output settings = current.deployment_settings if (settings.get_project_outcomes() and settings.get_project_goals()): outcome_id = form_vars.get('outcome_id') if outcome_id:...
'Import item de-duplication'
@staticmethod def project_indicator_deduplicate(item):
data = item.data name = data.get('name') if name: table = item.table query = (table.name == name) project_id = data.get('project_id') if project_id: query &= ((table.project_id == project_id) | (table.project_id == None)) duplicate = current.db(query).sele...
'Default all weightings to an even spread @ToDo: Handle deployment_settings which have Indicators directly attached to Projects'
def project_indicator_create_onaccept(self, form):
db = current.db record_id = form.vars.id table = current.s3db.project_indicator record = db((table.id == record_id)).select(table.output_id, limitby=(0, 1)).first() try: output_id = record.output_id except: current.log.error('Cannot find Project Indicator record (n...
'Update all ancestor fields from immediate parent Warn if totals are not equal to 1.0 @ToDo: Handle deployment_settings which have Indicators directly attached to Projects Update Project Status at all levels'
def project_indicator_onaccept(self, form, create=False):
db = current.db s3db = current.s3db form_vars = form.vars record_id = form_vars.id table = s3db.project_indicator settings = current.deployment_settings if (settings.get_project_outputs() and (settings.get_project_outcomes() or settings.get_project_goals())): output_id = form_vars.ge...
'Handle Updates of entries to reset the hidden start_date Update Project Status at all levels'
def project_indicator_data_onaccept(self, form):
db = current.db s3db = current.s3db table = s3db.project_indicator_data record_id = form.vars.id record = db((table.id == record_id)).select(table.indicator_id, table.start_date, table.end_date, limitby=(0, 1)).first() try: indicator_id = record.indicator_id except: current.l...
'Handle Updates of entries to reset the hidden start_date Update Project Status at all levels'
def project_indicator_data_ondelete(self, row):
db = current.db s3db = current.s3db table = s3db.project_indicator_data record_id = row.get('id') record = db((table.id == record_id)).select(table.deleted_fk, table.start_date, table.end_date, limitby=(0, 1)).first() try: fks = json.loads(record.deleted_fk) indicator_id = fks['i...
'Import item de-duplication'
@staticmethod def project_indicator_criteria_deduplicate(item):
data = item.data name = data.get('name') if name: table = item.table query = (table.name == name) project_id = data.get('project_id') if project_id: query &= ((table.project_id == project_id) | (table.project_id == None)) duplicate = current.db(query).sele...
'Default all weightings to an even spread'
def project_indicator_criteria_create_onaccept(self, form):
db = current.db record_id = form.vars.id table = current.s3db.project_indicator_criteria record = db((table.id == record_id)).select(table.indicator_id, limitby=(0, 1)).first() try: indicator_id = record.indicator_id except: current.log.error('Cannot find Project Indicat...
'Update all ancestor fields from immediate parent'
def project_indicator_criteria_onaccept(self, form, create=False):
form_vars = form.vars indicator_id = form_vars.get('indicator_id') if indicator_id: db = current.db s3db = current.s3db record_id = form_vars.id table = s3db.project_indicator_criteria itable = s3db.project_indicator indicator = db((itable.id == indicator_id))...
'Default all weightings to an even spread'
def project_criteria_activity_create_onaccept(self, form):
db = current.db record_id = form.vars.id table = current.s3db.project_criteria_activity record = db((table.id == record_id)).select(table.criteria_id, limitby=(0, 1)).first() try: criteria_id = record.criteria_id except: current.log.error('Cannot find Project Criteria ...
'Update all ancestor fields from immediate parent Update Status of Criterion'
def project_criteria_activity_onaccept(self, form, create=False):
form_vars = form.vars criteria_id = form_vars.get('criteria_id') if criteria_id: db = current.db s3db = current.s3db record_id = form_vars.id table = s3db.project_criteria_activity ctable = s3db.project_indicator_criteria criterion = db((ctable.id == criteria_...
'Set the Activity\'s project_id when created via this Custom Form'
@staticmethod def project_criteria_activity_postprocess(form):
db = current.db s3db = current.s3db vars_get = form.vars.get criteria_id = vars_get('criteria_id') ctable = s3db.project_indicator_criteria criterion = db((ctable.id == criteria_id)).select(ctable.project_id, limitby=(0, 1)).first() if criterion: criteria_activity_id = vars_get('id')...
'Virtual Field to show the percentage completion of the Indicator'
@staticmethod def project_indicator_percentage(row):
if hasattr(row, 'project_indicator_data'): row = row.project_indicator_data if hasattr(row, 'target_value'): planned = row.target_value if (planned is None): return current.messages['NONE'] else: planned = None if hasattr(row, 'value'): actual = row.va...
'Entry point for REST API @param r: the S3Request @param attr: controller arguments'
def apply_method(self, r, **attr):
if (r.name == 'project'): representation = r.representation if (representation == 'html'): output = self.html(r, **attr) return output elif (representation == 'pdf'): output = self.pdf(r, **attr) return output raise HTTP(405, current.ERROR....
'Extract the Data @ToDo: Read the filters from the HTML view'
def _extract(self, r, **attr):
db = current.db s3db = current.s3db status_from_activities = current.deployment_settings.get_project_status_from_activities() project_id = r.id vars_get = r.get_vars.get start_date = vars_get('date__ge') end_date = vars_get('date__le') goal_ids = vars_get('goal_id__belongs', []) indi...
'HTML Representation - page with Filters'
def html(self, r, **attr):
T = current.T db = current.db s3db = current.s3db settings = current.deployment_settings project_id = r.id goals = {} table = s3db.project_goal query = ((table.project_id == project_id) & (table.deleted == False)) rows = db(query).select(table.id, table.code, table.name) for row ...
'PDF Representation -the actual report'
def pdf(self, r, **attr):
from ..s3.s3codecs.pdf import EdenDocTemplate, S3RL_PDF T = current.T db = current.db s3db = current.s3db NONE = current.messages['NONE'] status_from_activities = current.deployment_settings.get_project_status_from_activities() (project, goals) = self._extract(r, **attr) record = r.recor...
'Entry point for REST API @param r: the S3Request @param attr: controller arguments'
def apply_method(self, r, **attr):
if (r.name == 'project'): if (r.representation == 'html'): output = self.html(r, **attr) return output elif (r.representation == 'xls'): output = self.xls(r, **attr) return output raise HTTP(405, current.ERROR.BAD_METHOD)
'Extract the Data'
def _extract(self, r, **attr):
db = current.db s3db = current.s3db NONE = current.messages['NONE'] project_id = r.id goals = {} table = s3db.project_goal query = ((table.project_id == project_id) & (table.deleted == False)) rows = db(query).select(table.id, table.code, table.name, table.overall_status_by_indicators) ...
'HTML Representation'
def html(self, r, **attr):
T = current.T s3db = current.s3db response = current.response NONE = current.messages['NONE'] record = r.record (dates, years, goals) = self._extract(r, **attr) colspan = (((2 * len(dates)) + (2 * len(years))) + 3) header_row = TR(TD(T('Number'), _rowspan=2, _class='tal'), TD(T('Indicato...
'XLS Representation'
def xls(self, r, **attr):
from ..s3.s3codecs import S3XLS try: import xlwt except ImportError: error = S3XLS.ERROR.XLWT_ERROR current.log.error(error) raise HTTP(503, body=error) T = current.T (dates, years, goals) = self._extract(r, **attr) if (not years): current.session.warning ...
'Safe defaults for names if module is disabled'
@staticmethod def defaults():
dummy = S3ReusableField('dummy_id', 'integer', readable=False, writable=False) return {'project_programme_id': (lambda **attr: dummy('programme_id'))}
'Record creation post-processing Update the percentages of all the Project\'s Locations.'
@staticmethod def project_theme_project_onaccept(form):
project_id = form.vars.get('project_id', None) if ((not project_id) and form.request_vars): project_id = form.request_vars.get('project_id', None) if (not project_id): return percentages = {} db = current.db table = db.project_theme_project query = ((table.deleted == False) &...
'Option representation'
@staticmethod def hfa_opts_represent(opt):
if (not opt): return current.messages['NONE'] if isinstance(opt, int): opts = [opt] elif (not isinstance(opt, (list, tuple))): return current.messages['NONE'] else: opts = opt if (opts[0] is None): return current.messages['NONE'] vals = [('HFA %s' % o) ...
'After DB I/O tasks for Project DRRPP records'
@staticmethod def project_drrpp_onaccept(form):
db = current.db form_vars = form.vars id = form_vars.id project_id = form_vars.project_id dtable = db.project_drrpp if (not project_id): project_id = db((dtable.id == id)).select(dtable.project_id, limitby=(0, 1)).first().project_id table = db.project_project hr_id = db((table.id...
'Option representation'
@staticmethod def opts_represent(opt, prefix):
if isinstance(opt, int): opts = [opt] if isinstance(opt, (list, tuple)): if ((not opt) or (opt[0] is None)): return current.messages['NONE'] else: return ', '.join([('%s %s' % (prefix, o)) for o in opt]) else: return current.messages['NONE']
'Safe defaults for model-global names if module is disabled'
@staticmethod def defaults():
dummy = S3ReusableField('dummy_id', 'integer', readable=False, writable=False) return dict(project_task_id=(lambda **attr: dummy('task_id')), project_task_active_statuses=[])
'The record ID of a task as separate column in the data table'
@staticmethod def project_task_task_id(row):
if hasattr(row, 'project_task'): row = row.project_task try: return row.id except AttributeError: return None
'Provide the options for the Project search filter - all Projects with Tasks'
@staticmethod def project_task_project_opts():
db = current.db ptable = db.project_project ttable = db.project_task ltable = db.project_task_project query = (((ttable.deleted != True) & (ltable.task_id == ttable.id)) & (ltable.project_id == ptable.id)) rows = db(query).select(ptable.id, ptable.name) return dict(((row.id, row.name) for ro...
'Provide the options for the Activity search filter - all Activities with Tasks'
@staticmethod def project_task_activity_opts():
db = current.db atable = db.project_activity ttable = db.project_task ltable = db.project_task_activity query = (((ttable.deleted == False) & (ltable.task_id == ttable.id)) & (ltable.activity_id == atable.id)) rows = db(query).select(atable.id, atable.name) return dict(((row.id, row.name) fo...
'Provide the options for the Milestone search filter - all Milestones with Tasks'
@staticmethod def project_task_milestone_opts():
db = current.db mtable = db.project_milestone ttable = db.project_task ltable = db.project_task_milestone query = (((ttable.deleted == False) & (ltable.task_id == ttable.id)) & (ltable.milestone_id == mtable.id)) rows = db(query).select(mtable.id, mtable.name) return dict(((row.id, row.name)...
'Set the task realm entity to the project\'s realm entity'
@staticmethod def project_task_realm_entity(table, record):
task_id = record.id db = current.db ptable = db.project_project ltable = db.project_task_project query = ((ltable.task_id == task_id) & (ltable.project_id == ptable.id)) project = db(query).select(ptable.realm_entity, limitby=(0, 1)).first() if project: return project.realm_entity ...
'Task form validation'
@staticmethod def project_task_onvalidation(form):
vars = form.vars if ((str(vars.status) == '3') and (not vars.pe_id)): form.errors.pe_id = (current.T("Status 'assigned' requires the %(fieldname)s to not be blank") % dict(fieldname=current.db.project_task.pe_id.label)) elif (vars.pe_id and (str(vars.status) == '2')): ...
'When a Task is created: * Process the additional fields: Project/Activity/Milestone * create associated Link Table records * notify assignee'
@staticmethod def project_task_create_onaccept(form):
db = current.db s3db = current.s3db session = current.session task_id = form.vars.id if session.s3.incident: etable = s3db.event_task etable.insert(incident_id=session.s3.incident, task_id=task_id) ltp = db.project_task_project post_vars = current.request.post_vars projec...
'* Process the additional fields: Project/Activity/Milestone * Log changes as comments * If the task is assigned to someone then notify them'
@staticmethod def project_task_update_onaccept(form):
db = current.db s3db = current.s3db form_vars = form.vars task_id = form_vars.id record = form.record table = db.project_task changed = {} if record: for var in form_vars: vvar = form_vars[var] rvar = record[var] if (vvar != rvar): ...
'Send a Task Dispatch notice from a Task - if a location is supplied, this will be formatted as an OpenGeoSMS'
@staticmethod def project_task_dispatch(r, **attr):
if ((r.representation == 'html') and (r.name == 'task') and r.id and (not r.component)): record = r.record text = ('%s: %s' % (record.name, record.description)) msg = current.msg message = msg.prepare_opengeosms(record.location_id, code='ST', map='google', text=text) url =...
'When Time is logged, update the Task & Activity'
@staticmethod def project_time_onaccept(form):
db = current.db titable = db.project_time ttable = db.project_task atable = db.project_activity tatable = db.project_task_activity task_id = form.vars.task_id if (not task_id): query = (titable.id == form.vars.id) record = db(query).select(titable.task_id, limitby=(0, 1)).fir...
'When a Task is linked to an IReport, then populate the location_id'
@staticmethod def task_ireport_onaccept(form):
vars = form.vars ireport_id = vars.ireport_id task_id = vars.task_id db = current.db table = db.project_task query = (table.id == task_id) record = db(query).select(table.location_id, limitby=(0, 1)).first() if ((not record) or record.location_id): return itable = db.irs_irep...
'Custom lookup method for organisation rows, does a join with the projects and locations. Parameters key and fields are not used, but are kept for API compatiblity reasons. @param values: the project_location IDs'
def custom_lookup_rows(self, key, values, fields=None):
db = current.db ltable = current.s3db.project_location gtable = db.gis_location fields = [ltable.id, gtable.name, gtable.level, gtable.L0, gtable.L1, gtable.L2, gtable.L3, gtable.L4, gtable.L5] if (len(values) == 1): query = ((ltable.id == values[0]) & (ltable.location_id == gtable.id)) ...
'Represent a single Row @param row: the joined Row'
def represent_row(self, row):
community = self.community if (not self.community): prow = row['project_project'] row = row['gis_location'] name = row.name level = row.level if (level == 'L0'): location = name elif name: locations = [name] lappend = locations.append matched = False ...
'Constructor @param show_link: render representation as link to the task @param show_project: show the project name in the representation @param project_first: show the project name before the task name'
def __init__(self, show_link=False, show_project=False, project_first=True):
task_url = URL(c='project', f='task', args=['[id]']) super(project_TaskRepresent, self).__init__(lookup='project_task', show_link=show_link, linkto=task_url) self.show_project = show_project if show_project: self.project_represent = S3Represent(lookup='project_project') self.project_first = ...
'Custom rows lookup @param key: the key Field @param values: the values @param fields: unused (retained for API compatibility)'
def lookup_rows(self, key, values, fields=[]):
s3db = current.s3db ttable = s3db.project_task fields = [ttable.id, ttable.name] show_project = self.show_project if show_project: ltable = s3db.project_task_project left = ltable.on((ltable.task_id == ttable.id)) fields.append(ltable.project_id) else: left = None...
'Represent a row @param row: the Row'
def represent_row(self, row):
output = row['project_task.name'] if self.show_project: project_id = row['project_task_project.project_id'] if self.project_first: if project_id: strfmt = '%(project)s: %(task)s' else: strfmt = '- %(task)s' elif project_id: ...
'Custom lookup method for activity rows, does a left join with the parent project. Parameters key and fields are not used, but are kept for API compatibility reasons. @param values: the activity IDs'
def custom_lookup_rows(self, key, values, fields=[]):
db = current.db s3db = current.s3db atable = s3db.project_activity ptable = s3db.project_project left = ptable.on((ptable.id == atable.project_id)) qty = len(values) if (qty == 1): query = (atable.id == values[0]) limitby = (0, 1) else: query = atable.id.belongs(v...
'Represent a single Row @param row: the project_activity Row'
def represent_row(self, row):
if self.code: name = row['project_activity.name'] code = row['project_project.code'] if (not name): return row['project_activity.id'] else: name = row['name'] if (not name): return row['id'] if (self.code and code): name = ('%s > ...
'Themes associated with this Project'
def themes(self):
try: project_id = self.project_project.id except AttributeError: return '' s3db = current.s3db ptable = s3db.project_project ttable = s3db.project_theme ltable = s3db.project_theme_percentage query = (((ltable.deleted != True) & (ltable.project_id == project_id)) & (ltable.th...
'Constructor @param form: widget config to inject at the top of the page, or a callable to produce such a widget config'
def __init__(self, form=None):
self.form = form
'Entry point for REST API @param r: the S3Request @param attr: controller arguments'
def apply_method(self, r, **attr):
if ((r.name == 'project') and r.id and (not r.component) and (r.representation in ('html', 'aadata'))): T = current.T s3db = current.s3db settings = current.deployment_settings def dt_row_actions(component): return (lambda r, list_id: [{'label': T('Open'), 'url': r.url(co...
'Enable a Channel - Schedule a Poll for new messages - Enable all associated Parsers CLI API for shell scripts & to be called by S3Method'
@staticmethod def channel_enable(tablename, channel_id):
db = current.db s3db = current.s3db table = s3db.table(tablename) record = db((table.channel_id == channel_id)).select(table.id, table.enabled, limitby=(0, 1)).first() if (not record.enabled): record.update_record(enabled=True) s3db.update_super(table, record) ptable = s3db.msg_p...
'Enable a Channel - Schedule a Poll for new messages S3Method for interactive requests'
@staticmethod def channel_enable_interactive(r, **attr):
tablename = r.tablename result = current.s3db.msg_channel_enable(tablename, r.record.channel_id) current.session.confirmation = result fn = tablename.split('_', 1)[1] redirect(URL(f=fn))
'Disable a Channel - Remove schedule for Polling for new messages - Disable all associated Parsers CLI API for shell scripts & to be called by S3Method'
@staticmethod def channel_disable(tablename, channel_id):
db = current.db s3db = current.s3db table = s3db.table(tablename) record = db((table.channel_id == channel_id)).select(table.id, table.enabled, limitby=(0, 1)).first() if record.enabled: record.update_record(enabled=False) s3db.update_super(table, record) ptable = s3db.msg_parser...
'Disable a Channel - Remove schedule for Polling for new messages S3Method for interactive requests'
@staticmethod def channel_disable_interactive(r, **attr):
tablename = r.tablename result = current.s3db.msg_channel_disable(tablename, r.record.channel_id) current.session.confirmation = result fn = tablename.split('_', 1)[1] redirect(URL(f=fn))
'Process the Enabled Flag'
@staticmethod def channel_onaccept(form):
if form.record: if (form.record.enabled and (not form.vars.enabled)): current.s3db.msg_channel_disable(form.table._tablename, form.vars.channel_id) elif (form.vars.enabled and (not form.record.enabled)): current.s3db.msg_channel_enable(form.table._tablename, form.vars.channel...
'Poll a Channel for new messages S3Method for interactive requests'
@staticmethod def channel_poll(r, **attr):
tablename = r.tablename current.s3task.async('msg_poll', args=[tablename, r.record.channel_id]) current.session.confirmation = current.T('The poll request has been submitted, so new messages should appear shortly - refresh to see them') if (tablename == 'm...
'Return safe defaults in case the model has been deactivated.'
@staticmethod def defaults():
dummy = S3ReusableField('dummy_id', 'integer', readable=False, writable=False) return dict(msg_message_id=(lambda **attr: dummy('message_id')))
'Safe defaults for model-global names if module is disabled'
@staticmethod def defaults():
return dict(msg_facebook_login=(lambda : False))
'Parse unparsed messages S3Method for interactive requests'
@staticmethod def parser_parse(r, **attr):
record = r.record current.s3task.async('msg_parse', args=[record.channel_id, record.function_name]) current.session.confirmation = current.T('The parse request has been submitted') redirect(URL(f='parser'))
'Helper function to see if there is a Parser connected to a Channel - used to determine whether to populate the msg_parsing_status table'
@staticmethod def parser_enabled(channel_id):
table = current.s3db.msg_parser record = current.db((table.channel_id == channel_id)).select(table.enabled, limitby=(0, 1)).first() if (record and record.enabled): return True else: return False
'Enable a Parser - Connect a Parser to a Channel CLI API for shell scripts & to be called by S3Method @ToDo: Ensure only 1 Parser is connected to any Channel at a time'
@staticmethod def parser_enable(id):
db = current.db s3db = current.s3db table = s3db.msg_parser record = db((table.id == id)).select(table.id, table.enabled, table.channel_id, table.function_name, limitby=(0, 1)).first() if (not record.enabled): record.update_record(enabled=True) channel_id = record.channel_id function...
'Enable a Parser - Connect a Parser to a Channel S3Method for interactive requests'
@staticmethod def parser_enable_interactive(r, **attr):
result = current.s3db.msg_parser_enable(r.id) current.session.confirmation = result redirect(URL(f='parser'))
'Disable a Parser - Disconnect a Parser from a Channel CLI API for shell scripts & to be called by S3Method'
@staticmethod def parser_disable(id):
db = current.db s3db = current.s3db table = s3db.msg_parser record = db((table.id == id)).select(table.id, table.enabled, table.channel_id, table.function_name, limitby=(0, 1)).first() if record.enabled: record.update_record(enabled=False) ttable = db.scheduler_task args = ('[%s, ...
'Disable a Parser - Disconnect a Parser from a Channel S3Method for interactive requests'
@staticmethod def parser_disable_interactive(r, **attr):
result = current.s3db.msg_parser_disable(r.id) current.session.confirmation = result redirect(URL(f='parser'))
'Process the Enabled Flag'
@staticmethod def msg_parser_onaccept(form):
if form.record: if (form.record.enabled and (not form.vars.enabled)): current.s3db.msg_parser_disable(form.vars.id) elif (form.vars.enabled and (not form.record.enabled)): current.s3db.msg_parser_enable(form.vars.id) elif form.vars.enabled: current.s3db.msg_parser...
'Represent a Twitter account'
@staticmethod def twitter_represent(nickname, show_link=True):
if (not nickname): return current.messages['NONE'] db = current.db s3db = current.s3db table = s3db.pr_contact query = ((table.contact_method == 'TWITTER') & (table.value == nickname)) row = db(query).select(table.pe_id, limitby=(0, 1)).first() if row: repr = s3db.pr_pentity_...
'Complete oauth: take tokens from session + pin from form, and do the 2nd API call to Twitter'
@staticmethod def twitter_channel_onvalidation(form):
T = current.T session = current.session settings = current.deployment_settings.msg s3 = session.s3 form_vars = form.vars if (form_vars.pin and s3.twitter_request_key and s3.twitter_request_secret): try: import tweepy except: raise HTTP(501, body=T("Can't ...
'Perform a Search of Twitter S3Method for interactive requests'
@staticmethod def twitter_search_poll(r, **attr):
id = r.id tablename = r.tablename current.s3task.async('msg_twitter_search', args=[id]) current.session.confirmation = current.T('The search request has been submitted, so new messages should appear shortly - refresh to see them') redirect(URL(f='twitt...
'Prcoess Search Results with KeyGraph S3Method for interactive requests'
@staticmethod def twitter_keygraph(r, **attr):
tablename = r.tablename current.s3task.async('msg_process_keygraph', args=[r.id]) current.session.confirmation = current.T('The search results are now being processed with KeyGraph') redirect(URL(f='twitter_result'))
'Display the Tweets on a Simile Timeline http://www.simile-widgets.org/wiki/Reference_Documentation_for_Timeline'
@staticmethod def twitter_timeline(r, **attr):
if ((r.representation == 'html') and (r.name == 'twitter_result')): response = current.response s3 = response.s3 appname = r.application s3.scripts.append(('/%s/static/scripts/simile/timeline/timeline-api.js' % appname)) if s3.debug: s3.scripts.append(('/%s/static...
'Safe defaults for names in case the module is disabled'
@staticmethod def defaults():
dummy = S3ReusableField('dummy_id', 'integer', readable=False, writable=False) return {'dvr_case_id': (lambda name='case_id', **attr: dummy(name, **attr)), 'dvr_case_status_id': (lambda name='status_id', **attr: dummy(name, **attr))}
'Onaccept routine for case statuses: - only one status can be the default @param form: the FORM'
@staticmethod def case_status_onaccept(form):
form_vars = form.vars try: record_id = form_vars.id except AttributeError: record_id = None if (not record_id): return if (('is_default' in form_vars) and form_vars.is_default): table = current.s3db.dvr_case_status db = current.db db((table.id != recor...
'Case onvalidation: - make sure case numbers are unique within the organisation @param form: the FORM'
@staticmethod def case_onvalidation(form):
db = current.db s3db = current.s3db form_vars = form.vars if ('id' in form_vars): record_id = form_vars.id elif hasattr(form, 'record_id'): record_id = form.record_id else: record_id = None try: reference = form_vars.reference except AttributeError: ...
'Wrapper for case_onaccept when called during create rather than update @param form: the FORM'
@classmethod def case_create_onaccept(cls, form):
cls.case_onaccept(form, create=True)
'Case onaccept routine: - auto-create active appointments - count household size for new cases @param form: the FORM @param create: perform additional actions for new cases'
@staticmethod def case_onaccept(form, create=False):
db = current.db s3db = current.s3db form_vars = form.vars if ('id' in form_vars): record_id = form_vars.id elif hasattr(form, 'record_id'): record_id = form.record_id else: return ctable = s3db.dvr_case stable = s3db.dvr_case_status left = stable.on((stable.id...
'Safe defaults for names in case the module is disabled'
@staticmethod def defaults():
dummy = S3ReusableField('dummy_id', 'integer', readable=False, writable=False) return {'dvr_case_flag_id': (lambda name='flag_id', **attr: dummy(name, **attr))}
'Safe defaults for names in case the module is disabled'
@staticmethod def defaults():
dummy = S3ReusableField('dummy_id', 'integer', readable=False, writable=False) return {'dvr_need_id': (lambda name='need_id', **attr: dummy(name, **attr))}
'Safe defaults for names in case the module is disabled'
@staticmethod def defaults():
dummy = S3ReusableField('dummy_id', 'integer', readable=False, writable=False) return {'dvr_referral_type_id': (lambda name='referral_type_id', **attr: dummy(name, **attr))}
'Onaccept routine for response statuses: - only one status can be the default @param form: the FORM'
@staticmethod def response_status_onaccept(form):
form_vars = form.vars try: record_id = form_vars.id except AttributeError: record_id = None if (not record_id): return table = current.s3db.dvr_response_status db = current.db if form_vars.get('is_default'): db((table.id != record_id)).update(is_default=False)...
'Safe defaults for names in case the module is disabled'
@staticmethod def defaults():
return {}
'Safe defaults for names in case the module is disabled'
@staticmethod def defaults():
dummy = S3ReusableField('dummy_id', 'integer', readable=False, writable=False) return {'dvr_activity_id': (lambda name='activity_id', **attr: dummy(name, **attr)), 'dvr_case_activity_id': (lambda name='case_activity_id', **attr: dummy(name, **attr))}
'Onaccept routine for case activity statuses: - only one status can be the default @param form: the FORM'
@staticmethod def case_activity_status_onaccept(form):
form_vars = form.vars try: record_id = form_vars.id except AttributeError: record_id = None if (not record_id): return if (('is_default' in form_vars) and form_vars.is_default): table = current.s3db.dvr_case_activity_status db = current.db db((table.id...
'Validate case activity form: - end date must be after start date'
@staticmethod def case_activity_onvalidation(form):
T = current.T form_vars = form.vars try: start = form_vars.start_date end = form_vars.end_date except AttributeError: return if (start and end and (end < start)): form.errors['end_date'] = T('End date must be after start date')
'Onaccept-callback for case activites: - automatically set end date when marked as completed'
@staticmethod def case_activity_onaccept(form):
db = current.db s3db = current.s3db form_vars = form.vars if ('id' in form_vars): record_id = form_vars.id elif hasattr(form, 'record_id'): record_id = form.record_id else: return atable = s3db.dvr_case_activity query = (atable.id == record_id) activity = None...
'Safe defaults for names in case the module is disabled'
@staticmethod def defaults():
return {}
'Onaccept-callback for dvr_case_effort: - inherit person_id from case_activity, unless specified in form or default @param form: the FORM'
@staticmethod def case_effort_onaccept(form):
formvars = form.vars if ('id' in formvars): record_id = formvars.id elif hasattr(form, 'record_id'): record_id = form.record_id else: record_id = None if (not record_id): return s3db = current.s3db etable = s3db.dvr_case_effort field = etable.person_id ...
'Safe defaults for names in case the module is disabled'
@staticmethod def defaults():
dummy = S3ReusableField('dummy_id', 'integer', readable=False, writable=False) return {'dvr_appointment_status_opts': {}, 'dvr_appointment_type_id': (lambda name='type_id', **attr: dummy(name, **attr))}
'Validate appointment form - Future appointments can not be set to completed - Undated appointments can not be set to completed @param form: the FORM'
@staticmethod def case_appointment_onvalidation(form):
formvars = form.vars date = formvars.get('date') status = formvars.get('status') if (str(status) == '4'): if (date is None): form.errors['date'] = current.T('Date is required when marking the appointment as completed') elif (date > current.request.utcn...
'Actions after creating/updating appointments - Update last_seen_on in the corresponding case(s) - Update the case status if configured to do so @param form: the FORM'
@staticmethod def case_appointment_onaccept(form):
formvars = form.vars if ('id' in formvars): record_id = formvars.id elif hasattr(form, 'record_id'): record_id = form.record_id else: record_id = None if (not record_id): return db = current.db s3db = current.s3db settings = current.deployment_settings ...
'Actions after deleting appointments - Update last_seen_on in the corresponding case(s) @param row: the deleted Row'
@staticmethod def case_appointment_ondelete(row):
if current.deployment_settings.get_dvr_appointments_update_last_seen_on(): table = current.s3db.dvr_case_appointment row = current.db((table.id == row.id)).select(table.deleted_fk, limitby=(0, 1)).first() if (row and row.deleted_fk): try: deleted_fk = json.loads(r...
'Safe defaults for names in case the module is disabled'
@staticmethod def defaults():
dummy = S3ReusableField('dummy_id', 'integer', readable=False, writable=False) return {'dvr_beneficiary_type_id': (lambda name='beneficiary_type_id', **attr: dummy(name, **attr))}
'Safe defaults for names in case the module is disabled'
@staticmethod def defaults():
return {}
'Safe defaults for names in case the module is disabled'
@staticmethod def defaults():
return {'dvr_allowance_status_opts': {}}
'Validate allowance form - Status paid requires paid_on date @param form: the FORM'
@staticmethod def allowance_onvalidation(form):
formvars = form.vars date = formvars.get('paid_on') status = formvars.get('status') if ((str(status) == '2') and (not date)): form.errors['paid_on'] = current.T('Date of payment required')
'Actions after creating/updating allowance information - update last_seen_on'
@staticmethod def allowance_onaccept(form):
if current.deployment_settings.get_dvr_payments_update_last_seen_on(): form_vars = form.vars if ('id' in form_vars): record_id = form_vars.id elif hasattr(form, 'record_id'): record_id = form.record_id else: record_id = None if (not record_...
'Actions after deleting allowance information - Update last_seen_on in the corresponding case(s) @param row: the deleted Row'
@staticmethod def allowance_ondelete(row):
if current.deployment_settings.get_dvr_payments_update_last_seen_on(): table = current.s3db.dvr_allowance row = current.db((table.id == row.id)).select(table.deleted_fk, limitby=(0, 1)).first() if (row and row.deleted_fk): try: deleted_fk = json.loads(row.deleted_...