diff options
Diffstat (limited to 'ishtar_common/models.py')
| -rw-r--r-- | ishtar_common/models.py | 17 | 
1 files changed, 16 insertions, 1 deletions
| diff --git a/ishtar_common/models.py b/ishtar_common/models.py index 8542c8963..f46331eb5 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -406,7 +406,7 @@ class HistoryModel(models.Model):          if not models.endswith(".models"):              models += ".models"          models = import_module(models) -        model = getattr(models, self.__class__.__name__[len("Historical") :]) +        model = getattr(models, self.__class__.__name__[len("Historical"):])          field = getattr(model, key)          if hasattr(field, "rel"):              field = field.rel @@ -3456,6 +3456,21 @@ class ProfileType(GeneralType):          ordering = ("label",)      ADMIN_SECTION = _("Account") +    def get_filters(self, model_class): +        """ +        Return (exclude (True if exclude, False for include), key list) +        """ +        q = self.filtered_sheets.filter( +            content_type=ContentType.objects.get_for_model(model_class) +        ) +        if not q.count(): +            return (None, None) +        filter_sheet = q.all()[0] +        return ( +            filter_sheet.exclude_or_include == "E", +            list(filter_sheet.filters.values_list("key", flat=True)) +        ) +      def clean_groups(self):          """          Remove "own" groups if generic group is associated | 
