def get_initial_values(self): initial = { 'keyword': self.keyword.keyword, 'description': self.keyword.description, 'delimiter': self.keyword.delimiter, 'override_open_sessions': self.keyword.override_open_sessions, 'sender_content_type': NO_RESPONSE, } is_case_filter = "CommCareCase" in self.keyword.initiator_doc_type_filter is_user_filter = "CommCareUser" in self.keyword.initiator_doc_type_filter if is_case_filter and not is_user_filter: initial.update({ 'allow_keyword_use_by': 'cases', }) elif is_user_filter and not is_case_filter: initial.update({ 'allow_keyword_use_by': 'users', }) for action in self.keyword.keywordaction_set.all(): if action.action == KeywordAction.ACTION_STRUCTURED_SMS: if self.process_structured_message: initial.update({ 'structured_sms_app_and_form_unique_id': get_combined_id(action.app_id, action.form_unique_id), 'use_custom_delimiter': self.keyword.delimiter is not None, 'use_named_args_separator': action.named_args_separator is not None, 'use_named_args': action.use_named_args, 'named_args_separator': action.named_args_separator, 'named_args': [{ "name": k, "xpath": v } for k, v in action.named_args.items()], }) elif action.recipient == KeywordAction.RECIPIENT_SENDER: initial.update({ 'sender_content_type': action.action, 'sender_message': action.message_content, 'sender_app_and_form_unique_id': get_combined_id(action.app_id, action.form_unique_id), }) else: initial.update({ 'other_recipient_type': action.recipient, 'other_recipient_id': action.recipient_id, 'other_recipient_content_type': action.action, 'other_recipient_message': action.message_content, 'other_recipient_app_and_form_unique_id': get_combined_id(action.app_id, action.form_unique_id), }) return initial
def get_visit_scheduler_forms(domain, timestamp): """ The timestamp is set once at the beginning of each loading of the page, so that this result is only calculated once per page load. """ result = [] for app_id in get_app_ids_in_domain(domain): app = get_latest_released_app(domain, app_id) if app and not app.is_deleted() and not app.is_remote_app(): for module in app.get_modules(): for form in module.get_forms(): if isinstance(form, AdvancedForm) and form.schedule and form.schedule.enabled: result.append({ 'id': get_combined_id(app_id, form.unique_id), 'text': form.full_path_name, }) return result