Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CollaborationPolicyRecord - instantiate policy rules from the policy_…
…record * Remove AppConfig, CollaborationPolicy registration/caching messiness * Data migration ensures all valid policies are in the CollaborationPolicyRecord * Instantiate the CollaborationPolicy directly from CollaborationPolicyRecord (note: removes a layer of caching. possible speed hit)
- Loading branch information
Showing
7 changed files
with
76 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
[{"pk": 1, "model": "projects.project", "fields": {"body": "<p>The Columbia Center for New Media Teaching and Learning (CCNMTL) was founded at Columbia University in 1999 to enhance teaching and learning through the purposeful use of new media and technology. In partnership with faculty, the Center supports efforts ranging from basic course website management to advanced project development. <span class=\"caps\">CCNMTL </span>is committed to remaining a leader in the field of new media teaching and learning, engaging faculty, educators, librarians, partner institutions, and the community in the reinvention of education for the digital age.</p>\r\n<p>We are committed to ongoing evaluation of the efficacy of our work within the University.</p>\r\n<p> </p>\r\n<p>The Armory - Home to CCNMTL's CUMC Office</p>\r\n<p><a class=\"materialCitation asset-image asset-whole\" href=\"/asset/3/annotations/7/\">Left Corner</a></p>\r\n<p> </p>\r\n<p>Some of our awards. Maurice & Frank</p>\r\n<p><a class=\"materialCitation asset-image asset-whole\" href=\"/asset/2/annotations/5/\">Our esteemed leaders</a></p>", "project_type": "assignment", "author": 2, "title": "Sample Assignment", "modified": "2012-05-26 15:11:25", "date_submitted": "2012-05-26 15:11:25", "course": 1, "participants": [2]}}, {"pk": 2, "model": "projects.project", "fields": {"body": "<p>The Columbia Center for New Teaching and Learning was (CCNMTL)</p>\r\n<p>                    was founded at Columbia University in 1999 to enhance teaching and</p>\r\n<p>                    learning through the purposeful use of new media and technology</p>", "author": 3, "title": "Sample Assignment Response", "modified": "2012-05-26 15:17:06", "date_submitted": "2012-05-26 15:11:25", "course": 1, "participants": [3]}}, {"pk": 1, "model": "structuredcollaboration.collaborationpolicyrecord", "fields": {"policy_name": "PrivateEditorsAreOwners"}}, {"pk": 2, "model": "structuredcollaboration.collaborationpolicyrecord", "fields": {"policy_name": "CourseProtected"}}, {"pk": 3, "model": "structuredcollaboration.collaborationpolicyrecord", "fields": {"policy_name": "InstructorShared"}}, {"pk": 2, "model": "structuredcollaboration.collaboration", "fields": {"group": null, "context": 1, "title": "Sample Assignment", "policy_record": 2, "object_pk": "1", "_parent": null, "user": 2, "content_type": 21, "slug": null}}, {"pk": 3, "model": "structuredcollaboration.collaboration", "fields": {"group": null, "context": 1, "title": "Sample Assignment Response", "policy_record": 3, "object_pk": "2", "_parent": 2, "user": 3, "content_type": 21, "slug": null}}, {"pk": 1, "model": "structuredcollaboration.collaboration", "fields": {"group": 2, "context": null, "title": "Sample Course", "policy_record": null, "object_pk": "1", "_parent": null, "user": null, "content_type": 8, "slug": "Sample_Course"}}] | ||
[{"pk": 1, "model": "projects.project", "fields": {"body": "<p>The Columbia Center for New Media Teaching and Learning (CCNMTL) was founded at Columbia University in 1999 to enhance teaching and learning through the purposeful use of new media and technology. In partnership with faculty, the Center supports efforts ranging from basic course website management to advanced project development. <span class=\"caps\">CCNMTL </span>is committed to remaining a leader in the field of new media teaching and learning, engaging faculty, educators, librarians, partner institutions, and the community in the reinvention of education for the digital age.</p>\r\n<p>We are committed to ongoing evaluation of the efficacy of our work within the University.</p>\r\n<p> </p>\r\n<p>The Armory - Home to CCNMTL's CUMC Office</p>\r\n<p><a class=\"materialCitation asset-image asset-whole\" href=\"/asset/3/annotations/7/\">Left Corner</a></p>\r\n<p> </p>\r\n<p>Some of our awards. Maurice & Frank</p>\r\n<p><a class=\"materialCitation asset-image asset-whole\" href=\"/asset/2/annotations/5/\">Our esteemed leaders</a></p>", "project_type": "assignment", "author": 2, "title": "Sample Assignment", "modified": "2012-05-26 15:11:25", "date_submitted": "2012-05-26 15:11:25", "course": 1, "participants": [2]}}, {"pk": 2, "model": "projects.project", "fields": {"body": "<p>The Columbia Center for New Teaching and Learning was (CCNMTL)</p>\r\n<p>                    was founded at Columbia University in 1999 to enhance teaching and</p>\r\n<p>                    learning through the purposeful use of new media and technology</p>", "author": 3, "title": "Sample Assignment Response", "modified": "2012-05-26 15:17:06", "date_submitted": "2012-05-26 15:11:25", "course": 1, "participants": [3]}}, {"pk": 2, "model": "structuredcollaboration.collaboration", "fields": {"group": null, "context": 1, "title": "Sample Assignment", "policy_record": 2, "object_pk": "1", "_parent": null, "user": 2, "content_type": 21, "slug": null}}, {"pk": 3, "model": "structuredcollaboration.collaboration", "fields": {"group": null, "context": 1, "title": "Sample Assignment Response", "policy_record": 3, "object_pk": "2", "_parent": 2, "user": 3, "content_type": 21, "slug": null}}, {"pk": 1, "model": "structuredcollaboration.collaboration", "fields": {"group": 2, "context": null, "title": "Sample Course", "policy_record": null, "object_pk": "1", "_parent": null, "user": null, "content_type": 8, "slug": "Sample_Course"}}] |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +0,0 @@ | ||
default_app_config = 'structuredcollaboration.apps.CollaborationPolicyConfig' | ||
This file was deleted.
Oops, something went wrong.
56 changes: 56 additions & 0 deletions
56
structuredcollaboration/migrations/0004_auto_20151016_1401.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# -*- coding: utf-8 -*- | ||
from __future__ import unicode_literals | ||
|
||
from django.db import migrations | ||
|
||
|
||
def get_or_create_policies(apps, schema_editor): | ||
CollaborationPolicyRecord = apps.get_model('structuredcollaboration', | ||
'CollaborationPolicyRecord') | ||
|
||
valid_policies = [ | ||
'PrivateEditorsAreOwners', | ||
'PublicEditorsAreOwners', | ||
'PrivateStudentAndFaculty', | ||
'CourseProtected', | ||
'InstructorShared', | ||
'InstructorManaged', | ||
'CourseCollaboration' | ||
] | ||
|
||
for p in valid_policies: | ||
CollaborationPolicyRecord.objects.get_or_create(policy_name=p) | ||
|
||
|
||
def deprecate_policies(apps, schema_editor): | ||
invalid_policies = [ | ||
'Assignment', | ||
'PublicAssignment' | ||
] | ||
|
||
CollaborationPolicyRecord = apps.get_model('structuredcollaboration', | ||
'CollaborationPolicyRecord') | ||
Collaboration = apps.get_model('structuredcollaboration', | ||
'Collaboration') | ||
|
||
course_protected = CollaborationPolicyRecord.objects.get( | ||
policy_name='CourseProtected') | ||
|
||
for p in invalid_policies: | ||
policies = Collaboration.objects.filter(policy_record__policy_name=p) | ||
policies.update(policy_record=course_protected) | ||
|
||
CollaborationPolicyRecord.objects.filter( | ||
policy_name__in=invalid_policies).delete() | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('structuredcollaboration', '0003_auto_20150509_1914'), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython(get_or_create_policies), | ||
migrations.RunPython(deprecate_policies) | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters