desc stringlengths 3 26.7k | decl stringlengths 11 7.89k | bodies stringlengths 8 553k |
|---|---|---|
'Group Tabs on Projects into a single \'Details\' page'
| def get_project_details_tab(self):
| return self.project.get('details_tab', False)
|
'Link Activities to Events'
| def get_project_event_activities(self):
| return self.project.get('event_activities', False)
|
'Link Projects to Events'
| def get_project_event_projects(self):
| return self.project.get('event_projects', False)
|
'Use Goals in Projects'
| def get_project_goals(self):
| return self.project.get('goals', False)
|
'Use Hazards in DRR Projects'
| def get_project_hazards(self):
| use_hazards = self.project.get('hazards')
if (use_hazards is None):
use_hazards = self.get_project_mode_drr()
return use_hazards
|
'Use HFA Priorities in DRR Projects'
| def get_project_hfa(self):
| use_hfa = self.project.get('hfa')
if (use_hfa is None):
use_hfa = self.get_project_mode_drr()
return use_hfa
|
'Use Indicators in Projects'
| def get_project_indicators(self):
| return self.project.get('indicators', False)
|
'Use Indicator Criteria in Projects'
| def get_project_indicator_criteria(self):
| return self.project.get('indicator_criteria', False)
|
'Use Activity Statuses to build Project Status (instead of Indicator Data)'
| def get_project_status_from_activities(self):
| return self.project.get('status_from_activities', False)
|
'Use Milestones in Projects & Tasks'
| def get_project_milestones(self):
| return self.project.get('milestones', False)
|
'Use Outcomes in Projects'
| def get_project_outcomes(self):
| return self.project.get('outcomes', False)
|
'Use Outputs in Projects'
| def get_project_outputs(self):
| return self.project.get('outputs', 'inline')
|
'Whether the Project Planning data should CASCADE ondelete or RESTRICT
NB This cannot be edited on the fly, or vary by context
It needs defining before the database is created.'
| def get_project_planning_ondelete(self):
| return self.project.get('planning_ondelete', 'CASCADE')
|
'Link Activities & Tasks to Projects'
| def get_project_projects(self):
| return self.project.get('projects', False)
|
'Use Programmes in Projects'
| def get_project_programmes(self):
| return self.project.get('programmes', False)
|
'Use Budgets in Programmes'
| def get_project_programme_budget(self):
| return self.project.get('programme_budget', False)
|
'Use Sectors in Projects'
| def get_project_sectors(self):
| return self.project.get('sectors', True)
|
'Use Themes in 3W Projects'
| def get_project_themes(self):
| return self.project.get('themes', False)
|
'Use Theme Percentages in Projects'
| def get_project_theme_percentages(self):
| return self.project.get('theme_percentages', False)
|
'Use Multiple Budgets in Projects'
| def get_project_multiple_budgets(self):
| return self.project.get('multiple_budgets', False)
|
'Use Multiple Organisations in Projects'
| def get_project_multiple_organisations(self):
| return self.project.get('multiple_organisations', False)
|
'Organisation roles within projects'
| def get_project_organisation_roles(self):
| T = current.T
return self.project.get('organisation_roles', {1: T('Lead Implementer'), 2: T('Partner'), 3: T('Donor')})
|
'The lead role of organisations within projects'
| def get_project_organisation_lead_role(self):
| return self.project.get('organisation_lead_role', 1)
|
'Use Tags in Tasks'
| def get_project_task_tag(self):
| return self.project.get('task_tag', False)
|
'The list of options for the Status of a Task.
NB Whilst the list can be customised, doing so makes it harder to
do synchronization.
There are also hard-coded elements within XSL & styling of
project_task_list_layout which will break if these are changed.
Best bet is simply to comment statuses that you don\'t wish to u... | def get_project_task_status_opts(self):
| T = current.T
return self.project.get('task_status_opts', {1: T('Draft'), 2: T('New'), 3: T('Assigned'), 4: T('Feedback'), 5: T('Blocked'), 6: T('On Hold'), 7: T('Canceled'), 8: T('Duplicate'), 9: T('Ready'), 10: T('Verified'), 11: T('Reopened'), 12: T('Completed')})
|
'The list of options for the Priority of a Task.
NB Whilst the list can be customised, doing so makes it harder to
do synchronization.
There are also hard-coded elements within XSL & styling of
project_task_list_layout which will break if these are changed.
Best bet is simply to comment statuses that you don\'t wish to... | def get_project_task_priority_opts(self):
| T = current.T
return self.project.get('task_priority_opts', {1: T('Urgent'), 2: T('High'), 3: T('Normal'), 4: T('Low')})
|
'Whether to use hours logging for tasks'
| def get_project_task_time(self):
| return self.project.get('task_time', True)
|
'"My Open Tasks" to include team tasks'
| def get_project_my_tasks_include_team_tasks(self):
| return self.project.get('my_tasks_include_team_tasks', False)
|
'The Types of Request which can be made.
Select one or more from:
* People
* Stock
* Other
tbc: Assets, Shelter, Food'
| def get_req_req_type(self):
| return self.req.get('req_type', ('Stock', 'People', 'Other'))
|
'Provide a Copy button for Requests?'
| def get_req_copyable(self):
| return self.req.get('copyable', False)
|
'Do we allow creation of recurring requests?'
| def get_req_recurring(self):
| return self.req.get('recurring', True)
|
'Whether the User Account logging the Request is normally the Requester'
| def get_req_requester_is_author(self):
| return self.req.get('requester_is_author', True)
|
'Whether the Requester has to be a staff of the site making the Request'
| def get_req_requester_from_site(self):
| return self.req.get('requester_from_site', False)
|
'Whether to set the Requester as being an HR for the Site if no HR record yet & as Site contact if none yet exists'
| def get_req_requester_to_site(self):
| return self.req.get('requester_to_site', False)
|
'Whether Request Date should be manually editable'
| def get_req_date_writable(self):
| return self.req.get('date_writable', True)
|
'Whether Request Status should be manually editable'
| def get_req_status_writable(self):
| return self.req.get('status_writable', True)
|
'Whether Item Quantities should be manually editable'
| def get_req_item_quantities_writable(self):
| return self.req.get('item_quantities_writable', False)
|
'Whether People Quantities should be manually editable'
| def get_req_skill_quantities_writable(self):
| return self.req.get('skill_quantities_writable', False)
|
'Do we show pack values in Requests?'
| def get_req_pack_values(self):
| return self.req.get('pack_values', True)
|
'Can a Request have multiple line items?
- e.g. ICS says that each request should be just for items of a single Type'
| def get_req_multiple_req_items(self):
| return self.req.get('multiple_req_items', True)
|
'Whether Requests module should use inline forms for Items/Skills'
| def get_req_inline_forms(self):
| return self.req.get('inline_forms', True)
|
'Whether a Requester is prompted to match each line item in an Item request'
| def get_req_prompt_match(self):
| return self.req.get('prompt_match', True)
|
'Whether there is a Commit step in Requests Management'
| def get_req_use_commit(self):
| return self.req.get('use_commit', True)
|
'Whether Skills Requests should be Committed with Named Indviduals
or just Anonymous Skill
@ToDo: Make this do something'
| def get_req_commit_people(self):
| return self.req.get('commit_people', False)
|
'Whether Donations should have a Value field'
| def get_req_commit_value(self):
| return self.req.get('commit_value', False)
|
'Whether to allow Donations to be made without a matching Request'
| def get_req_commit_without_request(self):
| return self.req.get('commit_without_request', False)
|
'Whether the User Account logging the Commitment is normally the Committer'
| def get_req_committer_is_author(self):
| return self.req.get('committer_is_author', True)
|
'Should Requests ask whether Security is required?'
| def get_req_ask_security(self):
| return self.req.get('ask_security', False)
|
'Should Requests ask whether Transportation is required?'
| def get_req_ask_transport(self):
| return self.req.get('ask_transport', False)
|
'Should Requests for Items ask for Purpose?'
| def get_req_items_ask_purpose(self):
| return self.req.get('items_ask_purpose', True)
|
'To restrict adding new commits to the Completed commits.'
| def get_req_restrict_on_complete(self):
| return self.req.get('req_restrict_on_complete', False)
|
'Whether Airport code is unique'
| def get_transport_airport_code_unique(self):
| return self.transport.get('airport_code_unique', False)
|
'Whether Heliport code is unique'
| def get_transport_heliport_code_unique(self):
| return self.transport.get('heliport_code_unique', False)
|
'Whether Seaport code is unique'
| def get_transport_seaport_code_unique(self):
| return self.transport.get('seaport_code_unique', False)
|
'A list of xform resources
Item formats:
"tablename"
("Title", "tablename")
("Title", "tablename", options)
Format for options:
{c=controller, ...use this controller for form handling
f=function, ...use this function for form handling
vars=vars, ...add these vars to the download URL
title=t... | def get_xforms_resources(self):
| return self.xforms.get('resources')
|
'Template-specific frontpage configuration options'
| def get_frontpage(self, key=None, default=None):
| if key:
return self.frontpage.get(key, default)
else:
return default
|
'Resolve option profile (e.g. prepopulate)
@param options: the template options as dict like:
{"name": ("item1", "item2",...),...},
The "mandatory" list will always be
added, while the "default" list will
be added only if setting is None.
@param setting: the active setting, as single item
or tuple/list, items with a "t... | def resolve_profile(self, options, setting, resolved=None):
| default = (resolved is None)
if default:
resolved = set()
seen = resolved.add
resolve = self.resolve_profile
result = []
def append(item):
if (item not in resolved):
seen(item)
if (isinstance(item, basestring) and (item[:9] == 'template:')):
... |
'Resolve a "lazy" setting: when the config setting is callable,
call it once and store the result. A callable setting takes
the default value as parameter.
This method allows settings to depend on user authentication
(e.g. org-dependent variations), or involve database lookups,
which is only possible /after/ the initia... | def __lazy(self, subset, key, default=None):
| setting = self[subset].get(key, default)
if callable(setting):
_key = ('%s_%s' % (subset, key))
if (_key not in self._lazy_unwrapped):
self[subset][key] = setting = setting(default)
self._lazy_unwrapped.append(_key)
return setting
|
'Add the lower case and no-period version of the string arguments to the set.
Returns ``self`` for chaining.'
| def add(self, *strings):
| [self.elements.add(lc(s)) for s in strings]
return self
|
'Remove the lower case and no-period version of the string arguments from the set.
Returns ``self`` for chaining.'
| def remove(self, *strings):
| [self.elements.remove(lc(s)) for s in strings if (lc(s) in self.elements)]
return self
|
'HumanName instances are equal to other objects whose
lower case unicode representation is the same.'
| def __eq__(self, other):
| return (u(self).lower() == u(other).lower())
|
'Return the parsed name as a dictionary of its attributes.
:param bool include_empty: Include keys in the dictionary for empty name attributes.
:rtype: dict
.. doctest::
>>> name = HumanName("Bob Dole")
>>> name.as_dict()
{u\'last\': u\'Dole\', u\'suffix\': u\'\', u\'title\': u\'\', u\'middle\': u\'\', u\'nickname\': u... | def as_dict(self, include_empty=True):
| d = {}
for m in self._members:
if include_empty:
d[m] = getattr(self, m)
else:
val = getattr(self, m)
if val:
d[m] = val
return d
|
'The person\'s titles. Any string of consecutive pieces in
:py:mod:`~nameparser.config.titles` or :py:mod:`~nameparser.config.conjunctions`
at the beginning of :py:attr:`full_name`.'
| @property
def title(self):
| return u' '.join(self.title_list)
|
'The person\'s first name. The first name piece after any known
:py:attr:`title` pieces parsed from :py:attr:`full_name`.'
| @property
def first(self):
| return u' '.join(self.first_list)
|
'The person\'s middle names. All name pieces after the first name and before
the last name parsed from :py:attr:`full_name`.'
| @property
def middle(self):
| return u' '.join(self.middle_list)
|
'The person\'s last name. The last name piece parsed from
:py:attr:`full_name`.'
| @property
def last(self):
| return u' '.join(self.last_list)
|
'The persons\'s suffixes. Pieces at the end of the name that are found in
:py:mod:`~nameparser.config.suffixes`, or pieces that are at the end
of comma separated formats, e.g. "Lastname, Title Firstname Middle[,] Suffix
[, Suffix]" parsed from :py:attr:`full_name`.'
| @property
def suffix(self):
| return u', '.join(self.suffix_list)
|
'The person\'s nicknames. Any text found inside of quotes (``""``) or
parenthesis (``()``)'
| @property
def nickname(self):
| return u' '.join(self.nickname_list)
|
'Is in the :py:data:`~nameparser.config.titles.TITLES` set.'
| def is_title(self, value):
| return (lc(value) in self.C.titles)
|
'Is in the conjuctions set or :py:func:`is_an_initial()`.'
| def is_conjunction(self, piece):
| return ((lc(piece) in self.C.conjunctions) and (not self.is_an_initial(piece)))
|
'Is in the prefixes set or :py:func:`is_an_initial()`.'
| def is_prefix(self, piece):
| return ((lc(piece) in self.C.prefixes) and (not self.is_an_initial(piece)))
|
'Is in the suffixes set or :py:func:`is_an_initial()`.'
| def is_suffix(self, piece):
| return ((lc(piece).replace(u'.', u'') in self.C.suffixes) and (not self.is_an_initial(piece)))
|
'Return True if all pieces are suffixes.'
| def are_suffixes(self, pieces):
| for piece in pieces:
if (not self.is_suffix(piece)):
return False
return True
|
'Is not a known title, suffix or prefix. Just first, middle, last names.'
| def is_rootname(self, piece):
| return ((lc(piece) not in self.C.suffixes_prefixes_titles) and (not self.is_an_initial(piece)))
|
'Matches the ``initial`` regular expression in
:py:data:`~nameparser.config.regexes.REGEXES`.'
| def is_an_initial(self, value):
| return (self.C.regexes.initial.match(value) or False)
|
'The name string to be parsed.'
| @property
def full_name(self):
| return self._full_name
|
'This method happens at the beginning of the :py:func:`parse_full_name` before
any other processing of the string aside from unicode normalization, so
it\'s a good place to do any custom handling in a subclass.
Runs :py:func:`parse_nicknames`.'
| def pre_process(self):
| self.parse_nicknames()
|
'This happens at the end of the :py:func:`parse_full_name` after
all other processing has taken place. Runs :py:func:`handle_firstnames`.'
| def post_process(self):
| self.handle_firstnames()
|
'The content of parenthesis or double quotes in the name will
be treated as nicknames. This happens before any other
processing of the name.'
| def parse_nicknames(self):
| re_nickname = self.C.regexes.nickname
if re_nickname.search(self._full_name):
self.nickname_list = re_nickname.findall(self._full_name)
self._full_name = re_nickname.sub(u'', self._full_name)
|
'If there are only two parts and one is a title, assume it\'s a last name
instead of a first name. e.g. Mr. Johnson. Unless it\'s a special title
like "Sir", then when it\'s followed by a single name that name is always
a first name.'
| def handle_firstnames(self):
| if (self.title and (len(self) == 2) and (not (lc(self.title) in self.C.first_name_titles))):
(self.last, self.first) = (self.first, self.last)
|
'The main parse method for the parser. This method is run upon assignment to the
:py:attr:`full_name` attribute or instantiation.
Basic flow is to hand off to :py:func:`pre_process` to handle nicknames. It
then splits on commas and chooses a code path depending on the number of commas.
:py:func:`parse_pieces` then spli... | def parse_full_name(self):
| self.title_list = []
self.first_list = []
self.middle_list = []
self.last_list = []
self.suffix_list = []
self.nickname_list = []
self.unparsable = True
if (not isinstance(self._full_name, text_type)):
self._full_name = u(self._full_name, self.ENCODING)
self.pre_process()
... |
'Split parts on spaces and remove commas, join on conjunctions and
lastname prefixes.
:param list parts: name part strings from the comma split
:param int additional_parts_count:
if the comma format contains other parts, we need to know
how many there are to decide if things should be considered a conjunction.
:return:... | def parse_pieces(self, parts, additional_parts_count=0):
| tmp = []
for part in parts:
tmp += [x.strip(u' ,') for x in part.split(u' ')]
return self.join_on_conjunctions(tmp, additional_parts_count)
|
'Join conjunctions to surrounding pieces, e.g.:
[\'Mr. and Mrs.\'], [\'King of the Hill\'], [\'Jack and Jill\'], [\'Velasquez y Garcia\']
:param list pieces: name pieces strings after split on spaces
:param int additional_parts_count:
:return: new list with piece next to conjunctions merged into one piece with spaces i... | def join_on_conjunctions(self, pieces, additional_parts_count=0):
| length = (len(pieces) + additional_parts_count)
if (length < 3):
return pieces
for conj in filter(self.is_conjunction, pieces[::(-1)]):
if ((len(conj) == 1) and ((len(list(filter(self.is_rootname, pieces))) + additional_parts_count) < 4)):
continue
try:
i = pi... |
'The HumanName class can try to guess the correct capitalization
of name entered in all upper or lower case. It will not adjust
the case of names entered in mixed case.
**Usage**
.. doctest:: capitalize
>>> name = HumanName(\'bob v. de la macdole-eisenhower phd\')
>>> name.capitalize()
>>> unicode(name)
u\'Bob V. de la... | def capitalize(self):
| name = u(self)
if (not ((name == name.upper()) or (name == name.lower()))):
return
self.title_list = self.cap_piece(self.title).split(u' ')
self.first_list = self.cap_piece(self.first).split(u' ')
self.middle_list = self.cap_piece(self.middle).split(u' ')
self.last_list = self.c... |
'Override superclass method to resolve against the pr_person
resource instead of the master resource (=hrm_human_resource)
@param resource: the resource
@return: a tuple (self, None, Field instance)'
| def resolve(self, resource):
| selector = self.selector
person_resource = current.s3db.resource('pr_person', components=[selector])
return super(S3SQLHRPersonLink, self).resolve(person_resource)
|
'Override superclass method to map the master record to the
corresponding pr_person record (only required when called
from the form handler)
@param resource: the resource the record belongs to
@param record_id: the record ID
@return: the value for the input field that corresponds
to the specified record.'
| def extract(self, resource, record_id):
| if (resource.tablename == 'hrm_human_resource'):
s3db = current.s3db
table = resource.table
query = (table._id == record_id)
master = current.db(query).select(table.person_id, limitby=(0, 1)).first()
if (not master):
raise KeyError('Record not found')
... |
'Override superclass method to use the person_id in
the master record instead of the master_id.
@param form: the master form
@param master_id: the ID of the master record in the form
@param format: the data format extension (for audit)'
| def accept(self, form, master_id=None, format=None):
| s3db = current.s3db
htable = s3db.hrm_human_resource
query = (htable._id == master_id)
master = current.db(query).select(htable.person_id, limitby=(0, 1)).first()
if (not master):
return False
person_id = master.person_id
return super(S3SQLHRPersonLink, self).accept(form, master_id=p... |
'Entry point for REST API
@param r: the request (S3Request)
@param attr: REST controller parameters'
| def apply_method(self, r, **attr):
| if (r.record and (r.representation in ('html', 'aadata'))):
T = current.T
db = current.db
s3db = current.s3db
auth = current.auth
is_admin = auth.s3_has_role('ADMIN')
accessible = auth.s3_accessible_query
profile_widgets = []
add_widget = profile_widge... |
'Data table row actions'
| @staticmethod
def dt_row_actions(c, f):
| return (lambda r, list_id: [{'label': current.deployment_settings.get_ui_label_update(), 'url': URL(c=c, f=f, args=['[id]', 'update']), '_class': 'action-btn edit'}])
|
'Parse Feeds into the CMS Module'
| @staticmethod
def parse_rss(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):
return
po... |
'Custom Modules Menu'
| @classmethod
def menu_modules(cls):
| AUTHENTICATED = current.session.s3.system_roles.AUTHENTICATED
INDIVIDUALS = current.deployment_settings.get_hrm_staff_label()
return [MM('Dashboard', c='default', f='index', args=['dashboard'], restrict=[AUTHENTICATED]), MM('Contacts', link=False, restrict=[AUTHENTICATED])(MM('Networks', c='org', f='group')... |
'Help Menu'
| @classmethod
def menu_help(cls, **attr):
| ADMIN = current.auth.get_system_roles().ADMIN
menu_help = MM('Help', c='default', f='help', link=False, **attr)(MM('User Guide', f='help'), MM('Contact us', f='contact'))
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 =... |
'HRM / Human Resources Management'
| @staticmethod
def hrm():
| s3 = current.session.s3
ADMIN = s3.system_roles.ADMIN
AUTHENTICATED = s3.system_roles.AUTHENTICATED
INDIVIDUALS = current.deployment_settings.get_hrm_staff_label()
return M()(M('Networks', c='org', f='group')(M('Search'), M('Create', m='create')), M('Groups', c='hrm', f='group')(M('Search'), M('Crea... |
'ORG / Organization Registry'
| def org(self):
| if (not current.auth.is_logged_in()):
return None
else:
request = current.request
function = request.function
if (function in ('facility', 'facility_type')):
ADMIN = current.session.s3.system_roles.ADMIN
if ((function == 'facility') and (request.args(0) ==... |
'Person Registry'
| def pr(self):
| if (not current.auth.is_logged_in()):
return None
else:
return self.hrm()
|
'Remove Task from subscription filter'
| def remove_task_subscription(self, task_id):
| db = current.db
s3db = current.s3db
subscription = self.subscription
rfilter = self.rfilter
ids = subscription['get_vars'][rfilter].split(',')
if (task_id in ids):
ids.remove(task_id)
if (len(ids) == 0):
stable = s3db.pr_subscription
db((stable.id == subscription['id'... |
'Add Task to subscription filter'
| def add_task_subscription(self, task_id):
| subscription = self.subscription
rfilter = self.rfilter
if subscription['get_vars'].get(rfilter, None):
ids = subscription['get_vars'][rfilter]
ids += (',' + task_id)
else:
ids = task_id
sfilter = [[rfilter, ids], self.exclude]
subscription['filters'] = json.dumps(sfilter... |
'Get current subscription settings'
| def get_subscription(self):
| db = current.db
s3db = current.s3db
settings = current.deployment_settings
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(que... |
'Update subscription settings'
| def update_subscription(self):
| db = current.db
s3db = current.s3db
subscription = self.subscription
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_... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.