Checks if one of apps is listed in apps_dict
            Since apps_dict is derived from the app_list
            given by django admin, it lists only the apps
            the user can view
344285
def check_apps_permission(self, apps):
        
        for app in apps:
            if app in self.apps_dict:
                return True

        return False
1101663
def dispatch(self, *args, **kwargs):
        
        return super(GetAppListJsonView, self).dispatch(*args, **kwargs)
803229
def get_app_content_types(self):
        
        # Import this here to silence RemovedInDjango19Warning. See #15
        from django.contrib.contenttypes.models import ContentType

        return [ContentType.objects.get_for_model(c) for c
                in self.get_app_model_classes()]
1069184
def _get_current_migration_state(self, loader, apps):
        
        # Only care about applied migrations for the passed-in apps.
        apps = set(apps)
        relevant_applied = [migration for migration in loader.applied_migrations if migration[0] in apps]
        # Sort them by the most recent migration and convert to a dictionary,
        # leaving apps as keys and most recent migration as values.
        # NB: this is a dirty trick
        most_recents = dict(sorted(relevant_applied, key=lambda m: m[1]))
        # Fill in the apps with no migrations with 'zero'.
        # NOTE: Unicode Django application names are unsupported.
        most_recents = [[app, 'zero' if app not in most_recents else str(most_recents[app])] for app in apps]
        return most_recents
552061
def list_user_requests_view(request, targetUsername):
    '''
    
    '''
    if targetUsername == request.user.username:
        return list_my_requests_view(request)

    targetUser = get_object_or_404(User, username=targetUsername)
    targetProfile = get_object_or_404(UserProfile, user=targetUser)
    page_name = "{0}'s Requests".format(targetUsername)
    requests = Request.objects.filter(owner=targetProfile).exclude(
        ~Q(owner__user=request.user), private=True,
        )
    return render_to_response('list_requests.html', {
        'page_name': page_name,
        'requests': requests,
        'targetUsername': targetUsername,
        }, context_instance=RequestContext(request))
909794
def has_apps(names, check_platform=True):
        """"""
        if check_platform:
            Environment._platform_is_windows()
        for name in names:
            yield Environment.has_app(str(name), check_platform=False)
929044
def has_permission_to_view(page, user):
    
    if page.permissions.count() == 0:
        return True
    for perm in page.permissions.all():
        perm_label = '%s.%s' % (perm.content_type.app_label, perm.codename)
        if user.has_perm(perm_label):
            return True
    return False
1043659
def app_list(**kwargs):
    
    ctx = Context(**kwargs)
    ctx.execute_action('app:list', **{
        'storage': ctx.repo.create_secure_service('storage'),
    })
840963
def get_app_modules(self, apps):
        
        modules = getattr(self, "_modules", [])

        if not modules:
            from django.utils.module_loading import module_has_submodule

            # Try importing a modules from the module package
            package_string = '.'.join(['leonardo', 'module'])

            for app in apps:
                exc = '...'
                try:
                    # check if is not full app
                    _app = import_module(app)
                except Exception as e:
                    _app = False
                    exc = e

                if module_has_submodule(
                        import_module(package_string), app) or _app:
                    if _app:
                        mod = _app
                    else:
                        mod = import_module('.{0}'.format(app), package_string)
                    if mod:
                        modules.append(mod)
                        continue

                warnings.warn('%s was skipped because %s ' % (app, exc))

            self._modules = modules
        return self._modules
504282
def index
      @app_reviews = review_klass.approved
      @app_reviews = @app_reviews.limit(params[:limit]) if params[:limit]
      @app_reviews = @app_reviews.skip(params[:offset]) if params[:offset]
      @app_reviews = @app_reviews.order_by(params[:order_by]) if params[:order_by]
      @app_reviews = @app_reviews.where(params[:where]) if params[:where]

      @app_reviews = scope_app_reviews

      @app_reviews = @app_reviews.all.fetch
      response.headers['X-Total-Count'] = @app_reviews.metadata[:pagination][:count]
    end
738993
def is_model_registered(app_label, model_name):
    
    try:
        apps.get_registered_model(app_label, model_name)
    except LookupError:
        return False
    else:
        return True
611068
def _list_view(self, model, **kwargs):
        
        from uliweb import request

        #add download fields process
        fields = kwargs.pop('fields', None)
        meta = kwargs.pop('meta', 'Table')
        if 'download' in request.GET:
            if 'download_fields' in kwargs:
                fields = kwargs.pop('download_fields', fields)
            if 'download_meta' in kwargs:
                meta = kwargs.pop('download_meta')
            else:
                if hasattr(model, 'Download'):
                    meta = 'Download'
                else:
                    meta = meta

        view = functions.ListView(model, fields=fields, meta=meta, **kwargs)
        return view
830034
def _get_user_allowed_fields(self):
        
        model_name = self.Meta.model.__name__.lower()
        app_label = self.Meta.model._meta.app_label
        full_model_name = '%s.%s' % (app_label, model_name)
        permissions = self.cached_allowed_fields.get(full_model_name)

        if not permissions:
            permissions = FieldPermission.objects.filter(
                user_field_permissions__user=self.user,
                content_type__model=model_name,
                content_type__app_label=app_label
            )
            self.cached_allowed_fields[full_model_name] = permissions
        return permissions
1259668
def op_list_apps(self):
        
        self.logger.info('Listing known applications ...')
        apps = self.get_apps()
        for app in apps:
            self.logger.info('Found `%s`' % app)
        else:
            self.logger.info('\nDONE. No applications found in `%s` directory.\n' % APPS_DIRNAME)
        return apps
610555
def autodiscover(blacklist=[]):
    
    import imp
    from django.conf import settings
    try:
        from importlib import import_module
    except ImportError:
        # Django < 1.9 and Python < 2.7
        from django.utils.importlib import import_module

    blacklist.append('admin_tools.dashboard')
    blacklist.append('admin_tools.menu')
    blacklist.append('admin_tools.theming')

    for app in settings.INSTALLED_APPS:
        # skip blacklisted apps
        if app in blacklist:
            continue

        # try to import the app
        try:
            app_path = import_module(app).__path__
        except AttributeError:
            continue

        # try to find a app.dashboard module
        try:
            imp.find_module('dashboard', app_path)
        except ImportError:
            continue

        # looks like we found it so import it !
        import_module('%s.dashboard' % app)
52576
def apps():
    '''
    
    '''
    response = salt.utils.http.query(
        "{0}/v2/apps".format(_base_url()),
        decode_type='json',
        decode=True,
    )
    return {'apps': [app['id'] for app in response['dict']['apps']]}
1370821
def all_requests_view(request):
    '''
    
    '''
    # Pseudo-dictionary, actually a list with items of form
    # (request_type.name.title(), number_of_type_requests, name, enabled,
    # glyphicon)
    types_dict = list()
    for request_type in RequestType.objects.all():
        requests = Request.objects.filter(request_type=request_type)
        # Hide the count for private requests
        if not request_type.managers.filter(incumbent__user=request.user):
            requests = requests.exclude(
                ~Q(owner__user=request.user), private=True,
                )

        number_of_requests = requests.count()
        types_dict.append((
            request_type.name.title(), number_of_requests,
            request_type.url_name, request_type.enabled,
            request_type.glyphicon,
            ))
    return render_to_response('all_requests.html', {
        'page_name': "Archives - All Requests",
        'types_dict': types_dict,
        }, context_instance=RequestContext(request))