예제 #1
0
def releases_ajax(request, domain, app_id, template='app_manager/partials/releases.html'):
    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
    })
    if not app.is_remote_app():
        # 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
    response = render(request, template, context)
    response.set_cookie('lang', encode_if_unicode(context['lang']))
    return response
예제 #2
0
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({
        'intro_only':
        len(app.modules) == 0 and toggles.APP_MANAGER_V2.enabled(domain),
        '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 and not toggles.APP_MANAGER_V2.enabled(domain),
        'lastest_j2me_enabled_build':
        CommCareBuildConfig.latest_j2me_enabled_config().label,
        'fetchLimit':
        request.GET.get('limit', DEFAULT_FETCH_LIMIT),
    })
    if not app.is_remote_app():
        # 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
예제 #3
0
def releases_ajax(request, domain, app_id, template='app_manager/v1/partials/releases.html'):
    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({
        'intro_only': len(app.modules) == 0,
        '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 and not toggles.APP_MANAGER_V2.enabled(domain),
        'lastest_j2me_enabled_build': CommCareBuildConfig.latest_j2me_enabled_config().label,
        'fetchLimit': request.GET.get('limit', DEFAULT_FETCH_LIMIT),
    })
    if not app.is_remote_app():
        # 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
    response = render(request, template, context)
    response.set_cookie('lang', encode_if_unicode(context['lang']))
    return response
예제 #4
0
def releases_ajax(request, domain, app_id, template='app_manager/partials/releases.html'):
    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,
        'lastest_j2me_enabled_build': CommCareBuildConfig.latest_j2me_enabled_config().label,
        'vellum_case_management': app.vellum_case_management,
        'fetchLimit': request.GET.get('limit', DEFAULT_FETCH_LIMIT),
    })
    if not app.is_remote_app():
        # 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
    response = render(request, template, context)
    response.set_cookie('lang', encode_if_unicode(context['lang']))
    return response
예제 #5
0
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
예제 #6
0
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
예제 #7
0
def release_manager(request, domain, app_id, template="app_manager/releases.html"):
    app = get_app(domain, app_id)
    context = get_apps_base_context(request, domain, app)
    can_send_sms = domain_has_privilege(domain, privileges.OUTBOUND_SMS)

    context.update(
        {
            "release_manager": True,
            "can_send_sms": can_send_sms,
            "sms_contacts": (get_sms_autocomplete_context(request, domain)["sms_contacts"] if can_send_sms else []),
        }
    )
    if not app.is_remote_app():
        # Multimedia is not supported for remote applications at this time.
        multimedia_state = app.check_media_state()
        context.update({"multimedia_state": multimedia_state})
    response = render(request, template, context)
    response.set_cookie("lang", encode_if_unicode(context["lang"]))
    return response
예제 #8
0
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
예제 #9
0
def release_manager(request, domain, app_id, template='app_manager/releases.html'):
    app = get_app(domain, app_id)
    context = get_apps_base_context(request, domain, app)
    can_send_sms = domain_has_privilege(domain, privileges.OUTBOUND_SMS)

    context.update({
        'release_manager': True,
        'can_send_sms': can_send_sms,
        'sms_contacts': (
            get_sms_autocomplete_context(request, domain)['sms_contacts']
            if can_send_sms else []
        ),
    })
    if not app.is_remote_app():
        # Multimedia is not supported for remote applications at this time.
        # todo remove get_media_references
        multimedia = app.get_media_references()
        context.update({
            'multimedia': multimedia,
        })
    response = render(request, template, context)
    response.set_cookie('lang', encode_if_unicode(context['lang']))
    return response
예제 #10
0
파일: views.py 프로젝트: mchampanis/core-hq
def test_autocomplete(request, domain, template="users/test_autocomplete.html"):
    context = _users_context(request, domain)
    context.update(get_sms_autocomplete_context(request, domain))
    return render_to_response(request, template, context)
예제 #11
0
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