diff options
Diffstat (limited to 'ishtar_common/models.py')
-rw-r--r-- | ishtar_common/models.py | 61 |
1 files changed, 59 insertions, 2 deletions
diff --git a/ishtar_common/models.py b/ishtar_common/models.py index 5be06fd32..0a00fc108 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -294,11 +294,13 @@ class OwnPerms(object): sorted(owns, key=lambda x: x[0][label_key])) @classmethod - def get_owns(cls, user, replace_query={}, limit=None, values=None, - get_short_menu_class=False): + def get_owns(cls, user, replace_query=None, limit=None, values=None, + get_short_menu_class=False, menu_filtr=None): """ Get Own items """ + if not replace_query: + replace_query = {} if hasattr(user, 'is_authenticated') and not user.is_authenticated(): returned = cls.objects.filter(pk__isnull=True) if values: @@ -3636,6 +3638,30 @@ class Document(OwnPerms, ImageModel, FullSearch, Imported): pgettext_lazy("key for text search", u"has-duplicate"), 'duplicate' ), + 'operation': ( + pgettext_lazy("key for text search", u"operation"), + 'operations__cached_label__iexact' + ), + 'context_record': ( + pgettext_lazy("key for text search", u"context-record"), + 'context_records__cached_label__iexact' + ), + 'find': ( + pgettext_lazy("key for text search", u"find"), + 'finds__cached_label__iexact' + ), + 'file': ( + pgettext_lazy("key for text search", u"file"), + 'files__cached_label__iexact' + ), + 'site': ( + pgettext_lazy("key for text search", u"site"), + 'sites__cached_label__iexact' + ), + 'warehouse': ( + pgettext_lazy("key for text search", u"warehouse"), + 'warehouses__name__iexact' + ), } for v in ALT_NAMES.values(): for language_code, language_lbl in settings.LANGUAGES: @@ -3644,6 +3670,37 @@ class Document(OwnPerms, ImageModel, FullSearch, Imported): deactivate() objects = ExternalIdManager() + RELATED_MODELS_ALT = [ + 'finds', 'context_records', 'operations', 'sites', 'files', + 'warehouses', 'treatments', 'treatment_files', + ] + RELATIVE_SESSION_NAMES = [ + ('find', 'finds__pk'), + ('contextrecord', 'context_records__pk'), + ('operation', 'operations__pk'), + ('site', 'sites__pk'), + ('file', 'files__pk'), + ('warehouse', 'warehouses__pk'), + ('treatment', 'treatments__pk'), + ('treatmentfile', 'treatment_files__pk'), + ] + + UP_MODEL_QUERY = { + "operation": (pgettext_lazy("key for text search", u"operation"), + 'cached_label'), + "contextrecord": (pgettext_lazy("key for text search", + u"context-record"), 'cached_label'), + "file": (pgettext_lazy("key for text search", u"file"), 'cached_label'), + "find": (pgettext_lazy("key for text search", u"find"), 'cached_label'), + "site": (pgettext_lazy("key for text search", u"site"), 'cached_label'), + "warehouse": (pgettext_lazy("key for text search", u"warehouse"), + 'cached_label'), + "treatment": (pgettext_lazy("key for text search", u"treatment"), + 'cached_label'), + "treatmentfile": (pgettext_lazy("key for text search", + u"treatment-file"), 'cached_label'), + } + title = models.TextField(_(u"Title"), blank=True, default='') associated_file = models.FileField( upload_to=get_image_path, blank=True, null=True, max_length=255) |