[open-ils-commits] r1065 - in servres/trunk/conifer: static syrup syrup/migrations syrup/views templates/item (gfawcett)
svn at svn.open-ils.org
svn at svn.open-ils.org
Fri Nov 12 20:39:15 EST 2010
Author: gfawcett
Date: 2010-11-12 20:39:14 -0500 (Fri, 12 Nov 2010)
New Revision: 1065
Added:
servres/trunk/conifer/static/ask_for_item.js
servres/trunk/conifer/syrup/migrations/0007_auto__add_declaration.py
Modified:
servres/trunk/conifer/static/main.css
servres/trunk/conifer/syrup/models.py
servres/trunk/conifer/syrup/urls.py
servres/trunk/conifer/syrup/views/items.py
servres/trunk/conifer/templates/item/item_metadata.xhtml
Log:
added Declaration model; students must click to declare intent before downloading.
Added: servres/trunk/conifer/static/ask_for_item.js
===================================================================
--- servres/trunk/conifer/static/ask_for_item.js (rev 0)
+++ servres/trunk/conifer/static/ask_for_item.js 2010-11-13 01:39:14 UTC (rev 1065)
@@ -0,0 +1,7 @@
+function askToDownload() {
+ $.post('askfor', function() {
+ $('#ask_to_download_panel').fadeOut('fast', function() {
+ $('#downloadpanel').fadeIn(1000);
+ });
+ });
+}
Modified: servres/trunk/conifer/static/main.css
===================================================================
--- servres/trunk/conifer/static/main.css 2010-11-13 01:35:41 UTC (rev 1064)
+++ servres/trunk/conifer/static/main.css 2010-11-13 01:39:14 UTC (rev 1065)
@@ -325,8 +325,8 @@
background-color: #eee;
}
-.metadata_table a.bigdownload { padding: 8px 58px; font-weight: bold; font-size: 105%; }
-.metadata_table a.bigdownload:hover { background-color: #dfd; color: black; }
+a.bigdownload * { padding: 8px 58px; font-weight: bold; font-size: 100%; }
+a.bigdownload:hover { background-color: #dfd; color: black; }
h2.metadata_subhead {font-size: 105%; padding: 0; margin: 18px 0 9px 0;}
Added: servres/trunk/conifer/syrup/migrations/0007_auto__add_declaration.py
===================================================================
--- servres/trunk/conifer/syrup/migrations/0007_auto__add_declaration.py (rev 0)
+++ servres/trunk/conifer/syrup/migrations/0007_auto__add_declaration.py 2010-11-13 01:39:14 UTC (rev 1065)
@@ -0,0 +1,187 @@
+# encoding: utf-8
+import datetime
+from south.db import db
+from south.v2 import SchemaMigration
+from django.db import models
+
+class Migration(SchemaMigration):
+
+ def forwards(self, orm):
+
+ # Adding model 'Declaration'
+ db.create_table('syrup_declaration', (
+ ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
+ ('created', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True, blank=True)),
+ ('last_modified', self.gf('django.db.models.fields.DateTimeField')(auto_now=True, blank=True)),
+ ('item', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['syrup.Item'])),
+ ('user', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['auth.User'])),
+ ))
+ db.send_create_signal('syrup', ['Declaration'])
+
+
+ def backwards(self, orm):
+
+ # Deleting model 'Declaration'
+ db.delete_table('syrup_declaration')
+
+
+ models = {
+ 'auth.group': {
+ 'Meta': {'object_name': 'Group'},
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
+ 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'blank': 'True'})
+ },
+ 'auth.permission': {
+ 'Meta': {'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'},
+ 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+ 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
+ },
+ 'auth.user': {
+ 'Meta': {'object_name': 'User'},
+ 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
+ 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
+ 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'blank': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'blank': 'True'}),
+ 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
+ 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
+ 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
+ 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
+ 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'blank': 'True'}),
+ 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
+ },
+ 'contenttypes.contenttype': {
+ 'Meta': {'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
+ 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
+ },
+ 'syrup.config': {
+ 'Meta': {'object_name': 'Config'},
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '256'}),
+ 'value': ('django.db.models.fields.CharField', [], {'max_length': '8192'})
+ },
+ 'syrup.course': {
+ 'Meta': {'object_name': 'Course'},
+ 'code': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '64'}),
+ 'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
+ 'department': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['syrup.Department']"}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'last_modified': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '1024'})
+ },
+ 'syrup.declaration': {
+ 'Meta': {'object_name': 'Declaration'},
+ 'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'item': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['syrup.Item']"}),
+ 'last_modified': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
+ 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"})
+ },
+ 'syrup.department': {
+ 'Meta': {'object_name': 'Department'},
+ 'active': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'blank': 'True'}),
+ 'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'last_modified': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '256'}),
+ 'service_desk': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['syrup.ServiceDesk']"})
+ },
+ 'syrup.group': {
+ 'Meta': {'object_name': 'Group'},
+ 'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
+ 'external_id': ('django.db.models.fields.CharField', [], {'db_index': 'True', 'max_length': '2048', 'null': 'True', 'blank': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'last_modified': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
+ 'site': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['syrup.Site']"})
+ },
+ 'syrup.item': {
+ 'Meta': {'object_name': 'Item'},
+ 'author': ('django.db.models.fields.CharField', [], {'db_index': 'True', 'max_length': '8192', 'null': 'True', 'blank': 'True'}),
+ 'bib_id': ('django.db.models.fields.CharField', [], {'max_length': '256', 'null': 'True', 'blank': 'True'}),
+ 'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
+ 'fileobj': ('django.db.models.fields.files.FileField', [], {'default': 'None', 'max_length': '255', 'null': 'True', 'blank': 'True'}),
+ 'fileobj_mimetype': ('django.db.models.fields.CharField', [], {'max_length': '128', 'null': 'True', 'blank': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'item_type': ('django.db.models.fields.CharField', [], {'max_length': '7'}),
+ 'itemtype': ('django.db.models.fields.CharField', [], {'db_index': 'True', 'max_length': '1', 'null': 'True', 'blank': 'True'}),
+ 'last_modified': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
+ 'marcxml': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
+ 'parent_heading': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['syrup.Item']", 'null': 'True', 'blank': 'True'}),
+ 'published': ('django.db.models.fields.CharField', [], {'max_length': '64', 'null': 'True', 'blank': 'True'}),
+ 'publisher': ('django.db.models.fields.CharField', [], {'max_length': '8192', 'null': 'True', 'blank': 'True'}),
+ 'site': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['syrup.Site']"}),
+ 'title': ('django.db.models.fields.CharField', [], {'max_length': '8192', 'db_index': 'True'}),
+ 'url': ('django.db.models.fields.URLField', [], {'max_length': '200', 'null': 'True', 'blank': 'True'})
+ },
+ 'syrup.membership': {
+ 'Meta': {'unique_together': "(('group', 'user'),)", 'object_name': 'Membership'},
+ 'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
+ 'group': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['syrup.Group']"}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'last_modified': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
+ 'role': ('django.db.models.fields.CharField', [], {'default': "'STUDT'", 'max_length': '6'}),
+ 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"})
+ },
+ 'syrup.servicedesk': {
+ 'Meta': {'object_name': 'ServiceDesk'},
+ 'active': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'blank': 'True'}),
+ 'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
+ 'external_id': ('django.db.models.fields.CharField', [], {'max_length': '256', 'null': 'True', 'blank': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'last_modified': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '100'})
+ },
+ 'syrup.site': {
+ 'Meta': {'unique_together': "(('course', 'start_term', 'owner'),)", 'object_name': 'Site'},
+ 'access': ('django.db.models.fields.CharField', [], {'default': "'ANON'", 'max_length': '5'}),
+ 'course': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['syrup.Course']"}),
+ 'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
+ 'end_term': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'end_term'", 'to': "orm['syrup.Term']"}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'last_modified': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
+ 'owner': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"}),
+ 'service_desk': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['syrup.ServiceDesk']"}),
+ 'start_term': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'start_term'", 'to': "orm['syrup.Term']"})
+ },
+ 'syrup.term': {
+ 'Meta': {'object_name': 'Term'},
+ 'code': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '64'}),
+ 'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
+ 'finish': ('django.db.models.fields.DateField', [], {}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'last_modified': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '256'}),
+ 'start': ('django.db.models.fields.DateField', [], {})
+ },
+ 'syrup.userprofile': {
+ 'Meta': {'object_name': 'UserProfile'},
+ 'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
+ 'external_memberships_checked': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'ils_userid': ('django.db.models.fields.CharField', [], {'max_length': '50', 'null': 'True', 'blank': 'True'}),
+ 'last_email_notice': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'null': 'True', 'blank': 'True'}),
+ 'last_modified': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
+ 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"}),
+ 'wants_email_notices': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'})
+ },
+ 'syrup.z3950target': {
+ 'Meta': {'object_name': 'Z3950Target'},
+ 'active': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'blank': 'True'}),
+ 'database': ('django.db.models.fields.CharField', [], {'max_length': '50'}),
+ 'host': ('django.db.models.fields.CharField', [], {'max_length': '50'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+ 'port': ('django.db.models.fields.IntegerField', [], {'default': '210'}),
+ 'syntax': ('django.db.models.fields.CharField', [], {'default': "'USMARC'", 'max_length': '10'})
+ }
+ }
+
+ complete_apps = ['syrup']
Modified: servres/trunk/conifer/syrup/models.py
===================================================================
--- servres/trunk/conifer/syrup/models.py 2010-11-13 01:35:41 UTC (rev 1064)
+++ servres/trunk/conifer/syrup/models.py 2010-11-13 01:39:14 UTC (rev 1065)
@@ -625,6 +625,15 @@
else:
return self.site.site_url()
+ def needs_declaration_from(self, user):
+ """Does this user need to make a declaration before downloading this
+ item?"""
+ if self.item_type == 'ELEC':
+ return not bool(
+ Declaration.objects.filter(
+ item=self, user=user))
+ return False
+
def describe_physical_item_status(self):
"""Return a (bool,str) tuple: whether the item is available,
and a friendly description of the physical item's status"""
@@ -673,7 +682,18 @@
return (Q(site__access__in=('LOGIN','ANON')) \
| Q(site__group__membership__user=user))
+#------------------------------------------------------------
+class Declaration(BaseModel):
+ """
+ These are declarations of intent to use for personal research and study.
+ We now require these before users can download electronic documents. Note,
+ it only makes sense to add Declarations for items of type ELEC (uploaded
+ electronic documents).
+ """
+ item = m.ForeignKey(Item)
+ user = m.ForeignKey(User)
+
#------------------------------------------------------------
# TODO: move this to a utility module.
Modified: servres/trunk/conifer/syrup/urls.py
===================================================================
--- servres/trunk/conifer/syrup/urls.py 2010-11-13 01:35:41 UTC (rev 1064)
+++ servres/trunk/conifer/syrup/urls.py 2010-11-13 01:39:14 UTC (rev 1065)
@@ -36,6 +36,7 @@
(ITEM_PREFIX + r'$', 'item_detail'),
(ITEM_PREFIX + r'dl/(?P<filename>.*)$', 'item_download'),
(ITEM_PREFIX + r'meta$', 'item_metadata'),
+ (ITEM_PREFIX + r'askfor$', 'item_declaration'),
(ITEM_PREFIX + r'edit/$', 'item_edit'),
(ITEM_PREFIX + r'delete/$', 'item_delete'),
(ITEM_PREFIX + r'add/$', 'item_add'), # for adding sub-things
Modified: servres/trunk/conifer/syrup/views/items.py
===================================================================
--- servres/trunk/conifer/syrup/views/items.py 2010-11-13 01:35:41 UTC (rev 1064)
+++ servres/trunk/conifer/syrup/views/items.py 2010-11-13 01:39:14 UTC (rev 1065)
@@ -22,9 +22,23 @@
if item.item_type == 'HEADING':
return _heading_detail(request, item)
else:
+ item_declaration_required = item.needs_declaration_from(request.user)
return g.render('item/item_metadata.xhtml', site=item.site,
+ item_declaration_required=item_declaration_required,
item=item)
+ at members_only
+def item_declaration(request, site_id, item_id):
+ assert request.method == 'POST'
+ item = get_object_or_404(models.Item, pk=item_id, site__id=site_id)
+ if item.item_type != 'ELEC':
+ return HttpResponseNotFound('Items of this type are not downloadable.')
+ else:
+ # we don't actually need the declaration object for anything; we just
+ # need to ensure one exists.
+ models.Declaration.objects.get_or_create(item=item, user=request.user)
+ return HttpResponse('OK')
+
def _heading_url(request, item):
return HttpResponseRedirect(item.url)
Modified: servres/trunk/conifer/templates/item/item_metadata.xhtml
===================================================================
--- servres/trunk/conifer/templates/item/item_metadata.xhtml 2010-11-13 01:35:41 UTC (rev 1064)
+++ servres/trunk/conifer/templates/item/item_metadata.xhtml 2010-11-13 01:39:14 UTC (rev 1065)
@@ -16,6 +16,14 @@
.available { color: green; border-left: 16px green solid; padding-left: 8px; }
.unavailable { color: red; border-left: 16px red solid; padding-left: 8px; }
</style>
+ <style py:if="item_declaration_required">
+ #downloadpanel { display: none; }
+ </style>
+ <style py:if="not item_declaration_required">
+ #ask_to_download_panel { display: none; }
+ </style>
+ <script py:if="item_declaration_required"
+ type="text/javascript" src="${ROOT}/static/ask_for_item.js"/>
</head>
<body>
${site_banner(site)}
@@ -43,14 +51,19 @@
</tr>
<tr py:if="item.url"><th>URL</th><td><a href="${item.url}">${item.url}</a></td></tr>
</table>
+
<div py:if="item.item_type=='ELEC'">
- <h2 class="metadata_subhead">Attached document</h2>
- <table class="metadata_table">
- <tr><th>Content type</th><td>${item.fileobj_mimetype}</td></tr>
- <tr><th>Size</th><td>${item.fileobj.size} bytes</td></tr>
- <tr><th/><td><a class="bigdownload" href="${item.item_download_url()}">Download</a></td></tr>
- </table>
+ <h2 class="metadata_subhead">Download the document</h2>
+ <div id="ask_to_download_panel">
+ <p>I warrant that I am a student of the University of Windsor registered in the aforementioned course. By pressing the 'Request' button below, I am requesting a digital copy of a reading (chapter, article) for my own private study and research use. I agree that I will not reproduce, redistribute or transmit a copy of the reading in any format.</p>
+ <p><a class="bigdownload" href="javascript:askToDownload();"><button>Request to download this document</button></a></p>
+ </div>
+ <div id="downloadpanel">
+ <p><a class="bigdownload" href="${item.item_download_url()}"><button>Click here to download the document.</button></a></p>
+ <p>Document type: ${item.fileobj_mimetype}. Size: ${item.fileobj.size} bytes.</p>
+ </div>
</div>
+
<div py:if="item.marcxml">
<abbr py:if="item.marcxml" class="unapi-id" title="${item.id}"/>
<p id="marcdatashow"><a href="javascript:void($('#marcdata').toggle());">Display MARC Record</a></p>
More information about the open-ils-commits
mailing list