def archive_access_by_ead(user, id, *args, **kwargs): '''Check if a user has permissions for a specific archive based on an EAD document. Expects an eadid, which will be used to determine what Archive the document is associated with; then hands off to :meth:`archive_access`. ''' archive = None try: ead = FindingAid.objects.only('repository').get(eadid=id) if ead.repository: # NOTE: for some reason the partial return doesn't get normalized # normalize it here to ensure we get a match archive_name = normalize_whitespace(ead.repository[0]) try: archive = Archive.objects.get(name=archive_name).slug except ObjectDoesNotExist: pass except DoesNotExist: pass # hand off even if archive couldn't be determined - logic for non-admin # and superuser will still be accurate & useful return archive_access(user, archive, *args, **kwargs)
def requestable(self): ''' Determines if the EAD is applicable for the electronic request service.''' # If the request url is not configured, then the request can't be generated. if not hasattr(settings,'REQUEST_MATERIALS_URL') or not settings.REQUEST_MATERIALS_URL: return False if not hasattr(settings,'REQUEST_MATERIALS_REPOS') or not settings.REQUEST_MATERIALS_REPOS: return False # If the item is in on of the libraries defined, then it should be displayed. return any([normalize_whitespace(repo) in settings.REQUEST_MATERIALS_REPOS for repo in self.repository])
def __unicode__(self): count = 0 text = [] # list of text segments to be combined for element in self.elements: # due to spacing issues / missing text nodes in certain # cases (particularly when search term highlighting is # enabled), force a space before any extent tag if getattr(element.node, 'tag', None) == self.extent_tag: if count > 0: text.append(' ') count += 1 # add current node text content text.append(unicode(element)) return normalize_whitespace(''.join(text))