From dacbe80f95cb58578d450bae19442d964b95e91c Mon Sep 17 00:00:00 2001 From: gfawcett Date: Thu, 15 Jul 2010 00:53:47 +0000 Subject: [PATCH] Dang, ReadingList is an awful model name. Starting over as Site; blow your test db away. Sorry, the schema migration stuff can't handle this; at least I don't think it's worth the contortions to make it try. git-svn-id: svn://svn.open-ils.org/ILS-Contrib/servres/trunk@907 6d9bc8c9-1ec2-4278-b937-99fde70a366f --- conifer/syrup/admin.py | 2 +- conifer/syrup/migrations/0001_initial.py | 158 +++++++++---------- ...0002_auto__chg_field_servicedesk_external_id.py | 171 --------------------- conifer/syrup/migrations/__init__.py | 0 conifer/syrup/models.py | 46 +++--- 5 files changed, 103 insertions(+), 274 deletions(-) delete mode 100644 conifer/syrup/migrations/0002_auto__chg_field_servicedesk_external_id.py delete mode 100644 conifer/syrup/migrations/__init__.py diff --git a/conifer/syrup/admin.py b/conifer/syrup/admin.py index 29c6e7a..94b1e2a 100644 --- a/conifer/syrup/admin.py +++ b/conifer/syrup/admin.py @@ -6,7 +6,7 @@ import django.db.models from conifer.syrup.models import * for m in [ServiceDesk, Group, Membership, Course, - Department, ReadingList, Term, + Department, Site, Term, UserProfile, Config, Z3950Target]: admin.site.register(m) diff --git a/conifer/syrup/migrations/0001_initial.py b/conifer/syrup/migrations/0001_initial.py index 81766c4..2c46d4b 100644 --- a/conifer/syrup/migrations/0001_initial.py +++ b/conifer/syrup/migrations/0001_initial.py @@ -5,132 +5,132 @@ from south.v2 import SchemaMigration from django.db import models class Migration(SchemaMigration): - + def forwards(self, orm): # Adding model 'UserProfile' db.create_table('syrup_userprofile', ( - ('last_email_notice', self.gf('django.db.models.fields.DateTimeField')(default=datetime.datetime.now, null=True, blank=True)), + ('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)), - ('wants_email_notices', self.gf('django.db.models.fields.BooleanField')(default=False, blank=True)), ('last_modified', self.gf('django.db.models.fields.DateTimeField')(auto_now=True, blank=True)), ('user', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['auth.User'])), ('ils_userid', self.gf('django.db.models.fields.CharField')(max_length=50, null=True, blank=True)), - ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), + ('wants_email_notices', self.gf('django.db.models.fields.BooleanField')(default=False, blank=True)), + ('last_email_notice', self.gf('django.db.models.fields.DateTimeField')(default=datetime.datetime.now, null=True, blank=True)), )) db.send_create_signal('syrup', ['UserProfile']) # Adding model 'ServiceDesk' db.create_table('syrup_servicedesk', ( - ('name', self.gf('django.db.models.fields.CharField')(max_length=100)), + ('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)), + ('name', self.gf('django.db.models.fields.CharField')(max_length=100)), ('active', self.gf('django.db.models.fields.BooleanField')(default=True, blank=True)), - ('external_id', self.gf('django.db.models.fields.CharField')(max_length=256)), - ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), + ('external_id', self.gf('django.db.models.fields.CharField')(max_length=256, null=True, blank=True)), )) db.send_create_signal('syrup', ['ServiceDesk']) # Adding model 'Term' db.create_table('syrup_term', ( + ('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)), ('code', self.gf('django.db.models.fields.CharField')(max_length=64)), ('name', self.gf('django.db.models.fields.CharField')(max_length=256)), - ('created', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True, blank=True)), - ('finish', self.gf('django.db.models.fields.DateField')()), ('start', self.gf('django.db.models.fields.DateField')()), - ('last_modified', self.gf('django.db.models.fields.DateTimeField')(auto_now=True, blank=True)), - ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), + ('finish', self.gf('django.db.models.fields.DateField')()), )) db.send_create_signal('syrup', ['Term']) # Adding model 'Department' db.create_table('syrup_department', ( - ('service_desk', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['syrup.ServiceDesk'])), - ('name', self.gf('django.db.models.fields.CharField')(max_length=256)), + ('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)), + ('name', self.gf('django.db.models.fields.CharField')(max_length=256)), ('active', self.gf('django.db.models.fields.BooleanField')(default=True, blank=True)), - ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), + ('service_desk', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['syrup.ServiceDesk'])), )) db.send_create_signal('syrup', ['Department']) # Adding model 'Course' db.create_table('syrup_course', ( - ('code', self.gf('django.db.models.fields.CharField')(max_length=64)), - ('name', self.gf('django.db.models.fields.CharField')(max_length=1024)), + ('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)), + ('code', self.gf('django.db.models.fields.CharField')(max_length=64)), + ('name', self.gf('django.db.models.fields.CharField')(max_length=1024)), ('department', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['syrup.Department'])), - ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), )) db.send_create_signal('syrup', ['Course']) # Adding model 'Z3950Target' db.create_table('syrup_z3950target', ( + ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), ('name', self.gf('django.db.models.fields.CharField')(max_length=100)), + ('host', self.gf('django.db.models.fields.CharField')(max_length=50)), ('database', self.gf('django.db.models.fields.CharField')(max_length=50)), + ('port', self.gf('django.db.models.fields.IntegerField')(default=210)), ('syntax', self.gf('django.db.models.fields.CharField')(default='USMARC', max_length=10)), ('active', self.gf('django.db.models.fields.BooleanField')(default=True, blank=True)), - ('host', self.gf('django.db.models.fields.CharField')(max_length=50)), - ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), - ('port', self.gf('django.db.models.fields.IntegerField')(default=210)), )) db.send_create_signal('syrup', ['Z3950Target']) # Adding model 'Config' db.create_table('syrup_config', ( ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), - ('value', self.gf('django.db.models.fields.CharField')(max_length=8192)), ('name', self.gf('django.db.models.fields.CharField')(max_length=256)), + ('value', self.gf('django.db.models.fields.CharField')(max_length=8192)), )) db.send_create_signal('syrup', ['Config']) - # Adding model 'ReadingList' - db.create_table('syrup_readinglist', ( - ('service_desk', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['syrup.ServiceDesk'])), + # Adding model 'Site' + db.create_table('syrup_site', ( + ('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)), - ('passkey', self.gf('django.db.models.fields.CharField')(db_index=True, max_length=256, null=True, blank=True)), - ('access', self.gf('django.db.models.fields.CharField')(default='CLOSE', max_length=5)), ('last_modified', self.gf('django.db.models.fields.DateTimeField')(auto_now=True, blank=True)), ('owner', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['auth.User'])), - ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), + ('service_desk', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['syrup.ServiceDesk'])), + ('access', self.gf('django.db.models.fields.CharField')(default='CLOSE', max_length=5)), + ('passkey', self.gf('django.db.models.fields.CharField')(db_index=True, max_length=256, null=True, blank=True)), )) - db.send_create_signal('syrup', ['ReadingList']) + db.send_create_signal('syrup', ['Site']) - # Adding M2M table for field courses on 'ReadingList' - db.create_table('syrup_readinglist_courses', ( + # Adding M2M table for field courses on 'Site' + db.create_table('syrup_site_courses', ( ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)), - ('readinglist', models.ForeignKey(orm['syrup.readinglist'], null=False)), + ('site', models.ForeignKey(orm['syrup.site'], null=False)), ('course', models.ForeignKey(orm['syrup.course'], null=False)) )) - db.create_unique('syrup_readinglist_courses', ['readinglist_id', 'course_id']) + db.create_unique('syrup_site_courses', ['site_id', 'course_id']) - # Adding M2M table for field terms on 'ReadingList' - db.create_table('syrup_readinglist_terms', ( + # Adding M2M table for field terms on 'Site' + db.create_table('syrup_site_terms', ( ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)), - ('readinglist', models.ForeignKey(orm['syrup.readinglist'], null=False)), + ('site', models.ForeignKey(orm['syrup.site'], null=False)), ('term', models.ForeignKey(orm['syrup.term'], null=False)) )) - db.create_unique('syrup_readinglist_terms', ['readinglist_id', 'term_id']) + db.create_unique('syrup_site_terms', ['site_id', 'term_id']) # Adding model 'Group' db.create_table('syrup_group', ( - ('external_id', self.gf('django.db.models.fields.CharField')(default=None, max_length=2048, null=True, blank=True)), - ('last_modified', self.gf('django.db.models.fields.DateTimeField')(auto_now=True, blank=True)), - ('reading_list', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['syrup.ReadingList'])), ('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)), + ('site', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['syrup.Site'])), + ('external_id', self.gf('django.db.models.fields.CharField')(db_index=True, max_length=2048, null=True, blank=True)), )) db.send_create_signal('syrup', ['Group']) # Adding model 'Membership' db.create_table('syrup_membership', ( - ('group', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['syrup.Group'])), + ('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)), - ('role', self.gf('django.db.models.fields.CharField')(default='STUDT', max_length=6)), ('user', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['auth.User'])), - ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), + ('group', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['syrup.Group'])), + ('role', self.gf('django.db.models.fields.CharField')(default='STUDT', max_length=6)), )) db.send_create_signal('syrup', ['Membership']) @@ -139,26 +139,26 @@ class Migration(SchemaMigration): # Adding model 'Item' db.create_table('syrup_item', ( - ('parent_heading', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['syrup.Item'], null=True, blank=True)), - ('publisher', self.gf('django.db.models.fields.CharField')(max_length=8192, null=True, blank=True)), - ('itemtype', self.gf('django.db.models.fields.CharField')(db_index=True, max_length=1, null=True, blank=True)), + ('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)), + ('site', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['syrup.Site'])), + ('item_type', self.gf('django.db.models.fields.CharField')(max_length=7)), + ('bib_id', self.gf('django.db.models.fields.CharField')(max_length=256, null=True, blank=True)), ('marcxml', self.gf('django.db.models.fields.TextField')(null=True, blank=True)), + ('title', self.gf('django.db.models.fields.CharField')(max_length=8192, db_index=True)), ('author', self.gf('django.db.models.fields.CharField')(db_index=True, max_length=8192, null=True, blank=True)), - ('created', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True, blank=True)), + ('publisher', self.gf('django.db.models.fields.CharField')(max_length=8192, null=True, blank=True)), + ('published', self.gf('django.db.models.fields.DateField')(null=True, blank=True)), + ('itemtype', self.gf('django.db.models.fields.CharField')(db_index=True, max_length=1, null=True, blank=True)), + ('parent_heading', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['syrup.Item'], null=True, blank=True)), ('url', self.gf('django.db.models.fields.URLField')(max_length=200, null=True, blank=True)), - ('title', self.gf('django.db.models.fields.CharField')(max_length=8192, db_index=True)), - ('fileobj_mimetype', self.gf('django.db.models.fields.CharField')(max_length=128, null=True, blank=True)), - ('item_type', self.gf('django.db.models.fields.CharField')(max_length=7)), - ('last_modified', self.gf('django.db.models.fields.DateTimeField')(auto_now=True, blank=True)), ('fileobj', self.gf('django.db.models.fields.files.FileField')(default=None, max_length=255, null=True, blank=True)), - ('published', self.gf('django.db.models.fields.DateField')(null=True, blank=True)), - ('reading_list', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['syrup.ReadingList'])), - ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), - ('bib_id', self.gf('django.db.models.fields.CharField')(max_length=256, null=True, blank=True)), + ('fileobj_mimetype', self.gf('django.db.models.fields.CharField')(max_length=128, null=True, blank=True)), )) db.send_create_signal('syrup', ['Item']) - - + + def backwards(self, orm): # Deleting model 'UserProfile' @@ -182,14 +182,14 @@ class Migration(SchemaMigration): # Deleting model 'Config' db.delete_table('syrup_config') - # Deleting model 'ReadingList' - db.delete_table('syrup_readinglist') + # Deleting model 'Site' + db.delete_table('syrup_site') - # Removing M2M table for field courses on 'ReadingList' - db.delete_table('syrup_readinglist_courses') + # Removing M2M table for field courses on 'Site' + db.delete_table('syrup_site_courses') - # Removing M2M table for field terms on 'ReadingList' - db.delete_table('syrup_readinglist_terms') + # Removing M2M table for field terms on 'Site' + db.delete_table('syrup_site_terms') # Deleting model 'Group' db.delete_table('syrup_group') @@ -202,8 +202,8 @@ class Migration(SchemaMigration): # Deleting model 'Item' db.delete_table('syrup_item') - - + + models = { 'auth.group': { 'Meta': {'object_name': 'Group'}, @@ -268,10 +268,10 @@ class Migration(SchemaMigration): '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', [], {'default': 'None', 'max_length': '2048', 'null': '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'}), - 'reading_list': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['syrup.ReadingList']"}) + 'site': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['syrup.Site']"}) }, 'syrup.item': { 'Meta': {'object_name': 'Item'}, @@ -288,7 +288,7 @@ class Migration(SchemaMigration): 'parent_heading': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['syrup.Item']", 'null': 'True', 'blank': 'True'}), 'published': ('django.db.models.fields.DateField', [], {'null': 'True', 'blank': 'True'}), 'publisher': ('django.db.models.fields.CharField', [], {'max_length': '8192', 'null': 'True', 'blank': 'True'}), - 'reading_list': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['syrup.ReadingList']"}), + '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'}) }, @@ -301,8 +301,17 @@ class Migration(SchemaMigration): 'role': ('django.db.models.fields.CharField', [], {'default': "'STUDT'", 'max_length': '6'}), 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"}) }, - 'syrup.readinglist': { - 'Meta': {'object_name': 'ReadingList'}, + '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', [], {'max_length': '100'}) + }, + 'syrup.site': { + 'Meta': {'object_name': 'Site'}, 'access': ('django.db.models.fields.CharField', [], {'default': "'CLOSE'", 'max_length': '5'}), 'courses': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['syrup.Course']"}), 'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), @@ -313,15 +322,6 @@ class Migration(SchemaMigration): 'service_desk': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['syrup.ServiceDesk']"}), 'terms': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['syrup.Term']"}) }, - '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'}), - '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': '100'}) - }, 'syrup.term': { 'Meta': {'object_name': 'Term'}, 'code': ('django.db.models.fields.CharField', [], {'max_length': '64'}), @@ -353,5 +353,5 @@ class Migration(SchemaMigration): 'syntax': ('django.db.models.fields.CharField', [], {'default': "'USMARC'", 'max_length': '10'}) } } - + complete_apps = ['syrup'] diff --git a/conifer/syrup/migrations/0002_auto__chg_field_servicedesk_external_id.py b/conifer/syrup/migrations/0002_auto__chg_field_servicedesk_external_id.py deleted file mode 100644 index c00aeb7..0000000 --- a/conifer/syrup/migrations/0002_auto__chg_field_servicedesk_external_id.py +++ /dev/null @@ -1,171 +0,0 @@ -# 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): - - # Changing field 'ServiceDesk.external_id' - db.alter_column('syrup_servicedesk', 'external_id', self.gf('django.db.models.fields.CharField')(max_length=256, null=True, blank=True)) - - - def backwards(self, orm): - - # Changing field 'ServiceDesk.external_id' - db.alter_column('syrup_servicedesk', 'external_id', self.gf('django.db.models.fields.CharField')(max_length=256)) - - - 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', [], {'max_length': '256'}), - 'value': ('django.db.models.fields.CharField', [], {'max_length': '8192'}) - }, - 'syrup.course': { - 'Meta': {'object_name': 'Course'}, - 'code': ('django.db.models.fields.CharField', [], {'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.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', [], {'default': 'None', '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'}), - 'reading_list': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['syrup.ReadingList']"}) - }, - '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.DateField', [], {'null': 'True', 'blank': 'True'}), - 'publisher': ('django.db.models.fields.CharField', [], {'max_length': '8192', 'null': 'True', 'blank': 'True'}), - 'reading_list': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['syrup.ReadingList']"}), - '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.readinglist': { - 'Meta': {'object_name': 'ReadingList'}, - 'access': ('django.db.models.fields.CharField', [], {'default': "'CLOSE'", 'max_length': '5'}), - 'courses': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['syrup.Course']"}), - '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'}), - 'owner': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"}), - 'passkey': ('django.db.models.fields.CharField', [], {'db_index': 'True', 'max_length': '256', 'null': 'True', 'blank': 'True'}), - 'service_desk': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['syrup.ServiceDesk']"}), - 'terms': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['syrup.Term']"}) - }, - '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', [], {'max_length': '100'}) - }, - 'syrup.term': { - 'Meta': {'object_name': 'Term'}, - 'code': ('django.db.models.fields.CharField', [], {'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'}), - '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'] diff --git a/conifer/syrup/migrations/__init__.py b/conifer/syrup/migrations/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/conifer/syrup/models.py b/conifer/syrup/models.py index b880eea..c8aee0c 100644 --- a/conifer/syrup/models.py +++ b/conifer/syrup/models.py @@ -42,12 +42,12 @@ class BaseModel(m.Model): # candidate). class UserExtensionMixin(object): - def reading_lists(self): - return ReadingList.objects.filter(group__membership__user=self.id) + def sites(self): + return Site.objects.filter(group__membership__user=self.id) - def can_create_reading_lists(self): + def can_create_sites(self): return self.is_staff or \ - bool(callhook('can_create_reading_lists', self)) + bool(callhook('can_create_sites', self)) @classmethod def active_instructors(cls): @@ -142,7 +142,7 @@ class Config(m.Model): #------------------------------------------------------------ -class ReadingList(BaseModel): +class Site(BaseModel): """A a list of materials for one (or more) course offering(s).""" # some courses may be ad-hoc and have no code. # TODO: constrain there is at least one course and one term (deferred). @@ -229,8 +229,8 @@ class ReadingList(BaseModel): while True: key = algorithm() try: - crs = ReadingList.objects.get(passkey=key) - except ReadingList.DoesNotExist: + crs = Site.objects.get(passkey=key) + except Site.DoesNotExist: self.passkey = key break @@ -238,7 +238,7 @@ class ReadingList(BaseModel): # membership-related functions def members(self): - return Membership.objects.filter(group__reading_list=self) + return Membership.objects.filter(group__site=self) def get_students(self): return self.memberships(role='STUDT').order_by( @@ -270,39 +270,39 @@ class ReadingList(BaseModel): #------------------------------------------------------------ -# User membership in reading lists +# User membership in sites class Group(BaseModel): """ - A group of users associated with a ReadingList. A ReadingList will + A group of users associated with a Site. A Site will have one internal group, but may have zero or more external groups. - Each ReadingList will have exactly one Group with a NULL + Each Site will have exactly one Group with a NULL external_id, intended for internal memberships. It may have zero or more Groups with non-NULL external_ids, representing various - external user-groups that should have access to this ReadingList. + external user-groups that should have access to this Site. A consequence of this design is that a user may appear in a - ReadingList more than once, with different roles. + Site more than once, with different roles. - Note, a ReadingList may be open-access, but still have members + Note, a Site may be open-access, but still have members with 'student' access. In this case memberships won't imply authorization, but can be used for personalization (e.g. to show a - list of "my reading lists"). + list of "my sites"). """ - # TODO: add constraints to ensure that each ReadingList has - # exactly one Group with external_id=NULL, and that (readinglist, + # TODO: add constraints to ensure that each Site has + # exactly one Group with external_id=NULL, and that (site, # external_id) is unique forall external_id != NULL. - reading_list = m.ForeignKey(ReadingList) + site = m.ForeignKey(Site) external_id = m.CharField(null=True, blank=True, db_index=True, max_length=2048) def __unicode__(self): - return u"Group('%s', '%s')" % (self.reading_list, + return u"Group('%s', '%s')" % (self.site, self.external_id or '(internal)') class Membership(BaseModel): @@ -344,8 +344,8 @@ class Membership(BaseModel): class Item(BaseModel): """ A reserve item, physical or electronic, as it appears in a given - ReadingList instance. If an item appears on multiple reading - lists, it will have multiple Item records associated with it. + Site instance. If an item appears on multiple sites, it will have + multiple Item records associated with it. """ # Structure @@ -354,7 +354,7 @@ class Item(BaseModel): # database, all items are stored as a flat list; the sort_order # dictates the sequencing of items within their parent group. - reading_list = m.ForeignKey(ReadingList) + site = m.ForeignKey(Site) ITEM_TYPE_CHOICES = ( ('ELEC', _('Attached Electronic Document')), # PDF, Doc, etc. @@ -369,7 +369,7 @@ class Item(BaseModel): # Ephemerals, and add an EPHEM item-type to refer to them. The # contract would be that an ephmeral ID could be reused over time, # and so it might resolve to the wrong item (or no item at all) if - # deferenced after the active timeframe of the ReadingList. + # deferenced after the active timeframe of the Site. #-------------------------------------------------- # ILS integration -- 2.11.0