def get_app_build(app_dict): domain = Domain.get_by_name(app_dict['domain']) if domain.use_cloudcare_releases: return get_latest_released_build_id(app_dict['domain'], app_dict['_id']) else: return get_latest_build_id(app_dict['domain'], app_dict['_id'])
def get_app_build(app_dict): domain = Domain.get_by_name(app_dict['domain']) if domain.use_cloudcare_releases: return ApplicationBase.get(app_dict['_id']).get_latest_app()['_id'] else: return get_latest_build_id(app_dict['domain'], app_dict['_id']) return None
def get_releases_context(request, domain, app_id): app = get_app(domain, app_id) context = get_apps_base_context(request, domain, app) can_send_sms = domain_has_privilege(domain, privileges.OUTBOUND_SMS) build_profile_access = domain_has_privilege(domain, privileges.BUILD_PROFILES) context.update({ 'release_manager': True, 'can_send_sms': can_send_sms, 'has_mobile_workers': get_doc_count_in_domain_by_class(domain, CommCareUser) > 0, 'sms_contacts': ( get_sms_autocomplete_context(request, domain)['sms_contacts'] if can_send_sms else [] ), 'build_profile_access': build_profile_access, 'application_profile_url': reverse(LanguageProfilesView.urlname, args=[domain, app_id]), 'lastest_j2me_enabled_build': CommCareBuildConfig.latest_j2me_enabled_config().label, 'fetchLimit': request.GET.get('limit', DEFAULT_FETCH_LIMIT), 'latest_build_id': get_latest_build_id(domain, app_id) }) if not app.is_remote_app(): if toggles.APP_MANAGER_V2.enabled(request.user.username) and len(app.modules) == 0: context.update({'intro_only': True}) # Multimedia is not supported for remote applications at this time. try: multimedia_state = app.check_media_state() context.update({ 'multimedia_state': multimedia_state, }) except ReportConfigurationNotFoundError: pass return context
def get_releases_context(request, domain, app_id): app = get_app(domain, app_id) context = get_apps_base_context(request, domain, app) can_send_sms = domain_has_privilege(domain, privileges.OUTBOUND_SMS) build_profile_access = domain_has_privilege(domain, privileges.BUILD_PROFILES) prompt_settings_form = PromptUpdateSettingsForm.from_app( app, request_user=request.couch_user) context.update({ 'release_manager': True, 'can_send_sms': can_send_sms, 'has_mobile_workers': get_doc_count_in_domain_by_class(domain, CommCareUser) > 0, 'sms_contacts': (get_sms_autocomplete_context( request, domain)['sms_contacts'] if can_send_sms else []), 'build_profile_access': build_profile_access, 'application_profile_url': reverse(LanguageProfilesView.urlname, args=[domain, app_id]), 'lastest_j2me_enabled_build': CommCareBuildConfig.latest_j2me_enabled_config().label, 'fetchLimit': request.GET.get('limit', DEFAULT_FETCH_LIMIT), 'latest_build_id': get_latest_build_id(domain, app_id), 'prompt_settings_url': reverse(PromptSettingsUpdateView.urlname, args=[domain, app_id]), 'prompt_settings_form': prompt_settings_form, }) if not app.is_remote_app(): context.update({ 'enable_update_prompts': app.enable_update_prompts, }) if not toggles.USER_TESTING_SIMPLIFY.enabled_for_request(request): ab = ab_tests.ABTest(ab_tests.APP_BUILDER_VIDEO, request) context.update({ 'ab_test': ab.context, 'show_video': ab.version == ab_tests.APP_BUILDER_VIDEO_ON, }) if len(app.modules) == 0: context.update({'intro_only': True}) # Multimedia is not supported for remote applications at this time. try: multimedia_state = app.check_media_state() context.update({ 'multimedia_state': multimedia_state, }) except ReportConfigurationNotFoundError: pass return context
def get_releases_context(request, domain, app_id): app = get_app(domain, app_id) can_send_sms = domain_has_privilege(domain, privileges.OUTBOUND_SMS) build_profile_access = domain_has_privilege(domain, privileges.BUILD_PROFILES) prompt_settings_form = PromptUpdateSettingsForm.from_app( app, request_user=request.couch_user) context = { 'release_manager': True, 'can_send_sms': can_send_sms, 'can_view_cloudcare': has_privilege(request, privileges.CLOUDCARE), 'has_mobile_workers': get_doc_count_in_domain_by_class(domain, CommCareUser) > 0, 'latest_released_version': get_latest_released_app_version(domain, app_id), 'sms_contacts': (get_sms_autocomplete_context( request, domain)['sms_contacts'] if can_send_sms else []), 'build_profile_access': build_profile_access, 'application_profile_url': reverse(LanguageProfilesView.urlname, args=[domain, app_id]), 'lastest_j2me_enabled_build': CommCareBuildConfig.latest_j2me_enabled_config().label, 'latest_build_id': get_latest_build_id(domain, app_id), 'prompt_settings_url': reverse(PromptSettingsUpdateView.urlname, args=[domain, app_id]), 'prompt_settings_form': prompt_settings_form, 'full_name': request.couch_user.full_name, 'can_manage_releases': can_manage_releases(request.couch_user, request.domain, app_id), 'can_edit_apps': request.couch_user.can_edit_apps(), } if not app.is_remote_app(): context.update({ 'enable_update_prompts': app.enable_update_prompts, }) if len(app.modules) == 0: context.update({'intro_only': True}) # Multimedia is not supported for remote applications at this time. try: multimedia_state = app.check_media_state() context.update({ 'multimedia_state': multimedia_state, }) except ReportConfigurationNotFoundError: pass return context
def prune_auto_generated_builds(domain, app_id): last_build_id = get_latest_build_id(domain, app_id) saved_builds = get_auto_generated_built_apps(domain, app_id) for doc in saved_builds: app = get_app(domain, doc['_id']) if app.id == last_build_id or app.is_released: continue if not app.is_auto_generated or app.copy_of != app_id or app.id == last_build_id: raise SavedAppBuildException( "Attempted to delete build that should not be deleted") app.delete()
def prune_auto_generated_builds(domain, app_id): last_build_id = get_latest_build_id(domain, app_id) saved_builds = get_auto_generated_built_apps(domain, app_id) for doc in saved_builds: app = get_app(domain, doc['_id']) if app.id == last_build_id or app.is_released: continue if not app.is_auto_generated or app.copy_of != app_id or app.id == last_build_id: raise SavedAppBuildException("Attempted to delete build that should not be deleted") app.delete_app() logger.info("Pruned build {} from domain {}".format(app.id, domain)) app.save(increment_version=False)
def get_cloudcare_app(): """ Total hack function to get direct links to the cloud care application pages """ from corehq.apps.cloudcare import api app = api.get_cloudcare_app(PACT_DOMAIN, PACT_CLOUD_APPNAME) app_id = app['_id'] pact_cloudcare = [x for x in app['modules'] if x['name']['en'] == PACT_CLOUDCARE_MODULE] forms = pact_cloudcare[0]['forms'] ret = dict((f['name']['en'], ix) for (ix, f) in enumerate(forms)) ret['app_id'] = app_id ret['build_id'] = get_latest_build_id(PACT_DOMAIN, app_id) return ret
def get_releases_context(request, domain, app_id): app = get_app(domain, app_id) can_send_sms = domain_has_privilege(domain, privileges.OUTBOUND_SMS) build_profile_access = domain_has_privilege(domain, privileges.BUILD_PROFILES) prompt_settings_form = PromptUpdateSettingsForm.from_app(app, request_user=request.couch_user) context = { 'release_manager': True, 'can_send_sms': can_send_sms, 'can_view_cloudcare': has_privilege(request, privileges.CLOUDCARE), 'has_mobile_workers': get_doc_count_in_domain_by_class(domain, CommCareUser) > 0, 'latest_released_version': get_latest_released_app_version(domain, app_id), 'sms_contacts': ( get_sms_autocomplete_context(request, domain)['sms_contacts'] if can_send_sms else [] ), 'build_profile_access': build_profile_access, 'application_profile_url': reverse(LanguageProfilesView.urlname, args=[domain, app_id]), 'lastest_j2me_enabled_build': CommCareBuildConfig.latest_j2me_enabled_config().label, 'fetchLimit': request.GET.get('limit', DEFAULT_FETCH_LIMIT), 'latest_build_id': get_latest_build_id(domain, app_id), 'prompt_settings_url': reverse(PromptSettingsUpdateView.urlname, args=[domain, app_id]), 'prompt_settings_form': prompt_settings_form, 'full_name': request.couch_user.full_name, 'can_manage_releases': can_manage_releases(request.couch_user, request.domain, app_id) } if not app.is_remote_app(): context.update({ 'enable_update_prompts': app.enable_update_prompts, }) if len(app.modules) == 0: context.update({'intro_only': True}) # Multimedia is not supported for remote applications at this time. try: multimedia_state = app.check_media_state() context.update({ 'multimedia_state': multimedia_state, }) except ReportConfigurationNotFoundError: pass return context
def get_cloudcare_app(): """ Total hack function to get direct links to the cloud care application pages """ from corehq.apps.cloudcare import api app = api.get_cloudcare_app(PACT_DOMAIN, PACT_CLOUD_APPNAME) app_id = app['_id'] pact_cloudcare = filter(lambda x: x['name']['en'] == PACT_CLOUDCARE_MODULE, app['modules']) forms = pact_cloudcare[0]['forms'] ret = dict((f['name']['en'], ix) for (ix, f) in enumerate(forms)) url_root = '/a/%(domain)s/cloudcare/apps/view/%(build_id)s/%(module_id)s/%(form_id)s/case/%(case_id)s/enter/' ret['url_root'] = url_root ret['domain'] = PACT_DOMAIN ret['app_id'] = app_id latest_build_id = get_latest_build_id(PACT_DOMAIN, app_id) if latest_build_id is not None: ret['build_id'] = latest_build_id ret['module_id'] = 0 return ret
def _fetch_build_id(domain, username, app_id): if (toggles.CLOUDCARE_LATEST_BUILD.enabled(domain) or toggles.CLOUDCARE_LATEST_BUILD.enabled(username)): return get_latest_build_id(domain, app_id) else: return get_latest_released_build_id(domain, app_id)
def get_releases_context(request, domain, app_id): app = get_app(domain, app_id) context = get_apps_base_context(request, domain, app) can_send_sms = domain_has_privilege(domain, privileges.OUTBOUND_SMS) build_profile_access = domain_has_privilege(domain, privileges.BUILD_PROFILES) prompt_settings_form = PromptUpdateSettingsForm.from_app( app, request_user=request.couch_user) is_in_mobile_experiment = toggles.MOBILE_SIGNUP_REDIRECT_AB_TEST_CONTROLLER.enabled( request.couch_user.username) is_mobile_ab = toggles.MOBILE_SIGNUP_REDIRECT_AB_TEST.enabled( request.couch_user.username, toggles.NAMESPACE_USER) if is_in_mobile_experiment: context.update({ 'mobile_experience_ab_test': { 'name': 'mobile_signups_test_march2018test', 'version': 'variation' if is_mobile_ab else 'control', }, }) context.update({ 'release_manager': True, 'can_send_sms': can_send_sms, 'can_view_cloudcare': has_privilege(request, privileges.CLOUDCARE), 'has_mobile_workers': get_doc_count_in_domain_by_class(domain, CommCareUser) > 0, 'sms_contacts': (get_sms_autocomplete_context( request, domain)['sms_contacts'] if can_send_sms else []), 'build_profile_access': build_profile_access, 'application_profile_url': reverse(LanguageProfilesView.urlname, args=[domain, app_id]), 'lastest_j2me_enabled_build': CommCareBuildConfig.latest_j2me_enabled_config().label, 'fetchLimit': request.GET.get('limit', DEFAULT_FETCH_LIMIT), 'latest_build_id': get_latest_build_id(domain, app_id), 'prompt_settings_url': reverse(PromptSettingsUpdateView.urlname, args=[domain, app_id]), 'prompt_settings_form': prompt_settings_form, 'full_name': request.couch_user.full_name, 'is_mobile_experience': (is_in_mobile_experiment and is_mobile_ab), }) if not app.is_remote_app(): context.update({ 'enable_update_prompts': app.enable_update_prompts, }) if len(app.modules) == 0: context.update({'intro_only': True}) # Multimedia is not supported for remote applications at this time. try: multimedia_state = app.check_media_state() context.update({ 'multimedia_state': multimedia_state, }) except ReportConfigurationNotFoundError: pass return context