From 9df86c7cec27ae4409b5a8d0bdc6653202f43a91 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Fri, 25 Sep 2015 10:14:13 -0400 Subject: [PATCH 1/3] Upgrade to Django 1.8 squash --- organizations/migrations/0001_initial.py | 115 ++++++++---------- .../0002_auto__add_field_organization_logo.py | 44 ------- ...auto__add_field_organization_short_name.py | 45 ------- organizations/tests/test_api.py | 10 +- requirements.txt | 3 +- settings.py | 1 - setup.py | 5 +- 7 files changed, 57 insertions(+), 166 deletions(-) delete mode 100644 organizations/migrations/0002_auto__add_field_organization_logo.py delete mode 100644 organizations/migrations/0003_auto__add_field_organization_short_name.py diff --git a/organizations/migrations/0001_initial.py b/organizations/migrations/0001_initial.py index 51f9ab71..3881184e 100644 --- a/organizations/migrations/0001_initial.py +++ b/organizations/migrations/0001_initial.py @@ -1,67 +1,50 @@ # -*- coding: utf-8 -*- -from south.utils import datetime_utils as 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 'Organization' - db.create_table('organizations_organization', ( - ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), - ('created', self.gf('model_utils.fields.AutoCreatedField')(default=datetime.datetime.now)), - ('modified', self.gf('model_utils.fields.AutoLastModifiedField')(default=datetime.datetime.now)), - ('name', self.gf('django.db.models.fields.CharField')(max_length=255, db_index=True)), - ('description', self.gf('django.db.models.fields.TextField')()), - ('active', self.gf('django.db.models.fields.BooleanField')(default=True)), - )) - db.send_create_signal('organizations', ['Organization']) - - # Adding model 'OrganizationCourse' - db.create_table('organizations_organizationcourse', ( - ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), - ('created', self.gf('model_utils.fields.AutoCreatedField')(default=datetime.datetime.now)), - ('modified', self.gf('model_utils.fields.AutoLastModifiedField')(default=datetime.datetime.now)), - ('course_id', self.gf('django.db.models.fields.CharField')(max_length=255, db_index=True)), - ('organization', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['organizations.Organization'])), - ('active', self.gf('django.db.models.fields.BooleanField')(default=True)), - )) - db.send_create_signal('organizations', ['OrganizationCourse']) - - # Adding unique constraint on 'OrganizationCourse', fields ['course_id', 'organization'] - db.create_unique('organizations_organizationcourse', ['course_id', 'organization_id']) - - def backwards(self, orm): - # Removing unique constraint on 'OrganizationCourse', fields ['course_id', 'organization'] - db.delete_unique('organizations_organizationcourse', ['course_id', 'organization_id']) - - # Deleting model 'Organization' - db.delete_table('organizations_organization') - - # Deleting model 'OrganizationCourse' - db.delete_table('organizations_organizationcourse') - - models = { - 'organizations.organization': { - 'Meta': {'object_name': 'Organization'}, - 'active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), - 'created': ('model_utils.fields.AutoCreatedField', [], {'default': 'datetime.datetime.now'}), - 'description': ('django.db.models.fields.TextField', [], {}), - 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'modified': ('model_utils.fields.AutoLastModifiedField', [], {'default': 'datetime.datetime.now'}), - 'name': ('django.db.models.fields.CharField', [], {'max_length': '255', 'db_index': 'True'}) - }, - 'organizations.organizationcourse': { - 'Meta': {'unique_together': "(('course_id', 'organization'),)", 'object_name': 'OrganizationCourse'}, - 'active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), - 'course_id': ('django.db.models.fields.CharField', [], {'max_length': '255', 'db_index': 'True'}), - 'created': ('model_utils.fields.AutoCreatedField', [], {'default': 'datetime.datetime.now'}), - 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'modified': ('model_utils.fields.AutoLastModifiedField', [], {'default': 'datetime.datetime.now'}), - 'organization': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['organizations.Organization']"}) - } - } - - complete_apps = ['organizations'] +from __future__ import unicode_literals + +from django.db import models, migrations +import django.utils.timezone +import model_utils.fields + + +class Migration(migrations.Migration): + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='Organization', + fields=[ + ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), + ('created', model_utils.fields.AutoCreatedField(default=django.utils.timezone.now, verbose_name='created', editable=False)), + ('modified', model_utils.fields.AutoLastModifiedField(default=django.utils.timezone.now, verbose_name='modified', editable=False)), + ('name', models.CharField(max_length=255, verbose_name=b'Long name', db_index=True)), + ('short_name', models.CharField(max_length=255, db_index=True)), + ('description', models.TextField()), + ('logo', models.ImageField(help_text='Organization logo file. It should be an image.', max_length=255, null=True, upload_to=b'organization_logos', blank=True)), + ('active', models.BooleanField(default=True)), + ], + options={ + 'abstract': False, + }, + ), + migrations.CreateModel( + name='OrganizationCourse', + fields=[ + ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), + ('created', model_utils.fields.AutoCreatedField(default=django.utils.timezone.now, verbose_name='created', editable=False)), + ('modified', model_utils.fields.AutoLastModifiedField(default=django.utils.timezone.now, verbose_name='modified', editable=False)), + ('course_id', models.CharField(max_length=255, db_index=True)), + ('active', models.BooleanField(default=True)), + ('organization', models.ForeignKey(to='organizations.Organization')), + ], + options={ + 'verbose_name': 'Link Course', + 'verbose_name_plural': 'Link Courses', + }, + ), + migrations.AlterUniqueTogether( + name='organizationcourse', + unique_together=set([('course_id', 'organization')]), + ), + ] diff --git a/organizations/migrations/0002_auto__add_field_organization_logo.py b/organizations/migrations/0002_auto__add_field_organization_logo.py deleted file mode 100644 index 8febc2cc..00000000 --- a/organizations/migrations/0002_auto__add_field_organization_logo.py +++ /dev/null @@ -1,44 +0,0 @@ -# -*- coding: utf-8 -*- -from south.utils import datetime_utils as datetime -from south.db import db -from south.v2 import SchemaMigration -from django.db import models - - -class Migration(SchemaMigration): - - def forwards(self, orm): - # Adding field 'Organization.logo' - db.add_column('organizations_organization', 'logo', - self.gf('django.db.models.fields.files.ImageField')(max_length=255, null=True, blank=True), - keep_default=False) - - - def backwards(self, orm): - # Deleting field 'Organization.logo' - db.delete_column('organizations_organization', 'logo') - - - models = { - 'organizations.organization': { - 'Meta': {'object_name': 'Organization'}, - 'active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), - 'created': ('model_utils.fields.AutoCreatedField', [], {'default': 'datetime.datetime.now'}), - 'description': ('django.db.models.fields.TextField', [], {}), - 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'logo': ('django.db.models.fields.files.ImageField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}), - 'modified': ('model_utils.fields.AutoLastModifiedField', [], {'default': 'datetime.datetime.now'}), - 'name': ('django.db.models.fields.CharField', [], {'max_length': '255', 'db_index': 'True'}) - }, - 'organizations.organizationcourse': { - 'Meta': {'unique_together': "(('course_id', 'organization'),)", 'object_name': 'OrganizationCourse'}, - 'active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), - 'course_id': ('django.db.models.fields.CharField', [], {'max_length': '255', 'db_index': 'True'}), - 'created': ('model_utils.fields.AutoCreatedField', [], {'default': 'datetime.datetime.now'}), - 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'modified': ('model_utils.fields.AutoLastModifiedField', [], {'default': 'datetime.datetime.now'}), - 'organization': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['organizations.Organization']"}) - } - } - - complete_apps = ['organizations'] \ No newline at end of file diff --git a/organizations/migrations/0003_auto__add_field_organization_short_name.py b/organizations/migrations/0003_auto__add_field_organization_short_name.py deleted file mode 100644 index a83b4771..00000000 --- a/organizations/migrations/0003_auto__add_field_organization_short_name.py +++ /dev/null @@ -1,45 +0,0 @@ -# -*- coding: utf-8 -*- -from south.utils import datetime_utils as datetime -from south.db import db -from south.v2 import SchemaMigration -from django.db import models - - -class Migration(SchemaMigration): - - def forwards(self, orm): - # Adding field 'Organization.short_name' - db.add_column('organizations_organization', 'short_name', - self.gf('django.db.models.fields.CharField')(default='', max_length=255, db_index=True), - keep_default=False) - - - def backwards(self, orm): - # Deleting field 'Organization.short_name' - db.delete_column('organizations_organization', 'short_name') - - - models = { - 'organizations.organization': { - 'Meta': {'object_name': 'Organization'}, - 'active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), - 'created': ('model_utils.fields.AutoCreatedField', [], {'default': 'datetime.datetime.now'}), - 'description': ('django.db.models.fields.TextField', [], {}), - 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'logo': ('django.db.models.fields.files.ImageField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}), - 'modified': ('model_utils.fields.AutoLastModifiedField', [], {'default': 'datetime.datetime.now'}), - 'name': ('django.db.models.fields.CharField', [], {'max_length': '255', 'db_index': 'True'}), - 'short_name': ('django.db.models.fields.CharField', [], {'max_length': '255', 'db_index': 'True'}) - }, - 'organizations.organizationcourse': { - 'Meta': {'unique_together': "(('course_id', 'organization'),)", 'object_name': 'OrganizationCourse'}, - 'active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), - 'course_id': ('django.db.models.fields.CharField', [], {'max_length': '255', 'db_index': 'True'}), - 'created': ('model_utils.fields.AutoCreatedField', [], {'default': 'datetime.datetime.now'}), - 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'modified': ('model_utils.fields.AutoLastModifiedField', [], {'default': 'datetime.datetime.now'}), - 'organization': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['organizations.Organization']"}) - } - } - - complete_apps = ['organizations'] \ No newline at end of file diff --git a/organizations/tests/test_api.py b/organizations/tests/test_api.py index 98710940..d818e8c7 100644 --- a/organizations/tests/test_api.py +++ b/organizations/tests/test_api.py @@ -150,14 +150,14 @@ def test_get_organization_invalid_organization(self): def test_remove_organization(self): """ Unit Test: test_remove_organization """ - with self.assertNumQueries(4): + with self.assertNumQueries(3): api.remove_organization(self.test_organization['id']) with self.assertRaises(exceptions.InvalidOrganizationException): api.get_organization(self.test_organization['id']) def test_remove_organization_bogus_organization(self): """ Unit Test: test_remove_organization_bogus_organization """ - with self.assertNumQueries(4): + with self.assertNumQueries(3): api.remove_organization(self.test_organization['id']) with self.assertRaises(exceptions.InvalidOrganizationException): @@ -197,7 +197,7 @@ def test_add_organization_course_inactive_to_active(self): self.test_course_key ) api.remove_organization_course(self.test_organization, self.test_course_key) - with self.assertNumQueries(4): + with self.assertNumQueries(3): api.add_organization_course( self.test_organization, self.test_course_key @@ -230,7 +230,7 @@ def test_remove_organization_course(self): ) organizations = api.get_course_organizations(self.test_course_key) self.assertEqual(len(organizations), 1) - with self.assertNumQueries(4): + with self.assertNumQueries(3): api.remove_organization_course(self.test_organization, self.test_course_key) organizations = api.get_course_organizations(self.test_course_key) self.assertEqual(len(organizations), 0) @@ -265,6 +265,6 @@ def test_remove_course_references(self): self.assertEqual(len(api.get_organization_courses(self.test_organization)), 1) # Remove the course dependency - with self.assertNumQueries(3): + with self.assertNumQueries(2): api.remove_course_references(self.test_course_key) self.assertEqual(len(api.get_organization_courses(self.test_organization)), 0) diff --git a/requirements.txt b/requirements.txt index d1a77753..7e101f48 100755 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,6 @@ # Django/Framework Packages -django==1.4.12 +django>1.8,<1.9 django-model-utils==1.4.0 -South>=0.7.6 # Testing Packages coverage==3.7.1 diff --git a/settings.py b/settings.py index 5fb100f2..8d1be8d4 100644 --- a/settings.py +++ b/settings.py @@ -23,7 +23,6 @@ 'organizations', 'django_nose', - 'south', ) MIDDLEWARE_CLASSES = { diff --git a/setup.py b/setup.py index d4d68613..8b53cb8e 100755 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ setup( name='edx-organizations', - version='0.1.6', + version='1.0', description='Organization management module for Open edX', long_description=open('README.md').read(), author='edX', @@ -23,9 +23,8 @@ dependency_links=[ ], install_requires=[ - "django>=1.4.12", + "django>=1.8", "django-model-utils==1.4.0", - "South>=0.7.6", ], tests_require=[ "coverage==3.7.1", From 3e10879335ab0b7500932e0e8dd59effbe3a89eb Mon Sep 17 00:00:00 2001 From: muhammad-ammar Date: Fri, 6 Nov 2015 12:11:01 +0500 Subject: [PATCH 2/3] bump library version --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 8b53cb8e..7dd809c1 100755 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ setup( name='edx-organizations', - version='1.0', + version='0.1.7', description='Organization management module for Open edX', long_description=open('README.md').read(), author='edX', From 2daa4a8059672fa5c1956ed44dccc00230641325 Mon Sep 17 00:00:00 2001 From: asadiqbal Date: Thu, 12 Nov 2015 13:09:52 +0500 Subject: [PATCH 3/3] SOL-1380 --- organizations/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/organizations/models.py b/organizations/models.py index 7e32b257..1ae1e1a6 100644 --- a/organizations/models.py +++ b/organizations/models.py @@ -23,7 +23,7 @@ class Organization(TimeStampedModel): description = models.TextField() logo = models.ImageField( upload_to='organization_logos', - help_text=_(u'Organization logo file. It should be an image.'), + help_text=_(u'Please add only .PNG files for logo images.'), null=True, blank=True, max_length=255 ) active = models.BooleanField(default=True)