From 43b47430a29ac6ada5ba14a33f1983f6cf92ace4 Mon Sep 17 00:00:00 2001 From: gfawcett Date: Tue, 28 Dec 2010 18:05:03 +0000 Subject: [PATCH] copyright status enhancements Now, electronic items that are not cleared for copyright are not downloadable by students. Such items are visible to instructors and staff, with a clear visual warning. git-svn-id: svn://svn.open-ils.org/ILS-Contrib/servres/trunk@1131 6d9bc8c9-1ec2-4278-b937-99fde70a366f --- conifer/static/main.css | 4 ++++ conifer/syrup/models.py | 3 +++ conifer/syrup/views/items.py | 10 ++++++++++ conifer/templates/components/site.xhtml | 3 ++- conifer/templates/item/item_add_elec.xhtml | 3 ++- conifer/templates/item/item_heading_detail.xhtml | 1 + conifer/templates/item/item_metadata.xhtml | 3 +++ conifer/templates/site_detail.xhtml | 1 + 8 files changed, 26 insertions(+), 2 deletions(-) diff --git a/conifer/static/main.css b/conifer/static/main.css index 9fc8a37..964509c 100644 --- a/conifer/static/main.css +++ b/conifer/static/main.css @@ -185,6 +185,7 @@ span.final_item { font-weight: bold; font-size: 110%; } .itemtree li .mainline { padding-left: 8px; } .itemtree li .author_pub { padding-left: 8px; font-size: 90%; margin: 2px 0; color: #111; } +.itemtree li .forbidden_notice { padding-left: 8px; font-size: 90%; margin: 2px 0; color: darkred; } .itemtree .metalink { padding-left: 8px; color: gray; } .itemtree .metalink a { @@ -243,6 +244,9 @@ li.item_HEADING .headingmainline a.mainlink:hover { list-style-image: url(tango/x-office-address-book.png); } +.itemtree li.forbidden { + background-color: #fdd; +} .instructors { border: 1px solid #ccc; diff --git a/conifer/syrup/models.py b/conifer/syrup/models.py index 6752b57..43eeb17 100644 --- a/conifer/syrup/models.py +++ b/conifer/syrup/models.py @@ -691,6 +691,9 @@ class Item(BaseModel): """Should an 'About' link be displayed for this item?""" return self.item_type in ('URL',) + def copyright_status_ok(self): + return not (self.item_type == u'ELEC' and self.copyright_status == u'UK') + def item_download_url(self): if self.item_type != 'ELEC': return None diff --git a/conifer/syrup/views/items.py b/conifer/syrup/views/items.py index 6bb347e..4e4ffdd 100644 --- a/conifer/syrup/views/items.py +++ b/conifer/syrup/views/items.py @@ -292,6 +292,16 @@ def item_download(request, site_id, item_id, filename): site = get_object_or_404(models.Site, pk=site_id) item = get_object_or_404(models.Item, pk=item_id, site__id=site_id) assert item.item_type == 'ELEC', _('Can only download ELEC documents!') + + # don't allow download of items that need a declaration. + item_declaration_required = item.needs_declaration_from(request.user) + if item_declaration_required: + return HttpResponseRedirect(item.item_url()) + + # don't allow download of items that are not copyright-cleared. + if not (item.copyright_status_ok() or site.can_edit(request.user)): + return HttpResponseRedirect(item.item_url()) + fileiter = item.fileobj.chunks() resp = HttpResponse(fileiter) resp['Content-Type'] = item.fileobj_mimetype or 'application/octet-stream' diff --git a/conifer/templates/components/site.xhtml b/conifer/templates/components/site.xhtml index 47fe28e..64a94dd 100644 --- a/conifer/templates/components/site.xhtml +++ b/conifer/templates/components/site.xhtml @@ -30,7 +30,7 @@ searchtext = _('search this site...')