Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(35)  |  Call(21)  |  Derive(0)  |  Import(14)

src/c/o/commcare-hq-HEAD/corehq/apps/hqwebapp/models.py   commcare-hq(Download)
from django_prbac.exceptions import PermissionDenied
from django_prbac.models import Role, UserRole
from django_prbac.utils import ensure_request_has_privilege
 
from dimagi.utils.couch.database import get_db
    def is_viewable(self):
        try:
            ensure_request_has_privilege(self._request, privileges.CLOUDCARE)
        except PermissionDenied:
            return False
    def can_access_sms(self):
        try:
            ensure_request_has_privilege(self._request, privileges.OUTBOUND_SMS)
        except PermissionDenied:
            return False
    def can_access_reminders(self):
        try:
            ensure_request_has_privilege(self._request, privileges.REMINDERS_FRAMEWORK)
            return True
        except PermissionDenied:
    def can_view_cloudcare(self):
        try:
            ensure_request_has_privilege(self._request, privileges.CLOUDCARE)
        except PermissionDenied:
            return False

src/c/o/commcare-hq-HEAD/corehq/apps/domain/decorators.py   commcare-hq(Download)
from django_prbac.exceptions import PermissionDenied
from django_prbac.models import Role
from django_prbac.utils import ensure_request_has_privilege
 
# CCHQ imports
    req.can_see_organization = True
    try:
        ensure_request_has_privilege(req, privileges.CROSS_PROJECT_REPORTS)
    except PermissionDenied:
        req.can_see_organization = False

src/c/o/commcare-hq-HEAD/corehq/apps/users/views/mobile/users.py   commcare-hq(Download)
from corehq.apps.commtrack.models import CommTrackUser
from django_prbac.exceptions import PermissionDenied
from django_prbac.utils import ensure_request_has_privilege
from soil.util import get_download_context, expose_download
 
    def can_bulk_edit_users(self):
        try:
            ensure_request_has_privilege(self.request, privileges.BULK_USER_MANAGEMENT)
        except PermissionDenied:
            return False

src/c/o/commcare-hq-HEAD/corehq/apps/domain/views.py   commcare-hq(Download)
from corehq import toggles, privileges, feature_previews
from django_prbac.exceptions import PermissionDenied
from django_prbac.utils import ensure_request_has_privilege
 
from corehq.apps.accounting.models import (
    def can_use_custom_logo(self):
        try:
            ensure_request_has_privilege(
                self.request, privileges.CUSTOM_BRANDING
            )
        try:
            ensure_request_has_privilege(
                self.request, privileges.ACCOUNTING_ADMIN)
            return False
        except PermissionDenied:

src/c/o/commcare-hq-HEAD/corehq/apps/data_interfaces/dispatcher.py   commcare-hq(Download)
from corehq.apps.users.models import Permissions
from django_prbac.exceptions import PermissionDenied
from django_prbac.utils import ensure_request_has_privilege
 
require_can_edit_data = require_permission(Permissions.edit_data)
            if report.split('.')[-1] in [DeidExportReport.__name__]:
                try:
                    ensure_request_has_privilege(request, privileges.DEIDENTIFIED_DATA)
                except PermissionDenied:
                    return False
            if report.split('.')[-1] in [ImportCases.__name__]:
                try:
                    ensure_request_has_privilege(request, privileges.BULK_CASE_MANAGEMENT)
                except PermissionDenied:
                    return False

src/c/o/commcare-hq-HEAD/corehq/apps/app_manager/views.py   commcare-hq(Download)
from django.contrib import messages
from django_prbac.exceptions import PermissionDenied
from django_prbac.utils import ensure_request_has_privilege
 
logger = logging.getLogger(__name__)
def get_app_view_context(request, app):
 
    is_cloudcare_allowed = False
    try:
        ensure_request_has_privilege(request, privileges.CLOUDCARE)
            raise Exception("App type %s does not support cloudcare" % app.get_doc_type())
        try:
            ensure_request_has_privilege(request, privileges.CLOUDCARE)
        except PermissionDenied:
            app.cloudcare_enabled = False

src/c/o/commcare-hq-HEAD/corehq/apps/users/views/__init__.py   commcare-hq(Download)
from dimagi.utils.decorators.memoized import memoized
from django_prbac.exceptions import PermissionDenied
from django_prbac.utils import ensure_request_has_privilege
import langcodes
from datetime import datetime
    def can_edit_roles(self):
        try:
            ensure_request_has_privilege(self.request, privileges.ROLE_BASED_ACCESS)
        except PermissionDenied:
            return False

src/c/o/commcare-hq-HEAD/corehq/apps/reports/standard/export.py   commcare-hq(Download)
from django.http import Http404
from django_prbac.exceptions import PermissionDenied
from django_prbac.utils import ensure_request_has_privilege
from corehq import privileges
 
    def can_view_deid(self):
        try:
            ensure_request_has_privilege(self.request, privileges.DEIDENTIFIED_DATA)
        except PermissionDenied:
            return False

src/c/o/commcare-hq-HEAD/corehq/apps/users/util.py   commcare-hq(Download)
from django.core.cache import cache
from django_prbac.exceptions import PermissionDenied
from django_prbac.utils import ensure_request_has_privilege
 
 
        return True
    try:
        ensure_request_has_privilege(request, privileges.ALLOW_EXCESS_USERS)
    except PermissionDenied:
        account = BillingAccount.get_account_by_domain(request.domain)

src/c/o/commcare-hq-HEAD/corehq/apps/reports/dispatcher.py   commcare-hq(Download)
from dimagi.utils.decorators.datespan import datespan_in_request
from django_prbac.exceptions import PermissionDenied
from django_prbac.utils import ensure_request_has_privilege
 
from corehq.apps.domain.models import Domain
    def permissions_check(self, report, request, domain=None, is_navigation_check=False):
        if is_navigation_check:
            try:
                ensure_request_has_privilege(request, privileges.CUSTOM_REPORTS)
            except PermissionDenied:

  1 | 2  Next