Beispiel #1
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
Beispiel #2
0
def toggle_release_restriction_by_app_profile(request, domain, restriction_id):
    if not toggles.RELEASE_BUILDS_PER_PROFILE.enabled_for_request(request):
        return HttpResponseForbidden()
    release = LatestEnabledBuildProfiles.objects.get(id=restriction_id)
    if not release:
        return HttpResponseBadRequest()
    if not can_manage_releases(request.couch_user, domain, release.app_id):
        return JsonResponse(data={
            'message': _("You don't have permission to set restriction for this application")})
    if request.POST.get('active') == 'false':
        return _update_release_restriction_by_app_profile(release, restriction_id, active=False)
    elif request.POST.get('active') == 'true':
        return _update_release_restriction_by_app_profile(release, restriction_id, active=True)
Beispiel #3
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