Пример #1
0
def get_allowed_models():
    models = ContentType.objects.all()
    if getattr(settings, 'REPORT_BUILDER_INCLUDE', False):
        all_model_names = []
        additional_models = []
        for element in settings.REPORT_BUILDER_INCLUDE:
            split_element = element.split('.')
            if len(split_element) == 2:
                additional_models.append(
                    models.filter(app_label=split_element[0],
                                  model=split_element[1]))
            else:
                all_model_names.append(element)
        models = models.filter(model__in=all_model_names)
        for additional_model in additional_models:
            models = models | additional_model
    if getattr(settings, 'REPORT_BUILDER_EXCLUDE', False):
        all_model_names = []
        for element in settings.REPORT_BUILDER_EXCLUDE:
            split_element = element.split('.')
            if len(split_element) == 2:
                models = models.exclude(app_label=split_element[0],
                                        model=split_element[1])
            else:
                all_model_names.append(element)
        models = models.exclude(model__in=all_model_names)
    return models
Пример #2
0
 def _get_allowed_models():
     models = ContentType.objects.all()
     if getattr(settings, 'REPORT_BUILDER_INCLUDE', False):
         models = models.filter(name__in=settings.REPORT_BUILDER_INCLUDE)
     if getattr(settings, 'REPORT_BUILDER_EXCLUDE', False):
         models = models.exclude(name__in=settings.REPORT_BUILDER_EXCLUDE)
     return models
Пример #3
0
 def _get_allowed_models():
     models = ContentType.objects.all()
     if getattr(settings, 'REPORT_BUILDER_INCLUDE', False):
         models = models.filter(name__in=settings.REPORT_BUILDER_INCLUDE)
     if getattr(settings, 'REPORT_BUILDER_EXCLUDE', False):
         models = models.exclude(name__in=settings.REPORT_BUILDER_EXCLUDE)
     return models
Пример #4
0
	def get_models():
		_models = ContentType.objects.all()
		if getattr(settings, 'REPORT_MODEL_INCLUDE', False):
		    _models = models.filter(name__in=settings.REPORT_MODEL_INCLUDE) #pragma: no cover
		if getattr(settings, 'REPORT_MODEL_EXCLUDE', False):
			_models = models.exclude(name__in=settings.REPORT_MODEL_EXCLUDE) #pragma: no cover
		return _models
 def _get_allowed_models():
     # TODO: make a model to handle this. To only permit models. The
     # rest is forbiden
     models = ContentType.objects.all()
     if getattr(sett, 'QUERYSET_REPORTER_INCLUDE', False):
         models = models.filter(name__in=sett.QUERYSET_REPORTER_INCLUDE)
     if getattr(sett, 'QUERYSET_REPORTER_EXCLUDE', False):
         models = models.exclude(name__in=sett.QUERYSET_REPORTER_EXCLUDE)
     return models
Пример #6
0
def get_allowed_models():
    models = ContentType.objects.all()
    if getattr(settings, 'REPORT_BUILDER_INCLUDE', False):
        all_model_names = []
        additional_models = []
        for element in settings.REPORT_BUILDER_INCLUDE:
            split_element = element.split('.')
            if len(split_element) == 2:
                additional_models.append(models.filter(app_label=split_element[0], model=split_element[1]))
            else:
                all_model_names.append(element)
        models = models.filter(model__in=all_model_names)
        for additional_model in additional_models:
            models = models | additional_model
    if getattr(settings, 'REPORT_BUILDER_EXCLUDE', False):
        all_model_names = []
        for element in settings.REPORT_BUILDER_EXCLUDE:
            split_element = element.split('.')
            if len(split_element) == 2:
                models = models.exclude(app_label=split_element[0], model=split_element[1])
            else:
                all_model_names.append(element)
        models = models.exclude(model__in=all_model_names)
    return models