From 7db5b614e028299bf2e2302fcba4510374d775c9 Mon Sep 17 00:00:00 2001 From: eric miller Date: Thu, 29 Nov 2012 16:16:58 -0500 Subject: [PATCH 001/515] modifying gitignore to ignore emacs versions --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index c7bcf560..1d1429e5 100644 --- a/.gitignore +++ b/.gitignore @@ -31,3 +31,5 @@ MANIFEST .hg/* .hgignore .hgtags +*~ +*# From f46eb0e8323ebefde2b02c2b71ce5dc1008929bf Mon Sep 17 00:00:00 2001 From: eric miller Date: Thu, 29 Nov 2012 16:19:08 -0500 Subject: [PATCH 002/515] first pass at bootstrap variable display --- .../static/exhibit/js/views/record-pager.js | 2 - freemix/static/freemix/css/editor.css | 6 - freemix/templates/dataset/base.html | 15 +- .../templates/dataset/dataset_list_item.html | 76 +- freemix/templates/dataset/edit/base.html | 56 +- freemix/templates/exhibit/base.html | 16 +- .../templates/exhibit/exhibit_list_item.html | 127 +- freemix/templates/exhibit/list/base.html | 15 +- .../images/glyphicons-halflings-white.png | Bin 0 -> 8777 bytes .../static/images/glyphicons-halflings.png | Bin 0 -> 12799 bytes recollection/static/scripts/bootstrap.js | 2027 ++++++ recollection/static/scripts/bootstrap.min.js | 6 + .../static/site_theme/css/default/base.css | 4 +- .../default/images/viewshare-logo-thin.png | Bin 0 -> 8406 bytes .../static/site_theme/css/homepage/base.css | 2 +- .../static/site_theme/css/solid/base.css | 2 +- .../stylesheets/bootstrap-responsive.css | 1040 +++ .../stylesheets/bootstrap-responsive.min.css | 9 + recollection/static/stylesheets/bootstrap.css | 5624 +++++++++++++++++ .../static/stylesheets/bootstrap.min.css | 9 + recollection/static/stylesheets/bootstrap.zip | Bin 0 -> 80216 bytes recollection/static/stylesheets/style.css | 341 +- recollection/static/themes/chili/chili.css | 38 - recollection/templates/base.html | 136 +- recollection/templates/messages/base.html | 8 +- recollection/templates/profiles/base.html | 13 +- recollection/templates/profiles/profile.html | 341 +- .../templates/profiles/profile_form.html | 2 +- .../profiles/profile_right_panel.html | 8 +- recollection/templates/site_base.html | 31 +- 30 files changed, 9165 insertions(+), 789 deletions(-) create mode 100644 recollection/static/images/glyphicons-halflings-white.png create mode 100644 recollection/static/images/glyphicons-halflings.png create mode 100644 recollection/static/scripts/bootstrap.js create mode 100644 recollection/static/scripts/bootstrap.min.js create mode 100644 recollection/static/site_theme/css/default/images/viewshare-logo-thin.png create mode 100644 recollection/static/stylesheets/bootstrap-responsive.css create mode 100644 recollection/static/stylesheets/bootstrap-responsive.min.css create mode 100644 recollection/static/stylesheets/bootstrap.css create mode 100644 recollection/static/stylesheets/bootstrap.min.css create mode 100644 recollection/static/stylesheets/bootstrap.zip diff --git a/freemix/static/exhibit/js/views/record-pager.js b/freemix/static/exhibit/js/views/record-pager.js index 6112ed8e..bddaaf78 100644 --- a/freemix/static/exhibit/js/views/record-pager.js +++ b/freemix/static/exhibit/js/views/record-pager.js @@ -172,8 +172,6 @@ nextRecord(model); populateRecordDisplay(model); }).parent().buttonset(); - root.find(".right-record-button").addClass("ui-corner-right"); - root.find(".left-record-button").addClass("ui-corner-left"); populateRecordDisplay(model); }); diff --git a/freemix/static/freemix/css/editor.css b/freemix/static/freemix/css/editor.css index 01ecbf5a..2e073e3f 100644 --- a/freemix/static/freemix/css/editor.css +++ b/freemix/static/freemix/css/editor.css @@ -63,12 +63,6 @@ font-size: 90%; .record-controls button { } -.data-property-add { - float: right; - margin-right: 10px; - font-size: 70%; -} - .data-record-delete, .data-refresh { } diff --git a/freemix/templates/dataset/base.html b/freemix/templates/dataset/base.html index d2ed5d08..86349380 100644 --- a/freemix/templates/dataset/base.html +++ b/freemix/templates/dataset/base.html @@ -8,15 +8,12 @@ {% block subnav %} {% if user.is_authenticated %} -
- -
+
  • {% trans "Your Data" %}
  • +
  • {%blocktrans%}Your Connections' Data{%endblocktrans %}
  • +{% comment %}set by instance policy +
  • {% trans "All Data" %}
  • +{% endcomment %} +{% block extra_subnav %}{% endblock %} {% else %} {% block unauthenticated_subnav %}{% endblock %} {% endif %} diff --git a/freemix/templates/dataset/dataset_list_item.html b/freemix/templates/dataset/dataset_list_item.html index 80f0dc00..e1e0c833 100644 --- a/freemix/templates/dataset/dataset_list_item.html +++ b/freemix/templates/dataset/dataset_list_item.html @@ -27,51 +27,51 @@ {% endifnotequal %} {% endif %} -{% with exhibits.count as exhibits_count %} - -{% endwith %} - {% if can_view %} - -
    - - -
    - -
    - -
    +
    diff --git a/freemix/templates/exhibit/edit/views/piechart-view.html b/freemix/templates/exhibit/edit/views/piechart-view.html index f127e91c..4e5f5b5c 100644 --- a/freemix/templates/exhibit/edit/views/piechart-view.html +++ b/freemix/templates/exhibit/edit/views/piechart-view.html @@ -31,12 +31,7 @@ - -
    - -
    - -
    + diff --git a/freemix/templates/exhibit/edit/views/scatterplot-view.html b/freemix/templates/exhibit/edit/views/scatterplot-view.html index 1348a9ca..42cec3d8 100644 --- a/freemix/templates/exhibit/edit/views/scatterplot-view.html +++ b/freemix/templates/exhibit/edit/views/scatterplot-view.html @@ -58,12 +58,7 @@ - -
    - -
    - -
    + diff --git a/freemix/templates/exhibit/edit/views/table-view.html b/freemix/templates/exhibit/edit/views/table-view.html index a6be8ef3..77c6e6b6 100644 --- a/freemix/templates/exhibit/edit/views/table-view.html +++ b/freemix/templates/exhibit/edit/views/table-view.html @@ -43,13 +43,7 @@ - -
    - -
    - -
    - + diff --git a/freemix/templates/exhibit/edit/views/thumbnail-view.html b/freemix/templates/exhibit/edit/views/thumbnail-view.html index 2833ea3b..a27e9a0c 100644 --- a/freemix/templates/exhibit/edit/views/thumbnail-view.html +++ b/freemix/templates/exhibit/edit/views/thumbnail-view.html @@ -60,12 +60,6 @@ - -
    - -
    - -
    diff --git a/freemix/templates/exhibit/edit/views/timeline-view.html b/freemix/templates/exhibit/edit/views/timeline-view.html index fdfbf478..79259805 100644 --- a/freemix/templates/exhibit/edit/views/timeline-view.html +++ b/freemix/templates/exhibit/edit/views/timeline-view.html @@ -112,12 +112,6 @@ -
    - -
    - -
    - diff --git a/viewshare/templates/profiles/profile.html b/viewshare/templates/profiles/profile.html index 2df9e29d..9a76601d 100644 --- a/viewshare/templates/profiles/profile.html +++ b/viewshare/templates/profiles/profile.html @@ -26,6 +26,8 @@ {% include "freemix/js_include/jquery_ui.html" %} + {% if is_me %} + + + {% endif %} {% endblock head_scripts %} {# check to see if the user being inspected is user logged in #} From 5c418a8cfc636de6cf132f3b0740b2620158ed29 Mon Sep 17 00:00:00 2001 From: Bill Amberg Date: Tue, 9 Jul 2013 13:44:01 +0000 Subject: [PATCH 112/515] Display a TimelineAugmentView inside a modal. Augment date-based properties. --- .../dataset/js/models/editor/property.js | 2 +- .../js/templates/editor/timeline-augment.html | 4 +- .../js/views/editor/modal-augment-view.js | 11 ++- .../js/views/editor/timeline-augment-view.js | 79 +++++++++++++++++++ 4 files changed, 92 insertions(+), 4 deletions(-) create mode 100644 freemix/static/dataset/js/views/editor/timeline-augment-view.js diff --git a/freemix/static/dataset/js/models/editor/property.js b/freemix/static/dataset/js/models/editor/property.js index b0b9abdb..dd50197b 100644 --- a/freemix/static/dataset/js/models/editor/property.js +++ b/freemix/static/dataset/js/models/editor/property.js @@ -94,7 +94,7 @@ define( /** Generate an array used to identify tags in Freemix */ tags: function() { - if (['location'].indexOf(this._type) >= 0) { + if (['location', 'date'].indexOf(this._type) >= 0) { // certain Property types have a special tags value return ['property:type=' + this._type]; } else { diff --git a/freemix/static/dataset/js/templates/editor/timeline-augment.html b/freemix/static/dataset/js/templates/editor/timeline-augment.html index de9b7e94..5b021be7 100644 --- a/freemix/static/dataset/js/templates/editor/timeline-augment.html +++ b/freemix/static/dataset/js/templates/editor/timeline-augment.html @@ -6,7 +6,7 @@ - + @@ -16,7 +16,7 @@ {{#each properties}} - + {{/each}} diff --git a/freemix/static/dataset/js/views/editor/modal-augment-view.js b/freemix/static/dataset/js/views/editor/modal-augment-view.js index b4767df0..e6d24683 100644 --- a/freemix/static/dataset/js/views/editor/modal-augment-view.js +++ b/freemix/static/dataset/js/views/editor/modal-augment-view.js @@ -7,6 +7,7 @@ define( 'text!templates/modal-augment.html', 'views/map-augment-view', 'views/modal-view', + 'views/timeline-augment-view', 'bootstrap', 'freemix.exhibit', 'freemix.property', @@ -18,7 +19,8 @@ define( $, modalAugmentTemplate, MapAugmentView, - ModalView + ModalView, + TimelineAugmentView ) { 'use strict'; /** @@ -54,7 +56,12 @@ define( $el: this.$el.find('#map'), model: this.model.records[0] }); + this.timelineView = new TimelineAugmentView({ + $el: this.$el.find('#timeline'), + model: this.model.records[0] + }); this.mapView.render(); + this.timelineView.render(); }, /** Display a validation error @@ -105,6 +112,7 @@ define( // validate tab's view's Model errorList.empty(); if (activeTab.attr('id') === 'timeline') { + newProperty = this.timelineView.newCompositeProperty; } else if (activeTab.attr('id') === 'map') { newProperty = this.mapView.newCompositeProperty; } else if (activeTab.attr('id') === 'list') { @@ -149,6 +157,7 @@ define( /** Remove event bindings, child views, and DOM elements */ destroy: function() { this.mapView.destroy(); + this.timelineView.destroy(); this.$el.remove(); } }); diff --git a/freemix/static/dataset/js/views/editor/timeline-augment-view.js b/freemix/static/dataset/js/views/editor/timeline-augment-view.js new file mode 100644 index 00000000..8ad7d655 --- /dev/null +++ b/freemix/static/dataset/js/views/editor/timeline-augment-view.js @@ -0,0 +1,79 @@ +/*global define */ +define( + [ + 'handlebars', + 'jquery', + 'models/composite-property', + 'text!templates/timeline-augment.html' + ], function ( + Handlebars, + $, + CompositePropertyModel, + timelineAugmentTemplate + ) { + 'use strict'; + /** + * View that can add a CompositeModel to a RecordCollection. This prepares + * the RecordCollection to be sent to an Akara server for augmentation. + * @constructor + * @param {object} options.model - RecordModel we're augmenting + * @param {object} options.$el - container Element object for this view + */ + var TimelineAugmentView = function(options) { + this.initialize.apply(this, [options]); + }; + + $.extend(TimelineAugmentView.prototype, { + initialize: function(options) { + this.model = options.model; + this.$el = options.$el; + this.newCompositeProperty = new CompositePropertyModel({ + id: undefined, + name: undefined, + type: 'date', + value: undefined, + composite: [] + }); + }, + + /** Compile the template we will use to render the View */ + template: Handlebars.compile(timelineAugmentTemplate), + + /** Event handler when a .name input is changed */ + changeNameHandler: function(event) { + this.newCompositeProperty.name(event.target.value); + }, + + /** Event handler when a .selcted input is clicked */ + changeCompositeHandler: function(event) { + var i = 0, + selected = this.$el.find('.selected input:checked'), + composites = []; + for (i; i < selected.length; ++i) { + composites.push(selected[i].value); + } + this.newCompositeProperty.composite(composites); + }, + + render: function() { + this.$el.html(this.template({ + properties: this.model.properties, + })); + this.$el.find('#new-timeline-property').on( + 'change', this.changeNameHandler.bind(this)); + this.$el.find('.selected input').on( + 'click', this.changeCompositeHandler.bind(this)); + }, + + /** Remove event bindings, child views, and DOM elements */ + destroy: function() { + this.$el.find('.name input').off( + 'change', this.changeNameHandler.bind(this)); + this.$el.find('.selected input').off( + 'click', this.changeCompositeHandler.bind(this)); + this.$el.remove(); + } + }); + + return TimelineAugmentView; +}); From 7fc897de7989a83d4390d7ff9a0bd59ab9e54b0c Mon Sep 17 00:00:00 2001 From: Bill Amberg Date: Tue, 9 Jul 2013 15:32:13 +0000 Subject: [PATCH 113/515] Validate that new CompositePropertyModel objects created during augmentation don't have the same name as an existing property. --- .../js/models/editor/composite-property.js | 9 ++++--- .../dataset/js/models/editor/property.js | 11 +++++--- .../static/dataset/js/models/editor/record.js | 9 +++++++ .../dataset/js/views/editor/editor-view.js | 7 +++-- .../js/views/editor/modal-augment-view.js | 26 +++++++++++++------ 5 files changed, 46 insertions(+), 16 deletions(-) diff --git a/freemix/static/dataset/js/models/editor/composite-property.js b/freemix/static/dataset/js/models/editor/composite-property.js index e5cacc62..d23ade2b 100644 --- a/freemix/static/dataset/js/models/editor/composite-property.js +++ b/freemix/static/dataset/js/models/editor/composite-property.js @@ -67,11 +67,14 @@ define( /** * Validate that the data in this Model is in a state where it could * be sent to a server. + * @param {array} propertyNames - names that already exist and should not + * be duplicated */ - validate: function() { - var errors = PropertyModel.prototype.validate.apply(this, []); + validate: function(propertyNames) { + var existingNames = propertyNames || [], + errors = PropertyModel.prototype.validate.apply(this, [existingNames]); if (!this._composite.length) { - errors['composite'] = 'Please select at least one property.'; + errors.composite = 'Please select at least one property.'; } return errors; } diff --git a/freemix/static/dataset/js/models/editor/property.js b/freemix/static/dataset/js/models/editor/property.js index dd50197b..59e05bfc 100644 --- a/freemix/static/dataset/js/models/editor/property.js +++ b/freemix/static/dataset/js/models/editor/property.js @@ -117,11 +117,16 @@ define( /** * Validate that the data in this Model is in a state where it could * be sent to a server. + * @param {array} propertyNames - names that already exist and should not + * be duplicated */ - validate: function() { - var errors = {}; + validate: function(propertyNames) { + var errors = {}, + existingNames = propertyNames || []; if (!this._name) { - errors['name'] = 'Please enter a name for the new property.'; + errors.name = 'Please enter a name for the new property.'; + } else if (existingNames.indexOf(this._name) >= 0) { + errors.name = 'Please enter a unique property name.'; } return errors; } diff --git a/freemix/static/dataset/js/models/editor/record.js b/freemix/static/dataset/js/models/editor/record.js index d8d28bf3..1d7d8217 100644 --- a/freemix/static/dataset/js/models/editor/record.js +++ b/freemix/static/dataset/js/models/editor/record.js @@ -47,6 +47,15 @@ define( }); }, + /** Return an array of PropertyModel.name values in this Record */ + propertyNames: function() { + var i, names = []; + for (i = 0; i < this.properties.length; ++i) { + names.push(this.properties[i].name()); + } + return names; + }, + /** * When any PropertyModel.type in this.properties changes this is run. * @param {string} published.name - Name of the PropertyModel being changed diff --git a/freemix/static/dataset/js/views/editor/editor-view.js b/freemix/static/dataset/js/views/editor/editor-view.js index a8df36b2..d5bf01cc 100644 --- a/freemix/static/dataset/js/views/editor/editor-view.js +++ b/freemix/static/dataset/js/views/editor/editor-view.js @@ -34,7 +34,10 @@ define( this.$el = options.$el; this.notificationView = options.notificationView; // child views - this.augmentModal = new ModalAugmentView({model: this.model}); + this.augmentModal = new ModalAugmentView({ + model: this.model, + notificationView: this.notificationView + }); this.recordView = {destroy: $.noop}; // bind 'this' to template variables and event handlers this.currentRecordNumber.bind(this); @@ -142,7 +145,7 @@ define( handleSaveSuccess: function () { // TODO: loading gif this.destroyChildren(); - this.model.loadLocal.apply(this.model, []) + this.model.loadLocal.apply(this.model, []); this.renderChildrenViews(); }, diff --git a/freemix/static/dataset/js/views/editor/modal-augment-view.js b/freemix/static/dataset/js/views/editor/modal-augment-view.js index e6d24683..251cf9ff 100644 --- a/freemix/static/dataset/js/views/editor/modal-augment-view.js +++ b/freemix/static/dataset/js/views/editor/modal-augment-view.js @@ -28,6 +28,8 @@ define( * properties to a dataset. * @constructor * @param {object} options.model - RecordCollection we're augmenting + * @param {object} options.notificationView - View used to + * render notifications */ var ModalAugmentView = function(options) { this.initialize.apply(this, [options]); @@ -43,7 +45,9 @@ define( buttonText: 'Create Property', buttonFunction: this.createProperty.bind(this) }).$el; + this.notificationView = options.notificationView; this.mapView = {destroy: $.noop}; + this.timelineView = {destroy: $.noop}; }, /** Compile the template we will use to render the View */ @@ -79,6 +83,9 @@ define( var augmentErrors = data.failed || {}, augmentedProperties = [], freemixDatabase = Freemix.exhibit.database, + freemixRemoveObjects = function(i, id) { + freemixDatabase.removeObjects(id,p); + }, i = 0, p; // Add augmented data to Freemix database $.each(Freemix.property.propertyList, function(name, prop){ @@ -88,9 +95,7 @@ define( }); for (i; i < augmentedProperties.length ; i++) { p = augmentedProperties[i]; - $.each(freemixDatabase.getAllItems(), function(i, id) { - freemixDatabase.removeObjects(id,p); - }); + $.each(freemixDatabase.getAllItems(), freemixRemoveObjects); } freemixDatabase.loadData({'items': data.items}); // Add augmented data to record-collection @@ -100,7 +105,11 @@ define( /** Actions to take on an augmentation server error */ augmentFailure: function(XMLHttpRequest, textStatus, errorThrown) { - console.log('failure'); + this.notificationView.addNotification( + 'error', + 'There was a server error during the data augmentation. Please try again later.', + 'Augmentation Error!' + ); }, /** Handle the 'Create Property' button click by augmenting data */ @@ -108,7 +117,7 @@ define( var activeTab = this.$el.find('.tab-content .active'), errorList = this.$el.find('#augment-errors'), errors = {}, - freemixDatabase, newProperty, postData; + freemixDatabase, newProperty, postData, propertyNames; // validate tab's view's Model errorList.empty(); if (activeTab.attr('id') === 'timeline') { @@ -120,7 +129,7 @@ define( console.log(activeTab); return false; } - errors = newProperty.validate(); + errors = newProperty.validate(this.model.records[0].propertyNames()); if ($.isEmptyObject(errors)) { // extend Freemix database with new Model by calling Property model's createFreemixProperty() Freemix.property.add(newProperty.createFreemixProperty()); @@ -144,11 +153,12 @@ define( this.$el.modal('hide'); } else { // display client-side form validation errors + this.$el.find('.modal-body').animate({ scrollTop: 0}, 'fast'); if (errors.hasOwnProperty('name')) { - this.renderValidationError(errors['name']); + this.renderValidationError(errors.name); } if (errors.hasOwnProperty('composite')) { - this.renderValidationError(errors['composite']); + this.renderValidationError(errors.composite); } return false; } From f96342840d7b7673d6ee10e0eb04c23cca03ddc9 Mon Sep 17 00:00:00 2001 From: Bill Amberg Date: Thu, 11 Jul 2013 18:46:04 +0000 Subject: [PATCH 114/515] Create PatternPropertyModel and ListAugmentView for splitting data that follows an identifiable patter (such as CSV). This implementation is not complete as the way we store Exhibits is about to change. --- .../js/models/editor/composite-property.js | 5 + .../js/models/editor/pattern-property.js | 92 +++++++++++++++++++ .../dataset/js/models/editor/property.js | 7 +- .../js/templates/editor/list-augment.html | 38 ++++++++ .../js/templates/editor/modal-augment.html | 9 +- .../js/views/editor/list-augment-view.js | 79 ++++++++++++++++ .../js/views/editor/modal-augment-view.js | 10 ++ 7 files changed, 226 insertions(+), 14 deletions(-) create mode 100644 freemix/static/dataset/js/models/editor/pattern-property.js create mode 100644 freemix/static/dataset/js/templates/editor/list-augment.html create mode 100644 freemix/static/dataset/js/views/editor/list-augment-view.js diff --git a/freemix/static/dataset/js/models/editor/composite-property.js b/freemix/static/dataset/js/models/editor/composite-property.js index d23ade2b..ada4164f 100644 --- a/freemix/static/dataset/js/models/editor/composite-property.js +++ b/freemix/static/dataset/js/models/editor/composite-property.js @@ -51,6 +51,11 @@ define( } }, + /** Generate an array used to identify tags in Freemix */ + tags: function() { + return ['property:type=' + this._type]; + }, + /** Create a Freemix Property with our Model's data */ createFreemixProperty: function() { var freemixProperty = { diff --git a/freemix/static/dataset/js/models/editor/pattern-property.js b/freemix/static/dataset/js/models/editor/pattern-property.js new file mode 100644 index 00000000..a744dd49 --- /dev/null +++ b/freemix/static/dataset/js/models/editor/pattern-property.js @@ -0,0 +1,92 @@ +/*global define */ +define( + [ + 'freemix', + 'jquery', + 'models/property', + 'freemix.exhibit', + 'freemix.property', + 'freemix.identify' + ], + function ( + Freemix, + $, + PropertyModel + ) { + 'use strict'; + + /** + * Extends PropertyModel. Represents a property that is created from other + * properties such an array created from a comma-separated value. + * @param {string} options.extract - label of other property used to + * create this PatternProperty + */ + var PatternPropertyModel = function(options) { + this.initialize.apply(this, [options]); + }; + + $.extend(PatternPropertyModel.prototype, PropertyModel.prototype, { + initialize: function(options) { + PropertyModel.prototype.initialize.apply(this, [options]); + this._extract = options.extract; + if (Freemix.property.propertyList && Freemix.property.propertyList.hasOwnProperty(this.id)) { + // this is an existing Property + this.freemixProperty = Freemix.property.propertyList[this.id]; + } else { + // this is a new property and doesn't exist in Freemix yet + this.freemixProperty = undefined; + } + }, + + /** + * getter/setter method - extract is the name of the PropertyModel + * that this PatternPropertyModel originates from. + */ + extract: function(newPattern) { + if (newPattern) { + this._extract = newPattern; + if (this.freemixProperty) { + // This is not a new Property so we can modify it in Freemix + this.freemixProperty.label(this._extract); + } + } else { + return this._extract; + } + }, + + /** Generate an array used to identify tags in Freemix */ + tags: function() { + return ['property:type=text', 'property:type=shredded_list']; + }, + + /** Create a Freemix Property with our Model's data */ + createFreemixProperty: function() { + var freemixProperty = { + property: this._name, + label: this._name, + enabled: true, + tags: this.tags(), + types: [this._type], + extract: this.extract() + }; + return freemixProperty; + }, + + /** + * Validate that the data in this Model is in a state where it could + * be sent to a server. + * @param {array} propertyNames - names that already exist and should not + * be duplicated + */ + validate: function(propertyNames) { + var existingNames = propertyNames || [], + errors = PropertyModel.prototype.validate.apply(this, [existingNames]); + if (!this._extract.length) { + errors.extract = 'Please select at least one property.'; + } + return errors; + } + }); + + return PatternPropertyModel; +}); diff --git a/freemix/static/dataset/js/models/editor/property.js b/freemix/static/dataset/js/models/editor/property.js index 59e05bfc..9e345bb3 100644 --- a/freemix/static/dataset/js/models/editor/property.js +++ b/freemix/static/dataset/js/models/editor/property.js @@ -94,12 +94,7 @@ define( /** Generate an array used to identify tags in Freemix */ tags: function() { - if (['location', 'date'].indexOf(this._type) >= 0) { - // certain Property types have a special tags value - return ['property:type=' + this._type]; - } else { - return []; - } + return []; }, /** Create a Freemix Property with our Model's data */ diff --git a/freemix/static/dataset/js/templates/editor/list-augment.html b/freemix/static/dataset/js/templates/editor/list-augment.html new file mode 100644 index 00000000..eb9de4ec --- /dev/null +++ b/freemix/static/dataset/js/templates/editor/list-augment.html @@ -0,0 +1,38 @@ +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    Base the new Latitude/Longitude field on your existing dataBase the new Date/Time field on your existing data
    Selected
    {{ this.name }}
    + + + + + + + + + {{#each properties}} + + + + + {{/each}} + +
    Create the list from your existing data.
    SelectedName
    {{ this.name }}
    + diff --git a/freemix/static/dataset/js/templates/editor/modal-augment.html b/freemix/static/dataset/js/templates/editor/modal-augment.html index 35c21543..698f5996 100644 --- a/freemix/static/dataset/js/templates/editor/modal-augment.html +++ b/freemix/static/dataset/js/templates/editor/modal-augment.html @@ -9,12 +9,5 @@

    View for Field

    -
    -
    - -
    - -
    -
    -
    +
    diff --git a/freemix/static/dataset/js/views/editor/list-augment-view.js b/freemix/static/dataset/js/views/editor/list-augment-view.js new file mode 100644 index 00000000..f416667e --- /dev/null +++ b/freemix/static/dataset/js/views/editor/list-augment-view.js @@ -0,0 +1,79 @@ +/*global define */ +define( + [ + 'handlebars', + 'jquery', + 'models/composite-property', + 'text!templates/list-augment.html' + ], function ( + Handlebars, + $, + CompositePropertyModel, + listAugmentTemplate + ) { + 'use strict'; + /** + * View that can add a CompositeModel to a RecordCollection. This prepares + * the RecordCollection to be sent to an Akara server for augmentation. + * @constructor + * @param {object} options.model - RecordModel we're augmenting + * @param {object} options.$el - container Element object for this view + */ + var ListAugmentView = function(options) { + this.initialize.apply(this, [options]); + }; + + $.extend(ListAugmentView.prototype, { + initialize: function(options) { + this.model = options.model; + this.$el = options.$el; + this.newCompositeProperty = new CompositePropertyModel({ + id: undefined, + name: undefined, + type: 'date', + value: undefined, + composite: [] + }); + }, + + /** Compile the template we will use to render the View */ + template: Handlebars.compile(listAugmentTemplate), + + /** Event handler when a .name input is changed */ + changeNameHandler: function(event) { + this.newCompositeProperty.name(event.target.value); + }, + + /** Event handler when a .selcted input is clicked */ + changeCompositeHandler: function(event) { + var i = 0, + selected = this.$el.find('.selected input:checked'), + composites = []; + for (i; i < selected.length; ++i) { + composites.push(selected[i].value); + } + this.newCompositeProperty.composite(composites); + }, + + render: function() { + this.$el.html(this.template({ + properties: this.model.properties, + })); + this.$el.find('#new-list-property').on( + 'change', this.changeNameHandler.bind(this)); + this.$el.find('.selected input').on( + 'click', this.changeCompositeHandler.bind(this)); + }, + + /** Remove event bindings, child views, and DOM elements */ + destroy: function() { + this.$el.find('.name input').off( + 'change', this.changeNameHandler.bind(this)); + this.$el.find('.selected input').off( + 'click', this.changeCompositeHandler.bind(this)); + this.$el.remove(); + } + }); + + return ListAugmentView; +}); diff --git a/freemix/static/dataset/js/views/editor/modal-augment-view.js b/freemix/static/dataset/js/views/editor/modal-augment-view.js index 251cf9ff..89fb7efe 100644 --- a/freemix/static/dataset/js/views/editor/modal-augment-view.js +++ b/freemix/static/dataset/js/views/editor/modal-augment-view.js @@ -5,6 +5,7 @@ define( 'handlebars', 'jquery', 'text!templates/modal-augment.html', + 'views/list-augment-view', 'views/map-augment-view', 'views/modal-view', 'views/timeline-augment-view', @@ -18,6 +19,7 @@ define( Handlebars, $, modalAugmentTemplate, + ListAugmentView, MapAugmentView, ModalView, TimelineAugmentView @@ -46,6 +48,7 @@ define( buttonFunction: this.createProperty.bind(this) }).$el; this.notificationView = options.notificationView; + this.listView = {destroy: $.noop}; this.mapView = {destroy: $.noop}; this.timelineView = {destroy: $.noop}; }, @@ -56,6 +59,10 @@ define( render: function() { $('body').append(this.$el); // render children + this.listView = new ListAugmentView({ + $el: this.$el.find('#list'), + model: this.model.records[0] + }); this.mapView = new MapAugmentView({ $el: this.$el.find('#map'), model: this.model.records[0] @@ -64,6 +71,7 @@ define( $el: this.$el.find('#timeline'), model: this.model.records[0] }); + this.listView.render(); this.mapView.render(); this.timelineView.render(); }, @@ -125,6 +133,7 @@ define( } else if (activeTab.attr('id') === 'map') { newProperty = this.mapView.newCompositeProperty; } else if (activeTab.attr('id') === 'list') { + newProperty = this.listView.newCompositeProperty; } else { console.log(activeTab); return false; @@ -166,6 +175,7 @@ define( /** Remove event bindings, child views, and DOM elements */ destroy: function() { + this.listView.destroy(); this.mapView.destroy(); this.timelineView.destroy(); this.$el.remove(); From edff108645965f0b5ac3de1597a9ff84c5b75b2a Mon Sep 17 00:00:00 2001 From: Bill Amberg Date: Tue, 23 Jul 2013 15:37:46 +0000 Subject: [PATCH 115/515] Remove 'use_decimal' argument from json.dumps calls. --- freemix/views.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/freemix/views.py b/freemix/views.py index 097e50fa..9de4c9fc 100644 --- a/freemix/views.py +++ b/freemix/views.py @@ -87,18 +87,14 @@ def __init__(self, data, template=None,**extra_context): indent = 2 if settings.DEBUG else None if template: - context = {"json": json.dumps(data, - indent=indent, - use_decimal=True) + context = {"json": json.dumps(data, indent=indent) } if extra_context: context.update(extra_context) content = render_to_string(template, context) mime = "application/javascript" else: - content = json.dumps(data, - indent=indent, - use_decimal=True) + content = json.dumps(data, indent=indent) mime = ("text/javascript" if settings.DEBUG else "application/json") super(JSONResponse, self).__init__( From 05dd7a51845fb7f5c749cc8bb4dae874477fc54c Mon Sep 17 00:00:00 2001 From: Bill Amberg Date: Tue, 23 Jul 2013 20:12:53 +0000 Subject: [PATCH 116/515] Upgrade django-registration from 0.8 to 1.0. --- requirements/requirements.txt | 2 +- .../apps/moderated_registration/admin.py | 2 +- .../apps/moderated_registration/backend.py | 130 ------------------ .../apps/moderated_registration/models.py | 18 +-- viewshare/apps/moderated_registration/urls.py | 17 +-- .../apps/moderated_registration/views.py | 87 ++++++++++++ 6 files changed, 103 insertions(+), 153 deletions(-) delete mode 100644 viewshare/apps/moderated_registration/backend.py diff --git a/requirements/requirements.txt b/requirements/requirements.txt index dba2efdf..846c6977 100644 --- a/requirements/requirements.txt +++ b/requirements/requirements.txt @@ -5,7 +5,7 @@ pytz==2013b django-announcements==1.0.2 django-celery==3.0.17 django-timezones==0.2 -django-registration==0.8 +django-registration==1.0 django_compressor==1.3 django-email-confirmation==0.2 django-extensions==1.1.1 diff --git a/viewshare/apps/moderated_registration/admin.py b/viewshare/apps/moderated_registration/admin.py index 91d82e23..429fc32b 100644 --- a/viewshare/apps/moderated_registration/admin.py +++ b/viewshare/apps/moderated_registration/admin.py @@ -132,7 +132,7 @@ def change_view(self, request, object_id, extra_context=None): def get_urls(self): urls = super(ModeratedRegistrationAdmin, self).get_urls() - return patterns('', + return patterns('', url(r'^(?P[\d]+)/moderate/$$', self.admin_site.admin_view(self.approval_view), name="approve_users"), diff --git a/viewshare/apps/moderated_registration/backend.py b/viewshare/apps/moderated_registration/backend.py deleted file mode 100644 index 6d52aaff..00000000 --- a/viewshare/apps/moderated_registration/backend.py +++ /dev/null @@ -1,130 +0,0 @@ -from django.contrib.sites.models import RequestSite, Site -from django.conf import settings - -from registration import signals -from registration.backends.default import DefaultBackend - -from viewshare.apps.moderated_registration import forms -from viewshare.apps.moderated_registration import models - - -class ModeratedRegistrationBackend(DefaultBackend): - """ - Extends the default registration profile to incorporate an admin approval - step in the user registration process - - A registration backend which follows a simple workflow: - - 1. User signs up, inactive account is created. - - 2. Email is sent to the admin for approval - - 3. On approval, an activation key is generated - - 4. Email is sent to user with activation link. - - 5. User clicks activation link, account is now active. - - Using this backend requires that - - * ``registration`` and ``moderated_registration`` be listed in the - ``INSTALLED_APPS`` setting - (since this backend makes use of models defined in these - applications). - - * The setting ``ACCOUNT_ACTIVATION_DAYS`` be supplied, specifying - (as an integer) the number of days from registration during - which a user may activate their account (after that period - expires, activation will be disallowed). - - * The creation of the templates - ``registration/activation_email_subject.txt`` and - ``registration/activation_email.txt``, which will be used for - the activation email. See the notes for this backends - ``register`` method for details regarding these templates. - - Additionally, registration can be temporarily closed by adding the - setting ``REGISTRATION_OPEN`` and setting it to - ``False``. Omitting this setting, or setting it to ``True``, will - be interpreted as meaning that registration is currently open and - permitted. - - Internally, this is accomplished via storing an activation key in - an instance of ``registration.models.RegistrationProfile``. See - that model and its custom manager for full documentation of its - fields and supported operations. - - """ - - model = models.ViewShareRegistrationProfile - form = forms.ViewShareRegistrationForm - - def register(self, request, **kwargs): - - if Site._meta.installed: - site = Site.objects.get_current() - else: - site = RequestSite(request) - ctx = dict(kwargs) - ctx["site"] = site - new_user = self.model.objects.create_moderated_user(**ctx) - signals.user_registered.send(sender=self.__class__, - user=new_user, - request=request) - return new_user - - def activate(self, request, activation_key): - """ - Given an an activation key, look up and activate the user - account corresponding to that key (if possible). - - After successful activation, the signal - ``registration.signals.user_activated`` will be sent, with the - newly activated ``User`` as the keyword argument ``user`` and - the class of this backend as the sender. - - """ - activated = self.model.objects.activate_user(activation_key) - if activated: - signals.user_activated.send(sender=self.__class__, - user=activated, - request=request) - return activated - - def registration_allowed(self, request): - """ - Indicate whether account registration is currently permitted, - based on the value of the setting ``REGISTRATION_OPEN``. This - is determined as follows: - - * If ``REGISTRATION_OPEN`` is not specified in settings, or is - set to ``True``, registration is permitted. - - * If ``REGISTRATION_OPEN`` is both specified and set to - ``False``, registration is not permitted. - - """ - return getattr(settings, 'REGISTRATION_OPEN', True) - - def get_form_class(self, request): - """ - Return the default form class used for user registration. - - """ - return self.form - - def post_registration_redirect(self, request, user): - """ - Return the name of the URL to redirect to after successful - user registration. - - """ - return 'registration_complete', (), {} - - def post_activation_redirect(self, request, user): - """ - Return the name of the URL to redirect to after successful - account activation. - - """ - return 'registration_activation_complete', (), {} diff --git a/viewshare/apps/moderated_registration/models.py b/viewshare/apps/moderated_registration/models.py index c792d01c..dd63ce0d 100644 --- a/viewshare/apps/moderated_registration/models.py +++ b/viewshare/apps/moderated_registration/models.py @@ -3,7 +3,6 @@ from django.conf import settings from django.contrib.auth.models import User -from django.contrib.sites.models import Site from django.db import models, transaction from django.template.loader import render_to_string from django_extensions.db.fields import AutoSlugField @@ -23,6 +22,11 @@ class ModeratedRegistrationManager(RegistrationManager): @transaction.commit_on_success def create_moderated_user(self, *args, **kwargs): + """ + Create an inactive User with a viewshare.apps.Profile. Also create + a ModeratedRegistrationProfile that must be reviewed by an admin. Send + an email notifying admins that there is a registration for review. + """ username = kwargs["username"] password = kwargs["password1"] email = kwargs["email"] @@ -45,7 +49,7 @@ def create_moderated_user(self, *args, **kwargs): registration_profile = self.create(user=new_user, activation_key=ModeratedRegistrationProfile.PENDING ) - registration_profile.send_approval_email(kwargs["site"]) + registration_profile.send_approval_email() return new_user def approve_profile(self, profile): @@ -68,10 +72,7 @@ def send_activation(self, profile): user_hash = hashlib.sha1(salt + profile.user.username) profile.activation_key = user_hash.hexdigest() profile.save() - - current_site = Site.objects.get_current() - - profile.send_activation_email(current_site) + profile.send_activation_email() return False @@ -86,7 +87,7 @@ class ModeratedRegistrationProfile(RegistrationProfile, models.Model): class Meta: abstract = True - def send_approval_email(self, site): + def send_approval_email(self): ctx_dict = { 'profile': self, 'SITE_NAME': settings.SITE_NAME, @@ -108,7 +109,7 @@ def send_approval_email(self, site): send_mail(subject, message, from_addr, to) - def send_activation_email(self, site): + def send_activation_email(self): """ Overrides the base method to add the profile itself to the activation templates @@ -116,7 +117,6 @@ def send_activation_email(self, site): """ ctx_dict = {'activation_key': self.activation_key, 'expiration_days': settings.ACCOUNT_ACTIVATION_DAYS, - 'site': site, 'profile': self, 'SITE_NAME': settings.SITE_NAME, 'CONTACT_EMAIL': settings.CONTACT_EMAIL} diff --git a/viewshare/apps/moderated_registration/urls.py b/viewshare/apps/moderated_registration/urls.py index 7a5a9557..d61d753f 100644 --- a/viewshare/apps/moderated_registration/urls.py +++ b/viewshare/apps/moderated_registration/urls.py @@ -1,33 +1,26 @@ """ URL patterns for user registration, admin authorization, and activation - """ - from django.conf.urls.defaults import patterns, url +from .views import ModeratedActivationView, ModeratedRegistrationView -_registration_backend_ = 'viewshare.apps.moderated_registration.backend' \ - '.ModeratedRegistrationBackend' urlpatterns = patterns('', url(r'^activate/complete/$', 'viewshare.apps.moderated_registration.views.activation_complete', name='registration_activation_complete'), - # Activation keys get matched by \w+ instead of the more specific # [a-fA-F0-9]{40} because a bad activation key should still get to the # view; # that way it can return a sensible "invalid key" message instead of a # confusing 404. url(r'^activate/(?P\w+)/$', - 'registration.views.activate', - {'backend': _registration_backend_}, - name='registration_activate'), - + ModeratedActivationView.as_view(), + name='registration_activate'), url(r'^register/$', - 'registration.views.register', - {'backend': _registration_backend_}, - name='registration_register'), + ModeratedRegistrationView.as_view(), + name='registration_register'), url(r'^register/complete/$', 'viewshare.apps.moderated_registration.views.registration_complete', diff --git a/viewshare/apps/moderated_registration/views.py b/viewshare/apps/moderated_registration/views.py index a5d9bfc0..3753195a 100644 --- a/viewshare/apps/moderated_registration/views.py +++ b/viewshare/apps/moderated_registration/views.py @@ -1,11 +1,98 @@ from django.views.generic.base import TemplateView +from registration import signals +from registration.backends.default.views import ( + ActivationView, RegistrationView) + +from .forms import ViewShareRegistrationForm +from .models import ViewShareRegistrationProfile + + +class ModeratedRegistrationView(RegistrationView): + """ + Extends the default registration profile to incorporate an admin approval + step in the user registration process + + A registration backend which follows a simple workflow: + + 1. User signs up, inactive account is created. + + 2. Email is sent to the admin for approval + + 3. On approval, an activation key is generated + + 4. Email is sent to user with activation link. + + 5. User clicks activation link, account is now active. + + Using this backend requires that + + * ``registration`` and ``moderated_registration`` be listed in the + ``INSTALLED_APPS`` setting + (since this backend makes use of models defined in these + applications). + + * The setting ``ACCOUNT_ACTIVATION_DAYS`` be supplied, specifying + (as an integer) the number of days from registration during + which a user may activate their account (after that period + expires, activation will be disallowed). + + * The creation of the templates + ``registration/activation_email_subject.txt`` and + ``registration/activation_email.txt``, which will be used for + the activation email. See the notes for this backends + ``register`` method for details regarding these templates. + + Additionally, registration can be temporarily closed by adding the + setting ``REGISTRATION_OPEN`` and setting it to + ``False``. Omitting this setting, or setting it to ``True``, will + be interpreted as meaning that registration is currently open and + permitted. + + Internally, this is accomplished via storing an activation key in + an instance of ``registration.models.RegistrationProfile``. See + that model and its custom manager for full documentation of its + fields and supported operations. + """ + model = ViewShareRegistrationProfile + form_class = ViewShareRegistrationForm + + def register(self, request, **kwargs): + new_user = self.model.objects.create_moderated_user(**kwargs) + signals.user_registered.send(sender=self.__class__, + user=new_user, + request=request) + + +class ModeratedActivationView(ActivationView): + model = ViewShareRegistrationProfile + + def activate(self, request, activation_key): + """ + Given an an activation key, look up and activate the user + account corresponding to that key (if possible). + + After successful activation, the signal + ``registration.signals.user_activated`` will be sent, with the + newly activated ``User`` as the keyword argument ``user`` and + the class of this backend as the sender. + """ + activated_user = self.model.objects.activate_user(activation_key) + if activated_user: + signals.user_activated.send(sender=self.__class__, + user=activated_user, + request=request) + return activated_user def registration_view(template): + """Helper function to return TemplateViews.""" return TemplateView.as_view(template_name='registration/%s' % template) + activation_complete = registration_view('activation_complete.html') + registration_complete = registration_view('registration_complete.html') + registration_closed = registration_view('registration_closed.html') From 50cf8f6dfe0da04abf567103f9711ff4c18d39cf Mon Sep 17 00:00:00 2001 From: David Feeney Date: Mon, 8 Jul 2013 15:43:52 -0400 Subject: [PATCH 117/515] Removing JSONDataModel, as it really only represents one field --- freemix/dataset/models.py | 15 +++++++++++---- freemix/exhibit/models.py | 1 - freemix/models.py | 8 -------- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/freemix/dataset/models.py b/freemix/dataset/models.py index 260449c4..46200edf 100644 --- a/freemix/dataset/models.py +++ b/freemix/dataset/models.py @@ -15,7 +15,6 @@ TimeStampedModel, TitleSlugDescriptionModel) from freemix.dataset.transform import AKARA_TRANSFORM_URL from freemix.dataset.transform import AkaraTransformClient -from freemix.models import JSONDataModel logger = logging.getLogger(__name__) @@ -81,21 +80,27 @@ def update_profile(self, json): profile.save() -class DatasetJSONFile(JSONDataModel): +class DatasetJSONFile(models.Model): """ The data associated with this dataset in the Exhibit JSON format """ dataset = models.OneToOneField(Dataset, related_name="data") + data =JSONField() -class DatasetProfile(JSONDataModel): + + +class DatasetProfile(models.Model): """ A JSON document representing the properties defined in the dataset """ dataset = models.OneToOneField(Dataset, related_name="profile") + data =JSONField() + -class DatasetPropertiesCache(JSONDataModel): + +class DatasetPropertiesCache(models.Model): """ An exhibit compatible representation of the properties defined in DatasetProfile. @@ -106,6 +111,8 @@ class DatasetPropertiesCache(JSONDataModel): dataset = models.OneToOneField(Dataset, related_name="properties_cache") + data =JSONField() + def sync_properties(sender, instance=None, **kwargs): # convert freemix properties to exhibit properties diff --git a/freemix/exhibit/models.py b/freemix/exhibit/models.py index 203a6d2d..db51f9c9 100644 --- a/freemix/exhibit/models.py +++ b/freemix/exhibit/models.py @@ -6,7 +6,6 @@ from django_extensions.db.fields.json import JSONField from django_extensions.db.models import TitleSlugDescriptionModel, TimeStampedModel from freemix.dataset.models import Dataset -from freemix.models import JSONDataModel class Canvas(TitleSlugDescriptionModel): diff --git a/freemix/models.py b/freemix/models.py index 44636ea2..8b137891 100644 --- a/freemix/models.py +++ b/freemix/models.py @@ -1,9 +1 @@ -from django.db import models -from django_extensions.db.fields.json import JSONField -class JSONDataModel(models.Model): - - data =JSONField() - - class Meta: - abstract=True \ No newline at end of file From 871a398ef24fe12fb97d100c432a9ae0df7617c0 Mon Sep 17 00:00:00 2001 From: David Feeney Date: Mon, 8 Jul 2013 15:48:21 -0400 Subject: [PATCH 118/515] Pinning south version number in the event of 2.0 release --- requirements/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements/requirements.txt b/requirements/requirements.txt index 846c6977..6c23638d 100644 --- a/requirements/requirements.txt +++ b/requirements/requirements.txt @@ -1,4 +1,4 @@ -South>=0.7.6 +South>=0.8.1,<2.0 Django==1.5.1 pillow==2.0.0 pytz==2013b From 6322a9fffb323b2f7b4f7f99d1225726624f305f Mon Sep 17 00:00:00 2001 From: David Feeney Date: Tue, 9 Jul 2013 01:22:50 -0400 Subject: [PATCH 119/515] ensure that UUIDFields are creating version 4 UUIDs --- freemix/dataset/models.py | 4 ++-- freemix/exhibit/share/models.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/freemix/dataset/models.py b/freemix/dataset/models.py index 46200edf..4bf27e77 100644 --- a/freemix/dataset/models.py +++ b/freemix/dataset/models.py @@ -161,7 +161,7 @@ class DataSourceTransaction(TimeStampedModel): This implementation is temporary, to be replaced with a solution with pluggable backends. """ - tx_id = UUIDField() + tx_id = UUIDField(version=4) status = models.IntegerField( choices=[(v, k) for k, v in TX_STATUS.iteritems()], @@ -270,7 +270,7 @@ class DataSource(TimeStampedModel): blank=True, related_name="source") - uuid = UUIDField() + uuid = UUIDField(version=4) @models.permalink def get_absolute_url(self): diff --git a/freemix/exhibit/share/models.py b/freemix/exhibit/share/models.py index 53bff001..14814277 100644 --- a/freemix/exhibit/share/models.py +++ b/freemix/exhibit/share/models.py @@ -5,7 +5,7 @@ class SharedExhibitKey(TimeStampedModel,models.Model): - slug = UUIDField() + slug = UUIDField(version=4) label = models.TextField(max_length=255, blank=True, null=True, help_text="An optional descriptive label") From dfecc608b81d54462d544fa066c311b09126d225 Mon Sep 17 00:00:00 2001 From: David Feeney Date: Tue, 9 Jul 2013 01:32:42 -0400 Subject: [PATCH 120/515] moved exhibit share app into viewshare --- docs/ecosystem.rst | 4 ++-- freemix/templates/exhibit/detail/base.html | 2 +- freemix/templates/exhibit/display/base.html | 2 +- freemix/templates/share/exhibit_display.html | 2 +- {freemix/exhibit => viewshare/apps}/share/__init__.py | 0 {freemix/exhibit => viewshare/apps}/share/admin.py | 2 +- {freemix/exhibit => viewshare/apps}/share/forms.py | 2 +- .../apps}/share/migrations/0001_initial.py | 0 .../apps}/share/migrations/0002_add_time_stamps.py | 0 .../exhibit => viewshare/apps}/share/migrations/__init__.py | 0 {freemix/exhibit => viewshare/apps}/share/models.py | 0 {freemix/exhibit => viewshare/apps}/share/urls.py | 2 +- {freemix/exhibit => viewshare/apps}/share/views.py | 5 ++++- viewshare/settings.py | 2 +- .../exhibit => viewshare/static}/share/js/share_dialog.js | 0 .../exhibit => viewshare/static}/share/js/shared_exhibit.js | 0 16 files changed, 13 insertions(+), 10 deletions(-) rename {freemix/exhibit => viewshare/apps}/share/__init__.py (100%) rename {freemix/exhibit => viewshare/apps}/share/admin.py (79%) rename {freemix/exhibit => viewshare/apps}/share/forms.py (93%) rename {freemix/exhibit => viewshare/apps}/share/migrations/0001_initial.py (100%) rename {freemix/exhibit => viewshare/apps}/share/migrations/0002_add_time_stamps.py (100%) rename {freemix/exhibit => viewshare/apps}/share/migrations/__init__.py (100%) rename {freemix/exhibit => viewshare/apps}/share/models.py (100%) rename {freemix/exhibit => viewshare/apps}/share/urls.py (96%) rename {freemix/exhibit => viewshare/apps}/share/views.py (98%) rename {freemix/static/exhibit => viewshare/static}/share/js/share_dialog.js (100%) rename {freemix/static/exhibit => viewshare/static}/share/js/shared_exhibit.js (100%) diff --git a/docs/ecosystem.rst b/docs/ecosystem.rst index 372961ab..99508e1b 100644 --- a/docs/ecosystem.rst +++ b/docs/ecosystem.rst @@ -72,8 +72,8 @@ Custom apps * An Exhibit is a visualization of a DataSet. An Exhibit consists of a Theme and a Canvas: * Theme - color scheme of the Exhibit * Canvas - layout of the Exhibit e.g. "A view container with a facet container to the left" - * freemix.exhibit.share - * Allows an Exhibit owner to generate a unique URL for their Exhibit. + * viewshare.apps.share + * Allows an Exhibit owner to generate a unique obfuscated URL for their Exhibit. * Viewshare specific * viewshare.apps.notices diff --git a/freemix/templates/exhibit/detail/base.html b/freemix/templates/exhibit/detail/base.html index 0f5bb575..a116b5a9 100644 --- a/freemix/templates/exhibit/detail/base.html +++ b/freemix/templates/exhibit/detail/base.html @@ -28,7 +28,7 @@ {% if can_share %} - {% compress js %}{% endcompress %} + {% compress js %}{% endcompress %} {% endif %} {% endblock %} diff --git a/freemix/templates/exhibit/display/base.html b/freemix/templates/exhibit/display/base.html index ee5b76fd..421127a6 100644 --- a/freemix/templates/exhibit/display/base.html +++ b/freemix/templates/exhibit/display/base.html @@ -37,7 +37,7 @@ {% if can_share %} {% compress js %} - + {% endcompress %} {% endif %} diff --git a/freemix/templates/share/exhibit_display.html b/freemix/templates/share/exhibit_display.html index efd6f596..2d6be409 100644 --- a/freemix/templates/share/exhibit_display.html +++ b/freemix/templates/share/exhibit_display.html @@ -32,7 +32,7 @@ {% compress js %} - + {% endcompress %} {% endblock head_scripts %} diff --git a/freemix/exhibit/share/__init__.py b/viewshare/apps/share/__init__.py similarity index 100% rename from freemix/exhibit/share/__init__.py rename to viewshare/apps/share/__init__.py diff --git a/freemix/exhibit/share/admin.py b/viewshare/apps/share/admin.py similarity index 79% rename from freemix/exhibit/share/admin.py rename to viewshare/apps/share/admin.py index b057c7b6..fc788a56 100644 --- a/freemix/exhibit/share/admin.py +++ b/viewshare/apps/share/admin.py @@ -1,5 +1,5 @@ from django.contrib import admin -from freemix.exhibit.share.models import SharedExhibitKey +from viewshare.apps.share.models import SharedExhibitKey class SharedExhibitKeyAdmin(admin.ModelAdmin): list_display = ('slug','label', 'exhibit',) diff --git a/freemix/exhibit/share/forms.py b/viewshare/apps/share/forms.py similarity index 93% rename from freemix/exhibit/share/forms.py rename to viewshare/apps/share/forms.py index d87dec71..b7f98c3a 100644 --- a/freemix/exhibit/share/forms.py +++ b/viewshare/apps/share/forms.py @@ -1,5 +1,5 @@ from django import forms -from freemix.exhibit.share import models +from viewshare.apps.share import models class CreateSharedExhibitKeyForm(forms.ModelForm): diff --git a/freemix/exhibit/share/migrations/0001_initial.py b/viewshare/apps/share/migrations/0001_initial.py similarity index 100% rename from freemix/exhibit/share/migrations/0001_initial.py rename to viewshare/apps/share/migrations/0001_initial.py diff --git a/freemix/exhibit/share/migrations/0002_add_time_stamps.py b/viewshare/apps/share/migrations/0002_add_time_stamps.py similarity index 100% rename from freemix/exhibit/share/migrations/0002_add_time_stamps.py rename to viewshare/apps/share/migrations/0002_add_time_stamps.py diff --git a/freemix/exhibit/share/migrations/__init__.py b/viewshare/apps/share/migrations/__init__.py similarity index 100% rename from freemix/exhibit/share/migrations/__init__.py rename to viewshare/apps/share/migrations/__init__.py diff --git a/freemix/exhibit/share/models.py b/viewshare/apps/share/models.py similarity index 100% rename from freemix/exhibit/share/models.py rename to viewshare/apps/share/models.py diff --git a/freemix/exhibit/share/urls.py b/viewshare/apps/share/urls.py similarity index 96% rename from freemix/exhibit/share/urls.py rename to viewshare/apps/share/urls.py index fff64958..f36a6621 100644 --- a/freemix/exhibit/share/urls.py +++ b/viewshare/apps/share/urls.py @@ -1,6 +1,6 @@ from django.conf.urls.defaults import patterns, url from django.views.generic.base import TemplateView -from freemix.exhibit.share import views +from viewshare.apps.share import views urlpatterns = patterns('', diff --git a/freemix/exhibit/share/views.py b/viewshare/apps/share/views.py similarity index 98% rename from freemix/exhibit/share/views.py rename to viewshare/apps/share/views.py index 8effb74c..49baa028 100644 --- a/freemix/exhibit/share/views.py +++ b/viewshare/apps/share/views.py @@ -5,10 +5,13 @@ from django.views.generic.detail import DetailView from django.utils.translation import ugettext_lazy as _ from django.views.generic.edit import CreateView +from freemix.exhibit.share import models + from freemix.dataset import models as dataset_models from freemix.exhibit.models import Exhibit from freemix.views import BaseJSONView -from freemix.exhibit.share import models, forms +from viewshare.apps.share import forms + class SharedExhibitDisplayView(DetailView): diff --git a/viewshare/settings.py b/viewshare/settings.py index b57a2bfd..2f15b44e 100644 --- a/viewshare/settings.py +++ b/viewshare/settings.py @@ -124,7 +124,7 @@ 'freemix.dataset', 'freemix.exhibit', 'freemix.dataset.augment', - 'freemix.exhibit.share', + 'viewshare.apps.share', # Viewshare specific 'viewshare.apps.vendor.notification', diff --git a/freemix/static/exhibit/share/js/share_dialog.js b/viewshare/static/share/js/share_dialog.js similarity index 100% rename from freemix/static/exhibit/share/js/share_dialog.js rename to viewshare/static/share/js/share_dialog.js diff --git a/freemix/static/exhibit/share/js/shared_exhibit.js b/viewshare/static/share/js/shared_exhibit.js similarity index 100% rename from freemix/static/exhibit/share/js/shared_exhibit.js rename to viewshare/static/share/js/shared_exhibit.js From f9ae770e3780795414c0156bc463297a1620b8e2 Mon Sep 17 00:00:00 2001 From: David Feeney Date: Tue, 9 Jul 2013 03:25:16 -0400 Subject: [PATCH 121/515] added distinct published and draft exhibit models --- .../0007_public_and_draft_exhibit.py | 134 ++++++++++++++++ .../0008_migrate_publication_info.py | 113 +++++++++++++ ...t_s__add_field_draftexhibit_creator__de.py | 145 +++++++++++++++++ ...010_rename_slug_title_description_owner.py | 150 ++++++++++++++++++ freemix/exhibit/models.py | 59 +++++-- 5 files changed, 585 insertions(+), 16 deletions(-) create mode 100644 freemix/exhibit/migrations/0007_public_and_draft_exhibit.py create mode 100644 freemix/exhibit/migrations/0008_migrate_publication_info.py create mode 100644 freemix/exhibit/migrations/0009_auto__chg_field_publishedexhibit_s__add_field_draftexhibit_creator__de.py create mode 100644 freemix/exhibit/migrations/0010_rename_slug_title_description_owner.py diff --git a/freemix/exhibit/migrations/0007_public_and_draft_exhibit.py b/freemix/exhibit/migrations/0007_public_and_draft_exhibit.py new file mode 100644 index 00000000..f116d3ba --- /dev/null +++ b/freemix/exhibit/migrations/0007_public_and_draft_exhibit.py @@ -0,0 +1,134 @@ +# -*- coding: 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 'PublishedExhibit' + db.create_table('exhibit_publishedexhibit', ( + ('exhibit_ptr', self.gf('django.db.models.fields.related.OneToOneField')(to=orm['exhibit.Exhibit'], unique=True, primary_key=True)), + ('is_public', self.gf('django.db.models.fields.BooleanField')(default=True)), + ('publisher', self.gf('django.db.models.fields.related.ForeignKey')(blank=True, related_name='published_exhibits', null=True, to=orm['auth.User'])), + ('t', self.gf('django.db.models.fields.CharField')(max_length=255)), + ('s', self.gf('django_extensions.db.fields.AutoSlugField')(allow_duplicates=False, max_length=50, separator=u'-', blank=True, populate_from='title', overwrite=False)), + ('d', self.gf('django.db.models.fields.TextField')(null=True, blank=True)), + )) + db.send_create_signal('exhibit', ['PublishedExhibit']) + + # Adding unique constraint on 'PublishedExhibit', fields ['slug', 'publisher'] + db.create_unique('exhibit_publishedexhibit', ['s', 'publisher_id']) + + # Adding model 'DraftExhibit' + db.create_table('exhibit_draftexhibit', ( + ('exhibit_ptr', self.gf('django.db.models.fields.related.OneToOneField')(to=orm['exhibit.Exhibit'], unique=True, primary_key=True)), + ('uuid', self.gf('django.db.models.fields.CharField')(max_length=36, blank=True)), + ('parent', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['exhibit.PublishedExhibit'], null=True, blank=True)), + )) + db.send_create_signal('exhibit', ['DraftExhibit']) + + + def backwards(self, orm): + # Removing unique constraint on 'PublishedExhibit', fields ['slug', 'publisher'] + db.delete_unique('exhibit_publishedexhibit', ['slug', 'publisher_id']) + + # Deleting model 'PublishedExhibit' + db.delete_table('exhibit_publishedexhibit') + + # Deleting model 'DraftExhibit' + db.delete_table('exhibit_draftexhibit') + + + 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']", 'symmetrical': 'False', 'blank': 'True'}) + }, + 'auth.permission': { + 'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", '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']", 'symmetrical': 'False', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + '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']", 'symmetrical': 'False', 'blank': 'True'}), + 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'}) + }, + 'contenttypes.contenttype': { + 'Meta': {'ordering': "('name',)", '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'}) + }, + 'dataset.dataset': { + 'Meta': {'ordering': "('-modified',)", 'unique_together': "(('slug', 'owner'),)", 'object_name': 'Dataset'}, + 'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'modified': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + 'owner': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'datasets'", 'null': 'True', 'to': "orm['auth.User']"}), + 'published': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'slug': ('django_extensions.db.fields.AutoSlugField', [], {'allow_duplicates': 'False', 'max_length': '50', 'separator': "u'-'", 'blank': 'True', 'populate_from': "'title'", 'overwrite': 'False'}), + 'title': ('django.db.models.fields.CharField', [], {'max_length': '255'}) + }, + 'exhibit.canvas': { + 'Meta': {'object_name': 'Canvas'}, + 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'enabled': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'location': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '100'}), + 'slug': ('django_extensions.db.fields.AutoSlugField', [], {'allow_duplicates': 'False', 'max_length': '50', 'separator': "u'-'", 'blank': 'True', 'populate_from': "'title'", 'overwrite': 'False'}), + 'thumbnail': ('django.db.models.fields.URLField', [], {'max_length': '200'}), + 'title': ('django.db.models.fields.CharField', [], {'max_length': '255'}) + }, + 'exhibit.draftexhibit': { + 'Meta': {'ordering': "('-modified',)", 'object_name': 'DraftExhibit', '_ormbases': ['exhibit.Exhibit']}, + 'exhibit_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['exhibit.Exhibit']", 'unique': 'True', 'primary_key': 'True'}), + 'parent': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['exhibit.PublishedExhibit']", 'null': 'True', 'blank': 'True'}), + 'uuid': ('django.db.models.fields.CharField', [], {'max_length': '36', 'blank': 'True'}) + }, + 'exhibit.exhibit': { + 'Meta': {'ordering': "('-modified',)", 'unique_together': "(('slug', 'owner'),)", 'object_name': 'Exhibit'}, + 'canvas': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['exhibit.Canvas']"}), + 'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + 'dataset': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'exhibits'", 'null': 'True', 'to': "orm['dataset.Dataset']"}), + 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'modified': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + 'owner': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'exhibits'", 'null': 'True', 'to': "orm['auth.User']"}), + 'profile': ('django.db.models.fields.TextField', [], {'default': "'{}'"}), + 'published': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'slug': ('django_extensions.db.fields.AutoSlugField', [], {'allow_duplicates': 'False', 'max_length': '50', 'separator': "u'-'", 'blank': 'True', 'populate_from': "'title'", 'overwrite': 'False'}), + 'title': ('django.db.models.fields.CharField', [], {'max_length': '255'}) + }, + 'exhibit.publishedexhibit': { + 'Meta': {'ordering': "('-modified',)", 'unique_together': "(('s', 'publisher'),)", 'object_name': 'PublishedExhibit', '_ormbases': ['exhibit.Exhibit']}, + 'd': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'exhibit_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['exhibit.Exhibit']", 'unique': 'True', 'primary_key': 'True'}), + 'is_public': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'publisher': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'published_exhibits'", 'null': 'True', 'to': "orm['auth.User']"}), + 's': ('django_extensions.db.fields.AutoSlugField', [], {'allow_duplicates': 'False', 'max_length': '50', 'separator': "u'-'", 'blank': 'True', 'populate_from': "'t'", 'overwrite': 'False'}), + 't': ('django.db.models.fields.CharField', [], {'max_length': '255'}), + } + } + + complete_apps = ['exhibit'] \ No newline at end of file diff --git a/freemix/exhibit/migrations/0008_migrate_publication_info.py b/freemix/exhibit/migrations/0008_migrate_publication_info.py new file mode 100644 index 00000000..76aa333d --- /dev/null +++ b/freemix/exhibit/migrations/0008_migrate_publication_info.py @@ -0,0 +1,113 @@ +# -*- coding: utf-8 -*- +import datetime +from south.db import db +from south.v2 import DataMigration +from django.db import models + +class Migration(DataMigration): + + def forwards(self, orm): + for exhibit in orm.Exhibit.objects.all(): + pub = orm.PublishedExhibit(exhibit_ptr=exhibit, + t=exhibit.title, + d=exhibit.description, + s=exhibit.slug, + is_public=exhibit.published, + publisher=exhibit.owner) + pub.__dict__.update(exhibit.__dict__) + pub.save() + + def backwards(self, orm): + "Write your backwards methods here." + + 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']", 'symmetrical': 'False', 'blank': 'True'}) + }, + 'auth.permission': { + 'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", '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']", 'symmetrical': 'False', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + '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']", 'symmetrical': 'False', 'blank': 'True'}), + 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'}) + }, + 'contenttypes.contenttype': { + 'Meta': {'ordering': "('name',)", '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'}) + }, + 'dataset.dataset': { + 'Meta': {'ordering': "('-modified',)", 'unique_together': "(('slug', 'owner'),)", 'object_name': 'Dataset'}, + 'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'modified': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + 'owner': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'datasets'", 'null': 'True', 'to': "orm['auth.User']"}), + 'published': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'slug': ('django_extensions.db.fields.AutoSlugField', [], {'allow_duplicates': 'False', 'max_length': '50', 'separator': "u'-'", 'blank': 'True', 'populate_from': "'title'", 'overwrite': 'False'}), + 'title': ('django.db.models.fields.CharField', [], {'max_length': '255'}) + }, + 'exhibit.canvas': { + 'Meta': {'object_name': 'Canvas'}, + 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'enabled': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'location': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '100'}), + 'slug': ('django_extensions.db.fields.AutoSlugField', [], {'allow_duplicates': 'False', 'max_length': '50', 'separator': "u'-'", 'blank': 'True', 'populate_from': "'title'", 'overwrite': 'False'}), + 'thumbnail': ('django.db.models.fields.URLField', [], {'max_length': '200'}), + 'title': ('django.db.models.fields.CharField', [], {'max_length': '255'}) + }, + 'exhibit.draftexhibit': { + 'Meta': {'ordering': "('-modified',)", 'object_name': 'DraftExhibit', '_ormbases': ['exhibit.Exhibit']}, + 'exhibit_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['exhibit.Exhibit']", 'unique': 'True', 'primary_key': 'True'}), + 'parent': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['exhibit.PublishedExhibit']", 'null': 'True', 'blank': 'True'}), + 'uuid': ('django.db.models.fields.CharField', [], {'max_length': '36', 'blank': 'True'}) + }, + 'exhibit.exhibit': { + 'Meta': {'ordering': "('-modified',)", 'unique_together': "(('slug', 'owner'),)", 'object_name': 'Exhibit'}, + 'canvas': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['exhibit.Canvas']"}), + 'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + 'dataset': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'exhibits'", 'null': 'True', 'to': "orm['dataset.Dataset']"}), + 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'modified': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + 'owner': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'exhibits'", 'null': 'True', 'to': "orm['auth.User']"}), + 'profile': ('django.db.models.fields.TextField', [], {'default': "'{}'"}), + 'published': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'slug': ('django_extensions.db.fields.AutoSlugField', [], {'allow_duplicates': 'False', 'max_length': '50', 'separator': "u'-'", 'blank': 'True', 'populate_from': "'title'", 'overwrite': 'False'}), + 'title': ('django.db.models.fields.CharField', [], {'max_length': '255'}) + }, + 'exhibit.publishedexhibit': { + 'Meta': {'ordering': "('-modified',)", 'unique_together': "(('s', 'publisher'),)", 'object_name': 'PublishedExhibit', '_ormbases': ['exhibit.Exhibit']}, + 'd': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'exhibit_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['exhibit.Exhibit']", 'unique': 'True', 'primary_key': 'True'}), + 'is_public': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'publisher': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'published_exhibits'", 'null': 'True', 'to': "orm['auth.User']"}), + 's': ('django_extensions.db.fields.AutoSlugField', [], {'allow_duplicates': 'False', 'max_length': '50', 'separator': "u'-'", 'blank': 'True', 'populate_from': "'t'", 'overwrite': 'False'}), + 't': ('django.db.models.fields.CharField', [], {'max_length': '255'}) + } + } + + complete_apps = ['exhibit'] + symmetrical = True diff --git a/freemix/exhibit/migrations/0009_auto__chg_field_publishedexhibit_s__add_field_draftexhibit_creator__de.py b/freemix/exhibit/migrations/0009_auto__chg_field_publishedexhibit_s__add_field_draftexhibit_creator__de.py new file mode 100644 index 00000000..2e5e1b18 --- /dev/null +++ b/freemix/exhibit/migrations/0009_auto__chg_field_publishedexhibit_s__add_field_draftexhibit_creator__de.py @@ -0,0 +1,145 @@ +# -*- coding: 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): + # Removing unique constraint on 'Exhibit', fields ['owner', 'slug'] + db.delete_unique('exhibit_exhibit', ['owner_id', 'slug']) + + # Deleting field 'Exhibit.description' + db.delete_column('exhibit_exhibit', 'description') + + # Deleting field 'Exhibit.owner' + db.delete_column('exhibit_exhibit', 'owner_id') + + # Deleting field 'Exhibit.slug' + db.delete_column('exhibit_exhibit', 'slug') + + # Deleting field 'Exhibit.title' + db.delete_column('exhibit_exhibit', 'title') + + # Deleting field 'Exhibit.published' + db.delete_column('exhibit_exhibit', 'published') + + + def backwards(self, orm): + + # Adding field 'Exhibit.description' + db.add_column('exhibit_exhibit', 'description', + self.gf('django.db.models.fields.TextField')(null=True, blank=True), + keep_default=False) + + # Adding field 'Exhibit.owner' + db.add_column('exhibit_exhibit', 'owner', + self.gf('django.db.models.fields.related.ForeignKey')(related_name='exhibits', null=True, to=orm['auth.User'], blank=True), + keep_default=False) + + # Adding field 'Exhibit.slug' + db.add_column('exhibit_exhibit', 'slug', + self.gf('django_extensions.db.fields.AutoSlugField')(default='', populate_from='title', allow_duplicates=False, max_length=50, separator=u'-', blank=True, overwrite=False), + keep_default=False) + + # Adding field 'Exhibit.title' + db.add_column('exhibit_exhibit', 'title', + self.gf('django.db.models.fields.CharField')(default='t', max_length=255), + keep_default=False) + + # Adding field 'Exhibit.published' + db.add_column('exhibit_exhibit', 'published', + self.gf('django.db.models.fields.BooleanField')(default=True), + keep_default=False) + + # Adding unique constraint on 'Exhibit', fields ['owner', 'slug'] + db.create_unique('exhibit_exhibit', ['owner_id', 'slug']) + + + 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']", 'symmetrical': 'False', 'blank': 'True'}) + }, + 'auth.permission': { + 'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", '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']", 'symmetrical': 'False', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + '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']", 'symmetrical': 'False', 'blank': 'True'}), + 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'}) + }, + 'contenttypes.contenttype': { + 'Meta': {'ordering': "('name',)", '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'}) + }, + 'dataset.dataset': { + 'Meta': {'ordering': "('-modified',)", 'unique_together': "(('slug', 'owner'),)", 'object_name': 'Dataset'}, + 'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'modified': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + 'owner': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'datasets'", 'null': 'True', 'to': "orm['auth.User']"}), + 'published': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'slug': ('django_extensions.db.fields.AutoSlugField', [], {'allow_duplicates': 'False', 'max_length': '50', 'separator': "u'-'", 'blank': 'True', 'populate_from': "'title'", 'overwrite': 'False'}), + 'title': ('django.db.models.fields.CharField', [], {'max_length': '255'}) + }, + 'exhibit.canvas': { + 'Meta': {'object_name': 'Canvas'}, + 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'enabled': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'location': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '100'}), + 'slug': ('django_extensions.db.fields.AutoSlugField', [], {'allow_duplicates': 'False', 'max_length': '50', 'separator': "u'-'", 'blank': 'True', 'populate_from': "'title'", 'overwrite': 'False'}), + 'thumbnail': ('django.db.models.fields.URLField', [], {'max_length': '200'}), + 'title': ('django.db.models.fields.CharField', [], {'max_length': '255'}) + }, + 'exhibit.draftexhibit': { + 'Meta': {'ordering': "('-modified',)", 'object_name': 'DraftExhibit', '_ormbases': ['exhibit.Exhibit']}, + 'exhibit_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['exhibit.Exhibit']", 'unique': 'True', 'primary_key': 'True'}), + 'parent': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['exhibit.PublishedExhibit']", 'null': 'True', 'blank': 'True'}), + 'uuid': ('django.db.models.fields.CharField', [], {'max_length': '36', 'blank': 'True'}) + }, + 'exhibit.exhibit': { + 'Meta': {'ordering': "('-modified', '-created')", 'object_name': 'Exhibit'}, + 'canvas': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['exhibit.Canvas']"}), + 'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + 'dataset': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'exhibits'", 'null': 'True', 'to': "orm['dataset.Dataset']"}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'modified': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + 'profile': ('django.db.models.fields.TextField', [], {'default': "'{}'"}) + }, + 'exhibit.publishedexhibit': { + 'Meta': {'ordering': "('-modified',)", 'unique_together': "(('s', 'publisher'),)", 'object_name': 'PublishedExhibit', '_ormbases': ['exhibit.Exhibit']}, + 'd': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'exhibit_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['exhibit.Exhibit']", 'unique': 'True', 'primary_key': 'True'}), + 'is_public': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'publisher': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'published_exhibits'", 'null': 'True', 'to': "orm['auth.User']"}), + 's': ('django_extensions.db.fields.AutoSlugField', [], {'allow_duplicates': 'False', 'max_length': '50', 'separator': "u'-'", 'blank': 'True', 'populate_from': "'t'", 'overwrite': 'False'}), + 't': ('django.db.models.fields.CharField', [], {'max_length': '255'}) + } + } + + complete_apps = ['exhibit'] \ No newline at end of file diff --git a/freemix/exhibit/migrations/0010_rename_slug_title_description_owner.py b/freemix/exhibit/migrations/0010_rename_slug_title_description_owner.py new file mode 100644 index 00000000..570b56a3 --- /dev/null +++ b/freemix/exhibit/migrations/0010_rename_slug_title_description_owner.py @@ -0,0 +1,150 @@ +# -*- coding: 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): + # Removing unique constraint on 'PublishedExhibit', fields ['publisher', 's'] + db.delete_unique('exhibit_publishedexhibit', ['publisher_id', 's']) + + # Deleting field 'PublishedExhibit.publisher' + db.rename_column('exhibit_publishedexhibit', 'publisher_id', 'owner_id') + + db.alter_column('exhibit_publishedexhibit', 'owner_id', + self.gf('django.db.models.fields.related.ForeignKey')(blank=True, related_name='published_exhibits', null=True, to=orm['auth.User'])) + + # Deleting field 'PublishedExhibit.d' + db.rename_column('exhibit_publishedexhibit', 'd', 'description') + + # Deleting field 'PublishedExhibit.s' + db.rename_column('exhibit_publishedexhibit', 's', 'slug') + + # Deleting field 'PublishedExhibit.t' + db.rename_column('exhibit_publishedexhibit', 't', 'title') + + # Adding unique constraint on 'PublishedExhibit', fields ['owner', 'slug'] + db.create_unique('exhibit_publishedexhibit', ['owner_id', 'slug']) + + # Adding field 'DraftExhibit.owner' + db.add_column('exhibit_draftexhibit', 'owner', + self.gf('django.db.models.fields.related.ForeignKey')(blank=True, related_name='draft_exhibits', null=True, to=orm['auth.User']), + keep_default=False) + + + + def backwards(self, orm): + # Removing unique constraint on 'PublishedExhibit', fields ['owner', 'slug'] + db.delete_unique('exhibit_publishedexhibit', ['owner_id', 'slug']) + + # Deleting field 'PublishedExhibit.publisher' + db.rename_column('exhibit_publishedexhibit', 'owner_id', 'publisher_id') + + db.alter_column('exhibit_publishedexhibit', 'publisher_id', + self.gf('django.db.models.fields.related.ForeignKey')(blank=True, related_name='published_exhibits', null=True, to=orm['auth.User'])) + + # Deleting field 'PublishedExhibit.d' + db.rename_column('exhibit_publishedexhibit', 'description', 'd') + + # Deleting field 'PublishedExhibit.s' + db.rename_column('exhibit_publishedexhibit', 'slug', 's') + + # Deleting field 'PublishedExhibit.t' + db.rename_column('exhibit_publishedexhibit', 'title', 't') + + # Adding unique constraint on 'PublishedExhibit', fields ['publisher', 's'] + db.create_unique('exhibit_publishedexhibit', ['publisher_id', 's']) + + # Deleting field 'DraftExhibit.owner' + db.delete_column('exhibit_draftexhibit', 'owner_id') + + + 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']", 'symmetrical': 'False', 'blank': 'True'}) + }, + 'auth.permission': { + 'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", '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']", 'symmetrical': 'False', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + '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']", 'symmetrical': 'False', 'blank': 'True'}), + 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'}) + }, + 'contenttypes.contenttype': { + 'Meta': {'ordering': "('name',)", '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'}) + }, + 'dataset.dataset': { + 'Meta': {'ordering': "('-modified',)", 'unique_together': "(('slug', 'owner'),)", 'object_name': 'Dataset'}, + 'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'modified': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + 'owner': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'datasets'", 'null': 'True', 'to': "orm['auth.User']"}), + 'published': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'slug': ('django_extensions.db.fields.AutoSlugField', [], {'allow_duplicates': 'False', 'max_length': '50', 'separator': "u'-'", 'blank': 'True', 'populate_from': "'title'", 'overwrite': 'False'}), + 'title': ('django.db.models.fields.CharField', [], {'max_length': '255'}) + }, + 'exhibit.canvas': { + 'Meta': {'object_name': 'Canvas'}, + 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'enabled': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'location': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '100'}), + 'slug': ('django_extensions.db.fields.AutoSlugField', [], {'allow_duplicates': 'False', 'max_length': '50', 'separator': "u'-'", 'blank': 'True', 'populate_from': "'title'", 'overwrite': 'False'}), + 'thumbnail': ('django.db.models.fields.URLField', [], {'max_length': '200'}), + 'title': ('django.db.models.fields.CharField', [], {'max_length': '255'}) + }, + 'exhibit.draftexhibit': { + 'Meta': {'ordering': "('-modified',)", 'object_name': 'DraftExhibit', '_ormbases': ['exhibit.Exhibit']}, + 'exhibit_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['exhibit.Exhibit']", 'unique': 'True', 'primary_key': 'True'}), + 'owner': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'draft_exhibits'", 'null': 'True', 'to': "orm['auth.User']"}), + 'parent': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['exhibit.PublishedExhibit']", 'null': 'True', 'blank': 'True'}), + 'uuid': ('django.db.models.fields.CharField', [], {'max_length': '36', 'blank': 'True'}) + }, + 'exhibit.exhibit': { + 'Meta': {'ordering': "('-modified', '-created')", 'object_name': 'Exhibit'}, + 'canvas': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['exhibit.Canvas']"}), + 'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + 'dataset': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'exhibits'", 'null': 'True', 'to': "orm['dataset.Dataset']"}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'modified': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + 'profile': ('django.db.models.fields.TextField', [], {'default': "'{}'"}) + }, + 'exhibit.publishedexhibit': { + 'Meta': {'ordering': "('-modified',)", 'unique_together': "(('slug', 'owner'),)", 'object_name': 'PublishedExhibit', '_ormbases': ['exhibit.Exhibit']}, + 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'exhibit_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['exhibit.Exhibit']", 'unique': 'True', 'primary_key': 'True'}), + 'is_public': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'owner': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'published_exhibits'", 'null': 'True', 'to': "orm['auth.User']"}), + 'slug': ('django_extensions.db.fields.AutoSlugField', [], {'allow_duplicates': 'False', 'max_length': '50', 'separator': "u'-'", 'blank': 'True', 'populate_from': "'title'", 'overwrite': 'False'}), + 'title': ('django.db.models.fields.CharField', [], {'max_length': '255'}) + } + } + + complete_apps = ['exhibit'] \ No newline at end of file diff --git a/freemix/exhibit/models.py b/freemix/exhibit/models.py index db51f9c9..e1935eb6 100644 --- a/freemix/exhibit/models.py +++ b/freemix/exhibit/models.py @@ -3,6 +3,7 @@ from django.shortcuts import get_object_or_404 from django.utils.translation import ugettext_lazy as _ from django.template.loader import render_to_string +from django_extensions.db.fields import AutoSlugField, UUIDField from django_extensions.db.fields.json import JSONField from django_extensions.db.models import TitleSlugDescriptionModel, TimeStampedModel from freemix.dataset.models import Dataset @@ -26,8 +27,7 @@ class Meta: verbose_name_plural = "Canvases" -class Exhibit(TitleSlugDescriptionModel, TimeStampedModel): - owner = models.ForeignKey(User, null=True, blank=True, related_name="exhibits") +class Exhibit(TimeStampedModel): profile = JSONField() @@ -35,7 +35,30 @@ class Exhibit(TitleSlugDescriptionModel, TimeStampedModel): canvas = models.ForeignKey(Canvas) - published = models.BooleanField(default=True) + def dataset_available(self, user): + """True if the provided user is able to view the dataset associated with this exhibit + """ + ds = self.dataset + if not ds or not user.has_perm("dataset.can_view", ds): + return False + return True + + def update_from_profile(self, profile): + self.profile = profile + self.save() + + +class PublishedExhibit(Exhibit): + + is_public = models.BooleanField(default=True) + owner = models.ForeignKey(User, + null=True, + blank=True, + related_name="published_exhibits") + + title = models.CharField(_('title'), max_length=255) + slug = AutoSlugField(_('slug'), populate_from='title') + description = models.TextField(_('description'), blank=True, null=True) def natural_key(self): return self.owner, self.slug @@ -49,23 +72,27 @@ def get_absolute_url(self): def __unicode__(self): return self.title - def dataset_available(self, user): - """True if the provided user is able to view the dataset associated with this exhibit - """ - ds = self.dataset - if not ds or not user.has_perm("dataset.can_view", ds): - return False - return True + class Meta: + unique_together = ("slug", "owner") + ordering = ('-modified', ) - def update_from_profile(self, profile): - self.profile = profile - self.save() + +class DraftExhibit(Exhibit): + + owner = models.ForeignKey(User, + null=True, + blank=True, + related_name="draft_exhibits") + + uuid = UUIDField(version=4) + + parent = models.ForeignKey(PublishedExhibit, + null=True, + blank=True) class Meta: - unique_together = ("slug", "owner") verbose_name_plural = "Exhibits" verbose_name = "Exhibit" ordering = ('-modified', ) -#class ExhibitProfile(JSONDataModel): -# pass \ No newline at end of file + From 8baf9ed08387d0de48a7035db7b2b800e3822496 Mon Sep 17 00:00:00 2001 From: David Feeney Date: Thu, 11 Jul 2013 03:57:57 -0400 Subject: [PATCH 122/515] Migrate data property metadata from a JSON blob in the dataset app to proper models in the Exhibit app --- ...add_delimitedlistproperty__add_exhibitp.py | 217 ++++++++++++++ ...igrate_data_profile_properties_and_data.py | 230 +++++++++++++++ freemix/exhibit/models.py | 265 +++++++++++++++++- 3 files changed, 698 insertions(+), 14 deletions(-) create mode 100644 freemix/exhibit/migrations/0011_auto__add_patternlistproperty__add_delimitedlistproperty__add_exhibitp.py create mode 100644 freemix/exhibit/migrations/0012_migrate_data_profile_properties_and_data.py diff --git a/freemix/exhibit/migrations/0011_auto__add_patternlistproperty__add_delimitedlistproperty__add_exhibitp.py b/freemix/exhibit/migrations/0011_auto__add_patternlistproperty__add_delimitedlistproperty__add_exhibitp.py new file mode 100644 index 00000000..41483349 --- /dev/null +++ b/freemix/exhibit/migrations/0011_auto__add_patternlistproperty__add_delimitedlistproperty__add_exhibitp.py @@ -0,0 +1,217 @@ +# -*- coding: 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 'PatternListProperty' + db.create_table('exhibit_patternlistproperty', ( + ('exhibitproperty_ptr', self.gf('django.db.models.fields.related.OneToOneField')(to=orm['exhibit.ExhibitProperty'], unique=True, primary_key=True)), + ('source', self.gf('django.db.models.fields.related.ForeignKey')(related_name='+', to=orm['exhibit.ExhibitProperty'])), + ('pattern', self.gf('django.db.models.fields.TextField')()), + )) + db.send_create_signal('exhibit', ['PatternListProperty']) + + # Adding model 'DelimitedListProperty' + db.create_table('exhibit_delimitedlistproperty', ( + ('exhibitproperty_ptr', self.gf('django.db.models.fields.related.OneToOneField')(to=orm['exhibit.ExhibitProperty'], unique=True, primary_key=True)), + ('source', self.gf('django.db.models.fields.related.ForeignKey')(related_name='+', to=orm['exhibit.ExhibitProperty'])), + ('delimiter', self.gf('django.db.models.fields.TextField')()), + )) + db.send_create_signal('exhibit', ['DelimitedListProperty']) + + # Adding model 'ExhibitProperty' + db.create_table('exhibit_exhibitproperty', ( + ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), + ('classname', self.gf('django.db.models.fields.CharField')(max_length=32, null=True)), + ('exhibit', self.gf('django.db.models.fields.related.ForeignKey')(related_name='properties', to=orm['exhibit.Exhibit'])), + ('label', self.gf('django.db.models.fields.CharField')(max_length=255)), + ('name', self.gf('django.db.models.fields.CharField')(max_length=255)), + ('value_type', self.gf('django.db.models.fields.CharField')(default='text', max_length=10)), + )) + db.send_create_signal('exhibit', ['ExhibitProperty']) + + # Adding unique constraint on 'ExhibitProperty', fields ['exhibit', 'name'] + db.create_unique('exhibit_exhibitproperty', ['exhibit_id', 'name']) + + # Adding model 'PropertyReference' + db.create_table('exhibit_propertyreference', ( + ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), + ('derived', self.gf('django.db.models.fields.related.ForeignKey')(related_name='properties', to=orm['exhibit.CompositeProperty'])), + ('source', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['exhibit.ExhibitProperty'])), + ('order', self.gf('django.db.models.fields.PositiveSmallIntegerField')()), + )) + db.send_create_signal('exhibit', ['PropertyReference']) + + # Adding unique constraint on 'PropertyReference', fields ['derived', 'source'] + db.create_unique('exhibit_propertyreference', ['derived_id', 'source_id']) + + # Adding model 'CompositeProperty' + db.create_table('exhibit_compositeproperty', ( + ('exhibitproperty_ptr', self.gf('django.db.models.fields.related.OneToOneField')(to=orm['exhibit.ExhibitProperty'], unique=True, primary_key=True)), + )) + db.send_create_signal('exhibit', ['CompositeProperty']) + + # Adding model 'DataJSONFile' + db.create_table('exhibit_datajsonfile', ( + ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), + ('exhibit', self.gf('django.db.models.fields.related.OneToOneField')(related_name='data', unique=True, to=orm['exhibit.Exhibit'])), + ('json', self.gf('django.db.models.fields.TextField')(default='{}')), + )) + db.send_create_signal('exhibit', ['DataJSONFile']) + + + def backwards(self, orm): + # Removing unique constraint on 'PropertyReference', fields ['derived', 'source'] + db.delete_unique('exhibit_propertyreference', ['derived_id', 'source_id']) + + # Removing unique constraint on 'ExhibitProperty', fields ['exhibit', 'name'] + db.delete_unique('exhibit_exhibitproperty', ['exhibit_id', 'name']) + + # Deleting model 'PatternListProperty' + db.delete_table('exhibit_patternlistproperty') + + # Deleting model 'DelimitedListProperty' + db.delete_table('exhibit_delimitedlistproperty') + + # Deleting model 'ExhibitProperty' + db.delete_table('exhibit_exhibitproperty') + + # Deleting model 'PropertyReference' + db.delete_table('exhibit_propertyreference') + + # Deleting model 'CompositeProperty' + db.delete_table('exhibit_compositeproperty') + + # Deleting model 'DataJSONFile' + db.delete_table('exhibit_datajsonfile') + + + 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']", 'symmetrical': 'False', 'blank': 'True'}) + }, + 'auth.permission': { + 'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", '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']", 'symmetrical': 'False', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + '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']", 'symmetrical': 'False', 'blank': 'True'}), + 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'}) + }, + 'contenttypes.contenttype': { + 'Meta': {'ordering': "('name',)", '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'}) + }, + 'dataset.dataset': { + 'Meta': {'ordering': "('-modified',)", 'unique_together': "(('slug', 'owner'),)", 'object_name': 'Dataset'}, + 'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'modified': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + 'owner': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'datasets'", 'null': 'True', 'to': "orm['auth.User']"}), + 'published': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'slug': ('django_extensions.db.fields.AutoSlugField', [], {'allow_duplicates': 'False', 'max_length': '50', 'separator': "u'-'", 'blank': 'True', 'populate_from': "'title'", 'overwrite': 'False'}), + 'title': ('django.db.models.fields.CharField', [], {'max_length': '255'}) + }, + 'exhibit.canvas': { + 'Meta': {'object_name': 'Canvas'}, + 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'enabled': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'location': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '100'}), + 'slug': ('django_extensions.db.fields.AutoSlugField', [], {'allow_duplicates': 'False', 'max_length': '50', 'separator': "u'-'", 'blank': 'True', 'populate_from': "'title'", 'overwrite': 'False'}), + 'thumbnail': ('django.db.models.fields.URLField', [], {'max_length': '200'}), + 'title': ('django.db.models.fields.CharField', [], {'max_length': '255'}) + }, + 'exhibit.compositeproperty': { + 'Meta': {'object_name': 'CompositeProperty', '_ormbases': ['exhibit.ExhibitProperty']}, + 'exhibitproperty_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['exhibit.ExhibitProperty']", 'unique': 'True', 'primary_key': 'True'}) + }, + 'exhibit.datajsonfile': { + 'Meta': {'object_name': 'DataJSONFile'}, + 'exhibit': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'data'", 'unique': 'True', 'to': "orm['exhibit.Exhibit']"}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'json': ('django.db.models.fields.TextField', [], {'default': "'{}'"}) + }, + 'exhibit.delimitedlistproperty': { + 'Meta': {'object_name': 'DelimitedListProperty'}, + 'delimiter': ('django.db.models.fields.TextField', [], {}), + 'exhibitproperty_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['exhibit.ExhibitProperty']", 'unique': 'True', 'primary_key': 'True'}), + 'source': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'+'", 'to': "orm['exhibit.ExhibitProperty']"}) + }, + 'exhibit.draftexhibit': { + 'Meta': {'ordering': "('-modified',)", 'object_name': 'DraftExhibit', '_ormbases': ['exhibit.Exhibit']}, + 'exhibit_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['exhibit.Exhibit']", 'unique': 'True', 'primary_key': 'True'}), + 'owner': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'draft_exhibits'", 'null': 'True', 'to': "orm['auth.User']"}), + 'parent': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['exhibit.PublishedExhibit']", 'null': 'True', 'blank': 'True'}), + 'uuid': ('django.db.models.fields.CharField', [], {'max_length': '36', 'blank': 'True'}) + }, + 'exhibit.exhibit': { + 'Meta': {'ordering': "('-modified', '-created')", 'object_name': 'Exhibit'}, + 'canvas': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['exhibit.Canvas']"}), + 'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + 'dataset': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'exhibits'", 'null': 'True', 'to': "orm['dataset.Dataset']"}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'modified': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + 'profile': ('django.db.models.fields.TextField', [], {'default': "'{}'"}) + }, + 'exhibit.exhibitproperty': { + 'Meta': {'unique_together': "(('exhibit', 'name'),)", 'object_name': 'ExhibitProperty'}, + 'classname': ('django.db.models.fields.CharField', [], {'max_length': '32', 'null': 'True'}), + 'exhibit': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'properties'", 'to': "orm['exhibit.Exhibit']"}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'label': ('django.db.models.fields.CharField', [], {'max_length': '255'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '255'}), + 'value_type': ('django.db.models.fields.CharField', [], {'default': "'text'", 'max_length': '10'}) + }, + 'exhibit.patternlistproperty': { + 'Meta': {'object_name': 'PatternListProperty'}, + 'exhibitproperty_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['exhibit.ExhibitProperty']", 'unique': 'True', 'primary_key': 'True'}), + 'pattern': ('django.db.models.fields.TextField', [], {}), + 'source': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'+'", 'to': "orm['exhibit.ExhibitProperty']"}) + }, + 'exhibit.propertyreference': { + 'Meta': {'ordering': "('order',)", 'unique_together': "(('derived', 'source'),)", 'object_name': 'PropertyReference'}, + 'derived': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'properties'", 'to': "orm['exhibit.CompositeProperty']"}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'order': ('django.db.models.fields.PositiveSmallIntegerField', [], {}), + 'source': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['exhibit.ExhibitProperty']"}) + }, + 'exhibit.publishedexhibit': { + 'Meta': {'ordering': "('-modified',)", 'unique_together': "(('slug', 'owner'),)", 'object_name': 'PublishedExhibit', '_ormbases': ['exhibit.Exhibit']}, + 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'exhibit_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['exhibit.Exhibit']", 'unique': 'True', 'primary_key': 'True'}), + 'is_public': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'owner': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'published_exhibits'", 'null': 'True', 'to': "orm['auth.User']"}), + 'slug': ('django_extensions.db.fields.AutoSlugField', [], {'allow_duplicates': 'False', 'max_length': '50', 'separator': "u'-'", 'blank': 'True', 'populate_from': "'title'", 'overwrite': 'False'}), + 'title': ('django.db.models.fields.CharField', [], {'max_length': '255'}) + } + } + + complete_apps = ['exhibit'] \ No newline at end of file diff --git a/freemix/exhibit/migrations/0012_migrate_data_profile_properties_and_data.py b/freemix/exhibit/migrations/0012_migrate_data_profile_properties_and_data.py new file mode 100644 index 00000000..d5f722ef --- /dev/null +++ b/freemix/exhibit/migrations/0012_migrate_data_profile_properties_and_data.py @@ -0,0 +1,230 @@ +# -*- coding: utf-8 -*- +import datetime +import json +from south.db import db +from south.v2 import DataMigration +from django.db import models + +def find_type(p): + for t in ["location", "text", "image", "date", "url", "number"]: + if "property:type=%s"%t in p["tags"]: + return t + + return "text" + +class Migration(DataMigration): + + def forwards(self, orm): + + # Migrate Dataset's json files into the new exhibit data model + + for exhibit in orm.Exhibit.objects.all(): + dataset = exhibit.dataset + data = orm["dataset.datasetjsonfile"].objects.get(dataset=dataset).data + profile = orm["dataset.datasetprofile"].objects.get(dataset=dataset).data + orm.DataJSONFile(exhibit=exhibit, json=data).save() + + profile = json.loads(profile) + properties = {} + second_pass = [] + for p in profile["properties"]: + # Do a first run through the properties to + # ensure that all properties exist before + # creating references + k = p.keys() + value_type = find_type(p) + name = p["property"] + label = p["label"] + + if "composite" in k: + classname = "CompositeProperty" + second_pass.append(p) + elif "delimiter" in k: + classname = "DelimitedListProperty" + second_pass.append(p) + elif "pattern" in k: + classname = "PatternListProperty" + second_pass.append(p) + else: + classname="ExhibitProperty" + + prop = orm.ExhibitProperty(exhibit=exhibit, + name=name, + label=label, + value_type=value_type, + classname=classname) + prop.save() + properties[name] = prop + + for p in second_pass: + # Now create the extension objects for augmented properties + + prop = properties[p["property"]] + + if "composite" in k: + ext = orm.CompositeProperty(exhibitproperty_ptr=prop) + ext.__dict__ = prop.__dict__ + ext.save() + counter = 1 + for c in p["composite"]: + ref = orm.PropertyReference(derived=ext, + source=properties[c], + order=counter) + counter += 1 + ref.save() + + elif "delimiter" in k: + ext = orm.DelimitedListProperty(exhibitproperty_ptr=prop, + source=properties[p["extract"]], + delimiter=p["delimiter"]) + ext.__dict__ = prop.__dict__ + ext.save() + elif "pattern" in k: + ext = orm.PatternListProperty(exhibitproperty_ptr=prop, + source=properties[p["extract"]], + pattern=p["pattern"]) + ext.__dict__ = prop.__dict__ + ext.save() + exhibit.save() + + + def backwards(self, orm): + "Write your backwards methods here." + + 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']", 'symmetrical': 'False', 'blank': 'True'}) + }, + 'auth.permission': { + 'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", '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']", 'symmetrical': 'False', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + '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']", 'symmetrical': 'False', 'blank': 'True'}), + 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'}) + }, + 'contenttypes.contenttype': { + 'Meta': {'ordering': "('name',)", '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'}) + }, + 'dataset.dataset': { + 'Meta': {'ordering': "('-modified',)", 'unique_together': "(('slug', 'owner'),)", 'object_name': 'Dataset'}, + 'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'modified': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + 'owner': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'datasets'", 'null': 'True', 'to': "orm['auth.User']"}), + 'published': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'slug': ('django_extensions.db.fields.AutoSlugField', [], {'allow_duplicates': 'False', 'max_length': '50', 'separator': "u'-'", 'blank': 'True', 'populate_from': "'title'", 'overwrite': 'False'}), + 'title': ('django.db.models.fields.CharField', [], {'max_length': '255'}) + }, + 'dataset.datasetjsonfile': { + 'Meta': {'object_name': 'DatasetJSONFile'}, + 'data': ('django.db.models.fields.TextField', [], {'default': "'{}'"}), + 'dataset': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'data'", 'unique': 'True', 'to': "orm['dataset.Dataset']"}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}) + }, + 'dataset.datasetprofile': { + 'Meta': {'object_name': 'DatasetProfile'}, + 'data': ('django.db.models.fields.TextField', [], {'default': "'{}'"}), + 'dataset': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'profile'", 'unique': 'True', 'to': "orm['dataset.Dataset']"}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}) + }, + 'exhibit.canvas': { + 'Meta': {'object_name': 'Canvas'}, + 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'enabled': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'location': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '100'}), + 'slug': ('django_extensions.db.fields.AutoSlugField', [], {'allow_duplicates': 'False', 'max_length': '50', 'separator': "u'-'", 'blank': 'True', 'populate_from': "'title'", 'overwrite': 'False'}), + 'thumbnail': ('django.db.models.fields.URLField', [], {'max_length': '200'}), + 'title': ('django.db.models.fields.CharField', [], {'max_length': '255'}) + }, + 'exhibit.compositeproperty': { + 'Meta': {'object_name': 'CompositeProperty', '_ormbases': ['exhibit.ExhibitProperty']}, + 'exhibitproperty_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['exhibit.ExhibitProperty']", 'unique': 'True', 'primary_key': 'True'}) + }, + 'exhibit.datajsonfile': { + 'Meta': {'object_name': 'DataJSONFile'}, + 'exhibit': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'data'", 'unique': 'True', 'to': "orm['exhibit.Exhibit']"}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'json': ('django.db.models.fields.TextField', [], {'default': "'{}'"}) + }, + 'exhibit.delimitedlistproperty': { + 'Meta': {'object_name': 'DelimitedListProperty'}, + 'delimiter': ('django.db.models.fields.TextField', [], {}), + 'exhibitproperty_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['exhibit.ExhibitProperty']", 'unique': 'True', 'primary_key': 'True'}), + 'source': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'+'", 'to': "orm['exhibit.ExhibitProperty']"}) + }, + 'exhibit.draftexhibit': { + 'Meta': {'ordering': "('-modified',)", 'object_name': 'DraftExhibit', '_ormbases': ['exhibit.Exhibit']}, + 'exhibit_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['exhibit.Exhibit']", 'unique': 'True', 'primary_key': 'True'}), + 'owner': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'draft_exhibits'", 'null': 'True', 'to': "orm['auth.User']"}), + 'parent': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['exhibit.PublishedExhibit']", 'null': 'True', 'blank': 'True'}), + 'uuid': ('django.db.models.fields.CharField', [], {'max_length': '36', 'blank': 'True'}) + }, + 'exhibit.exhibit': { + 'Meta': {'ordering': "('-modified', '-created')", 'object_name': 'Exhibit'}, + 'canvas': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['exhibit.Canvas']"}), + 'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + 'dataset': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'exhibits'", 'null': 'True', 'to': "orm['dataset.Dataset']"}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'modified': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + 'profile': ('django.db.models.fields.TextField', [], {'default': "'{}'"}) + }, + 'exhibit.exhibitproperty': { + 'Meta': {'unique_together': "(('exhibit', 'name'),)", 'object_name': 'ExhibitProperty'}, + 'classname': ('django.db.models.fields.CharField', [], {'max_length': '32', 'null': 'True'}), + 'exhibit': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'properties'", 'to': "orm['exhibit.Exhibit']"}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'label': ('django.db.models.fields.CharField', [], {'max_length': '255'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '255'}), + 'value_type': ('django.db.models.fields.CharField', [], {'default': "'text'", 'max_length': '10'}) + }, + 'exhibit.patternlistproperty': { + 'Meta': {'object_name': 'PatternListProperty'}, + 'exhibitproperty_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['exhibit.ExhibitProperty']", 'unique': 'True', 'primary_key': 'True'}), + 'pattern': ('django.db.models.fields.TextField', [], {}), + 'source': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'+'", 'to': "orm['exhibit.ExhibitProperty']"}) + }, + 'exhibit.propertyreference': { + 'Meta': {'ordering': "('order',)", 'unique_together': "(('derived', 'source'),)", 'object_name': 'PropertyReference'}, + 'derived': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'properties'", 'to': "orm['exhibit.CompositeProperty']"}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'order': ('django.db.models.fields.PositiveSmallIntegerField', [], {}), + 'source': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['exhibit.ExhibitProperty']"}) + }, + 'exhibit.publishedexhibit': { + 'Meta': {'ordering': "('-modified',)", 'unique_together': "(('slug', 'owner'),)", 'object_name': 'PublishedExhibit', '_ormbases': ['exhibit.Exhibit']}, + 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'exhibit_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['exhibit.Exhibit']", 'unique': 'True', 'primary_key': 'True'}), + 'is_public': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'owner': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'published_exhibits'", 'null': 'True', 'to': "orm['auth.User']"}), + 'slug': ('django_extensions.db.fields.AutoSlugField', [], {'allow_duplicates': 'False', 'max_length': '50', 'separator': "u'-'", 'blank': 'True', 'populate_from': "'title'", 'overwrite': 'False'}), + 'title': ('django.db.models.fields.CharField', [], {'max_length': '255'}) + } + } + + complete_apps = ['exhibit'] + symmetrical = True diff --git a/freemix/exhibit/models.py b/freemix/exhibit/models.py index e1935eb6..ef144ad0 100644 --- a/freemix/exhibit/models.py +++ b/freemix/exhibit/models.py @@ -1,21 +1,27 @@ from django.contrib.auth.models import User from django.db import models -from django.shortcuts import get_object_or_404 from django.utils.translation import ugettext_lazy as _ from django.template.loader import render_to_string from django_extensions.db.fields import AutoSlugField, UUIDField from django_extensions.db.fields.json import JSONField -from django_extensions.db.models import TitleSlugDescriptionModel, TimeStampedModel +from django_extensions.db.models import (TitleSlugDescriptionModel, + TimeStampedModel) from freemix.dataset.models import Dataset class Canvas(TitleSlugDescriptionModel): + """ + A reference to a template that contains the HTML for an Exhibit canvas + """ + location = models.CharField(_('location'), unique=True, max_length=100, - help_text=_("Example: 'exhibit/canvas/three-column.html'")) + help_text=_("Example: " + "'exhibit/canvas/" + "three-column.html'")) thumbnail = models.URLField(_('thumbnail')) - enabled = models.BooleanField(_('enabled'), null=False,default=True) + enabled = models.BooleanField(_('enabled'), null=False, default=True) def get_html(self): return render_to_string(self.location, {}) @@ -30,13 +36,18 @@ class Meta: class Exhibit(TimeStampedModel): profile = JSONField() - - dataset = models.ForeignKey(Dataset, null=True, blank=True, related_name="exhibits") + + dataset = models.ForeignKey(Dataset, + null=True, + blank=True, + related_name="exhibits") canvas = models.ForeignKey(Canvas) def dataset_available(self, user): - """True if the provided user is able to view the dataset associated with this exhibit + """ + True if the provided user is able to view the dataset associated + with this exhibit """ ds = self.dataset if not ds or not user.has_perm("dataset.can_view", ds): @@ -49,12 +60,15 @@ def update_from_profile(self, profile): class PublishedExhibit(Exhibit): + """ + A published exhibit with a title and slug for display to end users + """ is_public = models.BooleanField(default=True) owner = models.ForeignKey(User, - null=True, - blank=True, - related_name="published_exhibits") + null=True, + blank=True, + related_name="published_exhibits") title = models.CharField(_('title'), max_length=255) slug = AutoSlugField(_('slug'), populate_from='title') @@ -78,11 +92,18 @@ class Meta: class DraftExhibit(Exhibit): - + """ + A draft exhibit for editing. Modifications to a `DraftExhibit` will + not be visible to end users. If `parent` is populated, the draft should + be a copy of the reference `PublishedExhibit`. Publishing the draft will + move the contents of the `DraftExhibit` into the `PublishedExhibit` and the + draft will be deleted. If `parent` is null, a new `PublishedExhibit` will + be created on publication. + """ owner = models.ForeignKey(User, - null=True, - blank=True, - related_name="draft_exhibits") + null=True, + blank=True, + related_name="draft_exhibits") uuid = UUIDField(version=4) @@ -96,3 +117,219 @@ class Meta: ordering = ('-modified', ) +class DataJSONFile(models.Model): + """ + The data associated with this exhibit in the Exhibit JSON format + """ + exhibit = models.OneToOneField(Exhibit, related_name="data") + + json = JSONField() + + +#-----------------------------------------------------------------------------# +# Exhibit Property Types +#-----------------------------------------------------------------------------# + +VALUE_TYPES = { + "text": "text", + "url": "URL", + "image": "image", + "date": "date/time", + "location": "location", + "number": "number" +} + + +class ExhibitPropertyManager(models.Manager): + """ + Utility methods for the filtered properties on a particular exhibit + """ + use_for_related_fields = True + + def to_dict(self): + """ + Return a dict in exhibit JSON format for property descriptions + """ + qs = self.get_query_set() + result = dict() + for p in qs.all(): + result.update(p.to_dict()) + return {"properties": result} + + def to_profile_dict(self): + """ + Return a dict of properties in the legacy freemix data profile format + """ + qs = self.get_query_set() + result = [p.get_concrete().to_profile_dict() for p in qs.all()] + return {"properties": result} + + +class ExhibitProperty(models.Model): + """ + The Base class for defining individual properties in an exhibit + dataset. The properties defined in this class should be adequate + for reference in published exhibits and basic properties. + """ + + default_manager = ExhibitPropertyManager() + + classname = models.CharField(max_length=32, editable=False, null=True) + + exhibit = models.ForeignKey(Exhibit, + related_name="properties") + + label = models.CharField(_('label'), max_length=255) + + name = models.CharField(_('name'), max_length=255) + + value_type = models.CharField(choices=[(k, v) for k, v in + VALUE_TYPES.iteritems()], + default="text", + max_length=10) + + class Meta: + unique_together = ('exhibit', 'name') + + def natural_key(self): + return self.name + + def save(self, *args, **kwargs): + if self.classname is None: + self.classname = self.__class__.__name__ + return super(ExhibitProperty, self).save(*args, **kwargs) + + def get_concrete(self): + if self.classname == "ExhibitProperty": + return self + return self.__getattribute__(self.classname.lower()) + + def is_concrete(self): + return self.classname == self.__class__.__name__ + + def to_dict(self): + return { + self.name: { + "label": self.label, + "valueType": self.value_type + } + } + + def to_profile_dict(self): + return { + "enabled": True, + "label": self.label, + "property": self.name, + "tags": [ + "property:type=%s" % self.value_type, + ] + + } + + +class CompositeProperty(ExhibitProperty): + """ + Enhanced property that is derived from other properties. This + covers both date/time and location derivations. An ordered list of + source properties is defined using the PropertyReference model. + """ + + def to_dict(self): + d = super(CompositeProperty, self).to_dict() + d[self.name]["composite"] = self.properties.to_array() + return d + + def to_profile_dict(self): + d = super(CompositeProperty, self).to_profile_dict() + d["composite"] = self.properties.to_array() + return d + + +class PropertyReferenceManager(models.Manager): + """ + Utility methods for property references for Composite properties + """ + use_for_related_fields = True + + def to_array(self): + """ + Return a list of the names of all properties in the queryset + """ + qs = self.get_query_set() + return [p.source.name for p in qs.all()] + + +class PropertyReference(models.Model): + """ + A reference to a property used in the derivation of a composite property. + `derived`: the composite property + `source`: The referenced property + `order`: The referenced property's position in the list of sources + """ + + default_manager = PropertyReferenceManager() + + derived = models.ForeignKey('CompositeProperty', related_name="properties") + + source = models.ForeignKey(ExhibitProperty) + + order = models.PositiveSmallIntegerField() + + class Meta: + unique_together = ("derived", "source", ) + ordering = ("order", ) + + +class ShreddedListProperty(ExhibitProperty): + """ + Abstract Base class for properties that derive a list from another property + """ + source = models.ForeignKey(ExhibitProperty, related_name="+") + + def to_dict(self): + d = super(ShreddedListProperty, self).to_dict() + d[self.name]["extract"] = self.source.name + return d + + def to_profile_dict(self): + d = super(ShreddedListProperty, self).to_profile_dict() + d["extract"] = self.source.name + d["tags"].append("property:type=shredded_list") + + class Meta: + abstract = True + + +class DelimitedListProperty(ShreddedListProperty): + """ + Enhanced list property that is split based on a string delimiter + """ + delimiter = models.TextField(_("delimiter")) + + def to_dict(self): + d = super(DelimitedListProperty, self).to_dict() + d[self.name]["delimiter"] = self.delimiter + return d + + def to_profile_dict(self): + d = super(DelimitedListProperty, self).to_profile_dict() + d["delimiter"] = self.delimiter + return d + + +class PatternListProperty(ShreddedListProperty): + """ + Enhanced list property this is split based on a regular expression + """ + + pattern = models.TextField(_("pattern")) + + def to_dict(self): + d = super(PatternListProperty, self).to_dict() + d[self.name]["pattern"] = self.pattern + return d + + def to_profile_dict(self): + d = super(PatternListProperty, self).to_profile_dict() + d["pattern"] = self.pattern + return d From 431abb090599277d54562ee39430010949583070 Mon Sep 17 00:00:00 2001 From: David Feeney Date: Thu, 11 Jul 2013 15:06:48 -0400 Subject: [PATCH 123/515] fixing errant import --- viewshare/apps/share/views.py | 2 +- viewshare/urls.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/viewshare/apps/share/views.py b/viewshare/apps/share/views.py index 49baa028..32d559f4 100644 --- a/viewshare/apps/share/views.py +++ b/viewshare/apps/share/views.py @@ -5,7 +5,7 @@ from django.views.generic.detail import DetailView from django.utils.translation import ugettext_lazy as _ from django.views.generic.edit import CreateView -from freemix.exhibit.share import models +from viewshare.apps.share import models from freemix.dataset import models as dataset_models from freemix.exhibit.models import Exhibit diff --git a/viewshare/urls.py b/viewshare/urls.py index 02fd10f3..53c826e0 100644 --- a/viewshare/urls.py +++ b/viewshare/urls.py @@ -49,7 +49,7 @@ (r'^views/', include('freemix.exhibit.urls')), (r'^augment/', include('freemix.dataset.augment.urls')), - (r'^share/', include('freemix.exhibit.share.urls')), + (r'^share/', include('viewshare.apps.share.urls')), url(r'^userhome/$', login_required(UserHomeView.as_view()), name="user_home"), From fd1c837744870e0344f692d60e8572b1d894680f Mon Sep 17 00:00:00 2001 From: Bill Amberg Date: Thu, 11 Jul 2013 20:13:29 +0000 Subject: [PATCH 124/515] Minor changes for 500 errors: Fix PublishedExhibit and DraftExhibit ModelAdmin classes. Modify freemix.exhibit.forms.CreateExhibitForm and UpdateExhibitDetailForm to reflect new PublishedExhibit model properties. --- freemix/exhibit/admin.py | 11 +++++++++-- freemix/exhibit/forms.py | 14 +++++++------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/freemix/exhibit/admin.py b/freemix/exhibit/admin.py index bfd6f1fe..24ac86ec 100644 --- a/freemix/exhibit/admin.py +++ b/freemix/exhibit/admin.py @@ -8,8 +8,15 @@ class CanvasAdmin(admin.ModelAdmin): admin.site.register(models.Canvas, CanvasAdmin) -class ExhibitAdmin(admin.ModelAdmin): +class DraftExhibitAdmin(admin.ModelAdmin): + list_display = ('uuid', 'owner',) + search_fields = ('owner__username', ) + +admin.site.register(models.DraftExhibit, DraftExhibitAdmin) + + +class PublishedExhibitAdmin(admin.ModelAdmin): list_display = ('slug', 'owner',) search_fields = ('slug', 'title', 'description', 'owner__username') -admin.site.register(models.Exhibit, ExhibitAdmin) +admin.site.register(models.PublishedExhibit, PublishedExhibitAdmin) diff --git a/freemix/exhibit/forms.py b/freemix/exhibit/forms.py index 6f8e9f26..1194cb0d 100644 --- a/freemix/exhibit/forms.py +++ b/freemix/exhibit/forms.py @@ -1,6 +1,6 @@ from django import forms from freemix.exhibit import conf -from freemix.exhibit.models import Exhibit +from freemix.exhibit.models import PublishedExhibit class CreateExhibitForm(forms.ModelForm): @@ -20,17 +20,17 @@ def save(self, commit=True): return instance class Meta: - model = Exhibit - fields = ("title", "description", "published", "profile",) + model = PublishedExhibit + fields = ("title", "description", "is_public", "profile",) widgets= { "profile": forms.HiddenInput(), - "published": forms.RadioSelect(choices=((True, "Public"), (False, "Private"))) + "is_public": forms.RadioSelect(choices=((True, "Public"), (False, "Private"))) } class UpdateExhibitDetailForm(forms.ModelForm): class Meta: - model = Exhibit - fields = ("title", "description", "published",) + model = PublishedExhibit + fields = ("title", "description", "is_public",) widgets = { - "published": forms.RadioSelect(choices=((True, "Public"), (False, "Private"))) + "is_public": forms.RadioSelect(choices=((True, "Public"), (False, "Private"))) } From d9c3c6a9fd0f88520d10dab293a2cc8f0d596537 Mon Sep 17 00:00:00 2001 From: David Feeney Date: Mon, 15 Jul 2013 14:57:04 -0400 Subject: [PATCH 125/515] moving augment app into viewshare --- {freemix/dataset => viewshare/apps}/augment/__init__.py | 0 {freemix/dataset => viewshare/apps}/augment/admin.py | 4 ++-- {freemix/dataset => viewshare/apps}/augment/conf.py | 0 .../apps}/augment/fixtures/initial_data.json | 0 {freemix/dataset => viewshare/apps}/augment/forms.py | 2 +- .../apps}/augment/migrations/0001_initial.py | 0 .../apps}/augment/migrations/0002_force_fixture_load.py | 0 .../apps}/augment/migrations/0003_add_error_codes.py | 0 .../apps}/augment/migrations/__init__.py | 0 {freemix/dataset => viewshare/apps}/augment/models.py | 0 .../apps}/augment/templatetags/__init__.py | 0 .../apps}/augment/templatetags/augment_tags.py | 5 +---- {freemix/dataset => viewshare/apps}/augment/urls.py | 2 +- {freemix/dataset => viewshare/apps}/augment/views.py | 6 +++--- viewshare/apps/legacy/__init__.py | 1 + 15 files changed, 9 insertions(+), 11 deletions(-) rename {freemix/dataset => viewshare/apps}/augment/__init__.py (100%) rename {freemix/dataset => viewshare/apps}/augment/admin.py (72%) rename {freemix/dataset => viewshare/apps}/augment/conf.py (100%) rename {freemix/dataset => viewshare/apps}/augment/fixtures/initial_data.json (100%) rename {freemix/dataset => viewshare/apps}/augment/forms.py (82%) rename {freemix/dataset => viewshare/apps}/augment/migrations/0001_initial.py (100%) rename {freemix/dataset => viewshare/apps}/augment/migrations/0002_force_fixture_load.py (100%) rename {freemix/dataset => viewshare/apps}/augment/migrations/0003_add_error_codes.py (100%) rename {freemix/dataset => viewshare/apps}/augment/migrations/__init__.py (100%) rename {freemix/dataset => viewshare/apps}/augment/models.py (100%) rename {freemix/dataset => viewshare/apps}/augment/templatetags/__init__.py (100%) rename {freemix/dataset => viewshare/apps}/augment/templatetags/augment_tags.py (62%) rename {freemix/dataset => viewshare/apps}/augment/urls.py (87%) rename {freemix/dataset => viewshare/apps}/augment/views.py (96%) create mode 100644 viewshare/apps/legacy/__init__.py diff --git a/freemix/dataset/augment/__init__.py b/viewshare/apps/augment/__init__.py similarity index 100% rename from freemix/dataset/augment/__init__.py rename to viewshare/apps/augment/__init__.py diff --git a/freemix/dataset/augment/admin.py b/viewshare/apps/augment/admin.py similarity index 72% rename from freemix/dataset/augment/admin.py rename to viewshare/apps/augment/admin.py index 3eb97c8c..be3becb5 100644 --- a/freemix/dataset/augment/admin.py +++ b/viewshare/apps/augment/admin.py @@ -1,6 +1,6 @@ from django.contrib import admin -from .models import ListPattern, AugmentationErrorCode -from .forms import ListPatternForm +from .viewshare.apps.augment.models import ListPattern, AugmentationErrorCode +from .viewshare.apps.augment.forms import ListPatternForm class ListPatternAdmin(admin.ModelAdmin): form = ListPatternForm diff --git a/freemix/dataset/augment/conf.py b/viewshare/apps/augment/conf.py similarity index 100% rename from freemix/dataset/augment/conf.py rename to viewshare/apps/augment/conf.py diff --git a/freemix/dataset/augment/fixtures/initial_data.json b/viewshare/apps/augment/fixtures/initial_data.json similarity index 100% rename from freemix/dataset/augment/fixtures/initial_data.json rename to viewshare/apps/augment/fixtures/initial_data.json diff --git a/freemix/dataset/augment/forms.py b/viewshare/apps/augment/forms.py similarity index 82% rename from freemix/dataset/augment/forms.py rename to viewshare/apps/augment/forms.py index e2cfa061..cda50cc4 100644 --- a/freemix/dataset/augment/forms.py +++ b/viewshare/apps/augment/forms.py @@ -1,5 +1,5 @@ from django import forms -from .models import ListPattern +from .viewshare.apps.augment.models import ListPattern class ListPatternForm(forms.ModelForm): diff --git a/freemix/dataset/augment/migrations/0001_initial.py b/viewshare/apps/augment/migrations/0001_initial.py similarity index 100% rename from freemix/dataset/augment/migrations/0001_initial.py rename to viewshare/apps/augment/migrations/0001_initial.py diff --git a/freemix/dataset/augment/migrations/0002_force_fixture_load.py b/viewshare/apps/augment/migrations/0002_force_fixture_load.py similarity index 100% rename from freemix/dataset/augment/migrations/0002_force_fixture_load.py rename to viewshare/apps/augment/migrations/0002_force_fixture_load.py diff --git a/freemix/dataset/augment/migrations/0003_add_error_codes.py b/viewshare/apps/augment/migrations/0003_add_error_codes.py similarity index 100% rename from freemix/dataset/augment/migrations/0003_add_error_codes.py rename to viewshare/apps/augment/migrations/0003_add_error_codes.py diff --git a/freemix/dataset/augment/migrations/__init__.py b/viewshare/apps/augment/migrations/__init__.py similarity index 100% rename from freemix/dataset/augment/migrations/__init__.py rename to viewshare/apps/augment/migrations/__init__.py diff --git a/freemix/dataset/augment/models.py b/viewshare/apps/augment/models.py similarity index 100% rename from freemix/dataset/augment/models.py rename to viewshare/apps/augment/models.py diff --git a/freemix/dataset/augment/templatetags/__init__.py b/viewshare/apps/augment/templatetags/__init__.py similarity index 100% rename from freemix/dataset/augment/templatetags/__init__.py rename to viewshare/apps/augment/templatetags/__init__.py diff --git a/freemix/dataset/augment/templatetags/augment_tags.py b/viewshare/apps/augment/templatetags/augment_tags.py similarity index 62% rename from freemix/dataset/augment/templatetags/augment_tags.py rename to viewshare/apps/augment/templatetags/augment_tags.py index cdf459f5..1ba6fb4d 100644 --- a/freemix/dataset/augment/templatetags/augment_tags.py +++ b/viewshare/apps/augment/templatetags/augment_tags.py @@ -1,8 +1,5 @@ from django import template -from django.conf import settings -from freemix.dataset.augment.models import ListPattern -from django.template.loader import render_to_string -from django.template import Variable +from viewshare.apps.augment.models import ListPattern register = template.Library() diff --git a/freemix/dataset/augment/urls.py b/viewshare/apps/augment/urls.py similarity index 87% rename from freemix/dataset/augment/urls.py rename to viewshare/apps/augment/urls.py index 2d02023f..6e56abb8 100644 --- a/freemix/dataset/augment/urls.py +++ b/viewshare/apps/augment/urls.py @@ -1,5 +1,5 @@ from django.conf.urls.defaults import * -import views +from viewshare.apps.augment import views urlpatterns = patterns('', url(r'^transform/$', views.transform, name="akara_augment"), diff --git a/freemix/dataset/augment/views.py b/viewshare/apps/augment/views.py similarity index 96% rename from freemix/dataset/augment/views.py rename to viewshare/apps/augment/views.py index a2971e62..13a4767c 100644 --- a/freemix/dataset/augment/views.py +++ b/viewshare/apps/augment/views.py @@ -1,9 +1,9 @@ -from freemix.dataset.transform import RawTransformView, AkaraTransformClient from freemix.dataset.augment import models -from freemix.dataset.augment import conf - from django.views.generic.base import View + +from freemix.dataset.transform import RawTransformView, AkaraTransformClient from freemix.views import JSONResponse +from viewshare.apps.augment import conf class JSONView(View): diff --git a/viewshare/apps/legacy/__init__.py b/viewshare/apps/legacy/__init__.py new file mode 100644 index 00000000..5de19ee4 --- /dev/null +++ b/viewshare/apps/legacy/__init__.py @@ -0,0 +1 @@ +__author__ = 'dfeeney' From 87dd2c44efa4d42035ab23d385d2cb08cd57e7bb Mon Sep 17 00:00:00 2001 From: David Feeney Date: Mon, 15 Jul 2013 14:58:24 -0400 Subject: [PATCH 126/515] finishing moving augment app --- docs/ecosystem.rst | 2 +- viewshare/apps/augment/views.py | 2 +- viewshare/settings.py | 2 +- viewshare/urls.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/ecosystem.rst b/docs/ecosystem.rst index 99508e1b..7b86f7d1 100644 --- a/docs/ecosystem.rst +++ b/docs/ecosystem.rst @@ -66,7 +66,7 @@ Custom apps * Descriptions of the columns in uploaded data * Type of data (CSV file, MODS file, etc.) * Descriptions of the data properties which are compatible with exhibit and used to visualize the DataSet through SIMILE's Exhibit - * freemix.dataset.augment + * viewshare.apps.augment * Stores and provides augmentation patterns for dataset cells. For example, a DataSet data cell may contain a list of values separated by a comma. This app provides a pattern that recognizes comma separated data and parses it accordingly. * freemix.exhibit * An Exhibit is a visualization of a DataSet. An Exhibit consists of a Theme and a Canvas: diff --git a/viewshare/apps/augment/views.py b/viewshare/apps/augment/views.py index 13a4767c..eb1a87cb 100644 --- a/viewshare/apps/augment/views.py +++ b/viewshare/apps/augment/views.py @@ -1,4 +1,4 @@ -from freemix.dataset.augment import models +from viewshare.apps.augment import models from django.views.generic.base import View from freemix.dataset.transform import RawTransformView, AkaraTransformClient diff --git a/viewshare/settings.py b/viewshare/settings.py index 2f15b44e..142ebfec 100644 --- a/viewshare/settings.py +++ b/viewshare/settings.py @@ -123,7 +123,7 @@ 'freemix', 'freemix.dataset', 'freemix.exhibit', - 'freemix.dataset.augment', + 'viewshare.apps.augment', 'viewshare.apps.share', # Viewshare specific diff --git a/viewshare/urls.py b/viewshare/urls.py index 53c826e0..016ed413 100644 --- a/viewshare/urls.py +++ b/viewshare/urls.py @@ -48,7 +48,7 @@ # (r'^source/', include('freemix.dataset.urls.datasource')), (r'^views/', include('freemix.exhibit.urls')), - (r'^augment/', include('freemix.dataset.augment.urls')), + (r'^augment/', include('viewshare.apps.augment.urls')), (r'^share/', include('viewshare.apps.share.urls')), url(r'^userhome/$', login_required(UserHomeView.as_view()), name="user_home"), From dc504de4e9d04ed0c811918d26bbb725aaf1d19a Mon Sep 17 00:00:00 2001 From: David Feeney Date: Mon, 15 Jul 2013 15:29:09 -0400 Subject: [PATCH 127/515] moving dataset app into legacy directory for eventual removal --- freemix/exhibit/models.py | 2 +- freemix/exhibit/views.py | 9 ++++----- viewshare/apps/augment/conf.py | 7 +++++-- viewshare/apps/augment/views.py | 5 +++-- viewshare/apps/connections/views.py | 6 ++---- .../apps/legacy}/dataset/__init__.py | 0 {freemix => viewshare/apps/legacy}/dataset/admin.py | 3 ++- {freemix => viewshare/apps/legacy}/dataset/conf.py | 0 {freemix => viewshare/apps/legacy}/dataset/forms.py | 4 +++- .../apps/legacy}/dataset/management/__init__.py | 0 .../legacy}/dataset/management/commands/__init__.py | 0 .../commands/delete_expired_datasources.py | 2 +- .../commands/delete_expired_transactions.py | 2 +- .../dataset/migrations/0001_initial_models.py | 0 .../dataset/migrations/0002_null_datasource_owner.py | 0 .../0003_dataset_onetoone_to_datasource.py | 0 .../dataset/migrations/0004_source_key_reversal.py | 0 .../dataset/migrations/0005_delete_dataset_source.py | 0 .../0006_auto__add_field_dataset_properties_cache.py | 0 .../dataset/migrations/0007_add_property_cache.py | 0 .../dataset/migrations/0008_add_json_models.py | 0 .../legacy}/dataset/migrations/0009_migrate_json.py | 0 .../dataset/migrations/0010_remove_json_fields.py | 0 .../0011_add_datasource_transaction_is_complete.py | 0 .../migrations/0012_set_old_transactions_complete.py | 0 .../apps/legacy}/dataset/migrations/__init__.py | 0 {freemix => viewshare/apps/legacy}/dataset/models.py | 6 +++--- {freemix => viewshare/apps/legacy}/dataset/tasks.py | 4 ++-- .../apps/legacy}/dataset/templatetags/__init__.py | 0 .../legacy}/dataset/templatetags/dataset_tags.py | 0 .../legacy}/dataset/templatetags/datasource_tags.py | 2 +- .../templatetags/datasource_transaction_tags.py | 2 +- .../apps/legacy}/dataset/transform.py | 0 .../apps/legacy}/dataset/urls/__init__.py | 0 .../apps/legacy}/dataset/urls/base.py | 2 +- .../apps/legacy}/dataset/urls/datasource.py | 2 +- .../apps/legacy}/dataset/urls/editor.py | 2 +- .../apps/legacy}/dataset/urls/list.py | 3 +-- .../apps/legacy}/dataset/urls/transaction.py | 4 +++- .../apps/legacy}/dataset/urls/viewer.py | 2 +- {freemix => viewshare/apps/legacy}/dataset/utils.py | 2 +- {freemix => viewshare/apps/legacy}/dataset/views.py | 6 ++++-- viewshare/apps/profiles/views.py | 2 +- viewshare/apps/share/views.py | 1 - viewshare/apps/support/views.py | 4 ++-- viewshare/apps/upload/admin.py | 2 +- viewshare/apps/upload/conf.py | 7 +++++-- viewshare/apps/upload/forms.py | 2 +- viewshare/apps/upload/models.py | 4 ++-- viewshare/apps/upload/views.py | 10 ++++++---- viewshare/utilities/feeds.py | 6 +++--- viewshare/utilities/views.py | 12 ++++++------ 52 files changed, 69 insertions(+), 58 deletions(-) rename {freemix => viewshare/apps/legacy}/dataset/__init__.py (100%) rename {freemix => viewshare/apps/legacy}/dataset/admin.py (93%) rename {freemix => viewshare/apps/legacy}/dataset/conf.py (100%) rename {freemix => viewshare/apps/legacy}/dataset/forms.py (96%) rename {freemix => viewshare/apps/legacy}/dataset/management/__init__.py (100%) rename {freemix => viewshare/apps/legacy}/dataset/management/commands/__init__.py (100%) rename {freemix => viewshare/apps/legacy}/dataset/management/commands/delete_expired_datasources.py (92%) rename {freemix => viewshare/apps/legacy}/dataset/management/commands/delete_expired_transactions.py (91%) rename {freemix => viewshare/apps/legacy}/dataset/migrations/0001_initial_models.py (100%) rename {freemix => viewshare/apps/legacy}/dataset/migrations/0002_null_datasource_owner.py (100%) rename {freemix => viewshare/apps/legacy}/dataset/migrations/0003_dataset_onetoone_to_datasource.py (100%) rename {freemix => viewshare/apps/legacy}/dataset/migrations/0004_source_key_reversal.py (100%) rename {freemix => viewshare/apps/legacy}/dataset/migrations/0005_delete_dataset_source.py (100%) rename {freemix => viewshare/apps/legacy}/dataset/migrations/0006_auto__add_field_dataset_properties_cache.py (100%) rename {freemix => viewshare/apps/legacy}/dataset/migrations/0007_add_property_cache.py (100%) rename {freemix => viewshare/apps/legacy}/dataset/migrations/0008_add_json_models.py (100%) rename {freemix => viewshare/apps/legacy}/dataset/migrations/0009_migrate_json.py (100%) rename {freemix => viewshare/apps/legacy}/dataset/migrations/0010_remove_json_fields.py (100%) rename {freemix => viewshare/apps/legacy}/dataset/migrations/0011_add_datasource_transaction_is_complete.py (100%) rename {freemix => viewshare/apps/legacy}/dataset/migrations/0012_set_old_transactions_complete.py (100%) rename {freemix => viewshare/apps/legacy}/dataset/migrations/__init__.py (100%) rename {freemix => viewshare/apps/legacy}/dataset/models.py (98%) rename {freemix => viewshare/apps/legacy}/dataset/tasks.py (93%) rename {freemix => viewshare/apps/legacy}/dataset/templatetags/__init__.py (100%) rename {freemix => viewshare/apps/legacy}/dataset/templatetags/dataset_tags.py (100%) rename {freemix => viewshare/apps/legacy}/dataset/templatetags/datasource_tags.py (94%) rename {freemix => viewshare/apps/legacy}/dataset/templatetags/datasource_transaction_tags.py (93%) rename {freemix => viewshare/apps/legacy}/dataset/transform.py (100%) rename {freemix => viewshare/apps/legacy}/dataset/urls/__init__.py (100%) rename {freemix => viewshare/apps/legacy}/dataset/urls/base.py (92%) rename {freemix => viewshare/apps/legacy}/dataset/urls/datasource.py (96%) rename {freemix => viewshare/apps/legacy}/dataset/urls/editor.py (95%) rename {freemix => viewshare/apps/legacy}/dataset/urls/list.py (89%) rename {freemix => viewshare/apps/legacy}/dataset/urls/transaction.py (92%) rename {freemix => viewshare/apps/legacy}/dataset/urls/viewer.py (89%) rename {freemix => viewshare/apps/legacy}/dataset/utils.py (92%) rename {freemix => viewshare/apps/legacy}/dataset/views.py (99%) diff --git a/freemix/exhibit/models.py b/freemix/exhibit/models.py index ef144ad0..3c082af7 100644 --- a/freemix/exhibit/models.py +++ b/freemix/exhibit/models.py @@ -6,7 +6,7 @@ from django_extensions.db.fields.json import JSONField from django_extensions.db.models import (TitleSlugDescriptionModel, TimeStampedModel) -from freemix.dataset.models import Dataset +from viewshare.apps.legacy.dataset.models import Dataset class Canvas(TitleSlugDescriptionModel): diff --git a/freemix/exhibit/views.py b/freemix/exhibit/views.py index 6489580b..e6e9de22 100644 --- a/freemix/exhibit/views.py +++ b/freemix/exhibit/views.py @@ -1,5 +1,7 @@ -from django.utils.translation import ugettext_lazy as _ +import json +import uuid +from django.utils.translation import ugettext_lazy as _ from django.http import * from django.views.decorators.http import last_modified from django.views.generic.base import View @@ -11,13 +13,10 @@ from django.views.generic.list import ListView from freemix.exhibit import models, forms, conf -from freemix.dataset.models import Dataset +from viewshare.apps.legacy.dataset.models import Dataset from freemix.exhibit.models import Canvas from freemix.permissions import PermissionsRegistry from freemix.utils import get_site_url - -import json -import uuid from freemix.views import JSONResponse, OwnerListView, OwnerSlugPermissionMixin, BaseJSONView diff --git a/viewshare/apps/augment/conf.py b/viewshare/apps/augment/conf.py index 1c441bc0..aec6b4b6 100644 --- a/viewshare/apps/augment/conf.py +++ b/viewshare/apps/augment/conf.py @@ -1,6 +1,9 @@ -from django.conf import settings from urlparse import urljoin -from freemix.dataset.transform import AKARA_URL_PREFIX + +from django.conf import settings + +from viewshare.apps.legacy.dataset.transform import AKARA_URL_PREFIX + AKARA_AUGMENT_URL = getattr(settings, "AKARA_AUGMENT_URL", urljoin(AKARA_URL_PREFIX, "augment.freemix.json")) diff --git a/viewshare/apps/augment/views.py b/viewshare/apps/augment/views.py index eb1a87cb..191991b4 100644 --- a/viewshare/apps/augment/views.py +++ b/viewshare/apps/augment/views.py @@ -1,7 +1,8 @@ -from viewshare.apps.augment import models from django.views.generic.base import View -from freemix.dataset.transform import RawTransformView, AkaraTransformClient +from viewshare.apps.augment import models + +from viewshare.apps.legacy.dataset.transform import RawTransformView, AkaraTransformClient from freemix.views import JSONResponse from viewshare.apps.augment import conf diff --git a/viewshare/apps/connections/views.py b/viewshare/apps/connections/views.py index b1951fcd..220856e4 100644 --- a/viewshare/apps/connections/views.py +++ b/viewshare/apps/connections/views.py @@ -1,16 +1,14 @@ -from django.db.models.aggregates import Count from django.http import Http404 from django.shortcuts import get_object_or_404, render_to_response from django.template import RequestContext from django.contrib.auth.decorators import login_required from django.contrib import messages - from django.utils.translation import ugettext_lazy as _ +from django.views.generic.list import ListView from viewshare.apps.vendor.friends.models import * -from freemix.dataset.models import Dataset +from viewshare.apps.legacy.dataset.models import Dataset from freemix.permissions import PermissionsRegistry -from django.views.generic.list import ListView from freemix.utils import get_user from freemix.exhibit.models import Exhibit diff --git a/freemix/dataset/__init__.py b/viewshare/apps/legacy/dataset/__init__.py similarity index 100% rename from freemix/dataset/__init__.py rename to viewshare/apps/legacy/dataset/__init__.py diff --git a/freemix/dataset/admin.py b/viewshare/apps/legacy/dataset/admin.py similarity index 93% rename from freemix/dataset/admin.py rename to viewshare/apps/legacy/dataset/admin.py index ed1077d9..3d54b0f9 100644 --- a/freemix/dataset/admin.py +++ b/viewshare/apps/legacy/dataset/admin.py @@ -1,5 +1,6 @@ from django.contrib import admin -from . import models +from viewshare.apps.legacy.dataset import models + def make_json_data_inline(m): class JSONDataFileInline(admin.TabularInline): diff --git a/freemix/dataset/conf.py b/viewshare/apps/legacy/dataset/conf.py similarity index 100% rename from freemix/dataset/conf.py rename to viewshare/apps/legacy/dataset/conf.py diff --git a/freemix/dataset/forms.py b/viewshare/apps/legacy/dataset/forms.py similarity index 96% rename from freemix/dataset/forms.py rename to viewshare/apps/legacy/dataset/forms.py index 3cbbf081..fa4b46c2 100644 --- a/freemix/dataset/forms.py +++ b/viewshare/apps/legacy/dataset/forms.py @@ -1,8 +1,10 @@ from django import forms from django.db import transaction -from freemix.dataset.models import Dataset from django.utils.translation import ugettext_lazy as _ +from viewshare.apps.legacy.dataset.models import Dataset + + published_choices = ((True, "Public"), (False, "Private")) diff --git a/freemix/dataset/management/__init__.py b/viewshare/apps/legacy/dataset/management/__init__.py similarity index 100% rename from freemix/dataset/management/__init__.py rename to viewshare/apps/legacy/dataset/management/__init__.py diff --git a/freemix/dataset/management/commands/__init__.py b/viewshare/apps/legacy/dataset/management/commands/__init__.py similarity index 100% rename from freemix/dataset/management/commands/__init__.py rename to viewshare/apps/legacy/dataset/management/commands/__init__.py diff --git a/freemix/dataset/management/commands/delete_expired_datasources.py b/viewshare/apps/legacy/dataset/management/commands/delete_expired_datasources.py similarity index 92% rename from freemix/dataset/management/commands/delete_expired_datasources.py rename to viewshare/apps/legacy/dataset/management/commands/delete_expired_datasources.py index fb071a5e..4440c6e6 100644 --- a/freemix/dataset/management/commands/delete_expired_datasources.py +++ b/viewshare/apps/legacy/dataset/management/commands/delete_expired_datasources.py @@ -2,7 +2,7 @@ from django.core.management.base import NoArgsCommand -from freemix.dataset.models import DataSource +from viewshare.apps.legacy.dataset.models import DataSource class Command(NoArgsCommand): diff --git a/freemix/dataset/management/commands/delete_expired_transactions.py b/viewshare/apps/legacy/dataset/management/commands/delete_expired_transactions.py similarity index 91% rename from freemix/dataset/management/commands/delete_expired_transactions.py rename to viewshare/apps/legacy/dataset/management/commands/delete_expired_transactions.py index 95c3b13a..2d5145ec 100644 --- a/freemix/dataset/management/commands/delete_expired_transactions.py +++ b/viewshare/apps/legacy/dataset/management/commands/delete_expired_transactions.py @@ -2,7 +2,7 @@ from django.core.management.base import NoArgsCommand -from freemix.dataset.models import DataSourceTransaction +from viewshare.apps.legacy.dataset.models import DataSourceTransaction class Command(NoArgsCommand): diff --git a/freemix/dataset/migrations/0001_initial_models.py b/viewshare/apps/legacy/dataset/migrations/0001_initial_models.py similarity index 100% rename from freemix/dataset/migrations/0001_initial_models.py rename to viewshare/apps/legacy/dataset/migrations/0001_initial_models.py diff --git a/freemix/dataset/migrations/0002_null_datasource_owner.py b/viewshare/apps/legacy/dataset/migrations/0002_null_datasource_owner.py similarity index 100% rename from freemix/dataset/migrations/0002_null_datasource_owner.py rename to viewshare/apps/legacy/dataset/migrations/0002_null_datasource_owner.py diff --git a/freemix/dataset/migrations/0003_dataset_onetoone_to_datasource.py b/viewshare/apps/legacy/dataset/migrations/0003_dataset_onetoone_to_datasource.py similarity index 100% rename from freemix/dataset/migrations/0003_dataset_onetoone_to_datasource.py rename to viewshare/apps/legacy/dataset/migrations/0003_dataset_onetoone_to_datasource.py diff --git a/freemix/dataset/migrations/0004_source_key_reversal.py b/viewshare/apps/legacy/dataset/migrations/0004_source_key_reversal.py similarity index 100% rename from freemix/dataset/migrations/0004_source_key_reversal.py rename to viewshare/apps/legacy/dataset/migrations/0004_source_key_reversal.py diff --git a/freemix/dataset/migrations/0005_delete_dataset_source.py b/viewshare/apps/legacy/dataset/migrations/0005_delete_dataset_source.py similarity index 100% rename from freemix/dataset/migrations/0005_delete_dataset_source.py rename to viewshare/apps/legacy/dataset/migrations/0005_delete_dataset_source.py diff --git a/freemix/dataset/migrations/0006_auto__add_field_dataset_properties_cache.py b/viewshare/apps/legacy/dataset/migrations/0006_auto__add_field_dataset_properties_cache.py similarity index 100% rename from freemix/dataset/migrations/0006_auto__add_field_dataset_properties_cache.py rename to viewshare/apps/legacy/dataset/migrations/0006_auto__add_field_dataset_properties_cache.py diff --git a/freemix/dataset/migrations/0007_add_property_cache.py b/viewshare/apps/legacy/dataset/migrations/0007_add_property_cache.py similarity index 100% rename from freemix/dataset/migrations/0007_add_property_cache.py rename to viewshare/apps/legacy/dataset/migrations/0007_add_property_cache.py diff --git a/freemix/dataset/migrations/0008_add_json_models.py b/viewshare/apps/legacy/dataset/migrations/0008_add_json_models.py similarity index 100% rename from freemix/dataset/migrations/0008_add_json_models.py rename to viewshare/apps/legacy/dataset/migrations/0008_add_json_models.py diff --git a/freemix/dataset/migrations/0009_migrate_json.py b/viewshare/apps/legacy/dataset/migrations/0009_migrate_json.py similarity index 100% rename from freemix/dataset/migrations/0009_migrate_json.py rename to viewshare/apps/legacy/dataset/migrations/0009_migrate_json.py diff --git a/freemix/dataset/migrations/0010_remove_json_fields.py b/viewshare/apps/legacy/dataset/migrations/0010_remove_json_fields.py similarity index 100% rename from freemix/dataset/migrations/0010_remove_json_fields.py rename to viewshare/apps/legacy/dataset/migrations/0010_remove_json_fields.py diff --git a/freemix/dataset/migrations/0011_add_datasource_transaction_is_complete.py b/viewshare/apps/legacy/dataset/migrations/0011_add_datasource_transaction_is_complete.py similarity index 100% rename from freemix/dataset/migrations/0011_add_datasource_transaction_is_complete.py rename to viewshare/apps/legacy/dataset/migrations/0011_add_datasource_transaction_is_complete.py diff --git a/freemix/dataset/migrations/0012_set_old_transactions_complete.py b/viewshare/apps/legacy/dataset/migrations/0012_set_old_transactions_complete.py similarity index 100% rename from freemix/dataset/migrations/0012_set_old_transactions_complete.py rename to viewshare/apps/legacy/dataset/migrations/0012_set_old_transactions_complete.py diff --git a/freemix/dataset/migrations/__init__.py b/viewshare/apps/legacy/dataset/migrations/__init__.py similarity index 100% rename from freemix/dataset/migrations/__init__.py rename to viewshare/apps/legacy/dataset/migrations/__init__.py diff --git a/freemix/dataset/models.py b/viewshare/apps/legacy/dataset/models.py similarity index 98% rename from freemix/dataset/models.py rename to viewshare/apps/legacy/dataset/models.py index 4bf27e77..0bf4b886 100644 --- a/freemix/dataset/models.py +++ b/viewshare/apps/legacy/dataset/models.py @@ -13,8 +13,8 @@ from django_extensions.db.fields.json import JSONField from django_extensions.db.models import ( TimeStampedModel, TitleSlugDescriptionModel) -from freemix.dataset.transform import AKARA_TRANSFORM_URL -from freemix.dataset.transform import AkaraTransformClient +from viewshare.apps.legacy.dataset.transform import AKARA_TRANSFORM_URL +from viewshare.apps.legacy.dataset.transform import AkaraTransformClient logger = logging.getLogger(__name__) @@ -204,7 +204,7 @@ def schedule(self): db_tx.rollback() raise ex else: - from freemix.dataset.tasks import run_transaction + from viewshare.apps.legacy.dataset.tasks import run_transaction run_transaction.delay(self.tx_id) def run(self): diff --git a/freemix/dataset/tasks.py b/viewshare/apps/legacy/dataset/tasks.py similarity index 93% rename from freemix/dataset/tasks.py rename to viewshare/apps/legacy/dataset/tasks.py index dee35127..8f19b638 100644 --- a/freemix/dataset/tasks.py +++ b/viewshare/apps/legacy/dataset/tasks.py @@ -1,9 +1,9 @@ from celery.task import task from celery.task import periodic_task -from celery.task.schedules import crontab from django.core.management import call_command -from freemix.dataset.models import DataSourceTransaction +from celery.task.schedules import crontab +from viewshare.apps.legacy.dataset.models import DataSourceTransaction @task diff --git a/freemix/dataset/templatetags/__init__.py b/viewshare/apps/legacy/dataset/templatetags/__init__.py similarity index 100% rename from freemix/dataset/templatetags/__init__.py rename to viewshare/apps/legacy/dataset/templatetags/__init__.py diff --git a/freemix/dataset/templatetags/dataset_tags.py b/viewshare/apps/legacy/dataset/templatetags/dataset_tags.py similarity index 100% rename from freemix/dataset/templatetags/dataset_tags.py rename to viewshare/apps/legacy/dataset/templatetags/dataset_tags.py diff --git a/freemix/dataset/templatetags/datasource_tags.py b/viewshare/apps/legacy/dataset/templatetags/datasource_tags.py similarity index 94% rename from freemix/dataset/templatetags/datasource_tags.py rename to viewshare/apps/legacy/dataset/templatetags/datasource_tags.py index 90391eec..bdc038d5 100644 --- a/freemix/dataset/templatetags/datasource_tags.py +++ b/viewshare/apps/legacy/dataset/templatetags/datasource_tags.py @@ -1,5 +1,5 @@ from django import template -from freemix.dataset.views import DataSourceRegistry +from viewshare.apps.legacy.dataset.views import DataSourceRegistry register = template.Library() diff --git a/freemix/dataset/templatetags/datasource_transaction_tags.py b/viewshare/apps/legacy/dataset/templatetags/datasource_transaction_tags.py similarity index 93% rename from freemix/dataset/templatetags/datasource_transaction_tags.py rename to viewshare/apps/legacy/dataset/templatetags/datasource_transaction_tags.py index 9535bc7c..404b1c4a 100644 --- a/freemix/dataset/templatetags/datasource_transaction_tags.py +++ b/viewshare/apps/legacy/dataset/templatetags/datasource_transaction_tags.py @@ -1,7 +1,7 @@ from django import template from django.core.urlresolvers import reverse -from freemix.dataset.utils import pretty_print_transaction_status +from viewshare.apps.legacy.dataset.utils import pretty_print_transaction_status register = template.Library() diff --git a/freemix/dataset/transform.py b/viewshare/apps/legacy/dataset/transform.py similarity index 100% rename from freemix/dataset/transform.py rename to viewshare/apps/legacy/dataset/transform.py diff --git a/freemix/dataset/urls/__init__.py b/viewshare/apps/legacy/dataset/urls/__init__.py similarity index 100% rename from freemix/dataset/urls/__init__.py rename to viewshare/apps/legacy/dataset/urls/__init__.py diff --git a/freemix/dataset/urls/base.py b/viewshare/apps/legacy/dataset/urls/base.py similarity index 92% rename from freemix/dataset/urls/base.py rename to viewshare/apps/legacy/dataset/urls/base.py index 557ee0a9..229c4046 100644 --- a/freemix/dataset/urls/base.py +++ b/viewshare/apps/legacy/dataset/urls/base.py @@ -1,5 +1,5 @@ from django.conf.urls.defaults import url, patterns -from freemix.dataset import views +from viewshare.apps.legacy.dataset import views # Dataset parameters urlpatterns = patterns('', diff --git a/freemix/dataset/urls/datasource.py b/viewshare/apps/legacy/dataset/urls/datasource.py similarity index 96% rename from freemix/dataset/urls/datasource.py rename to viewshare/apps/legacy/dataset/urls/datasource.py index 199dc8eb..7e91d9a3 100644 --- a/freemix/dataset/urls/datasource.py +++ b/viewshare/apps/legacy/dataset/urls/datasource.py @@ -2,7 +2,7 @@ from django.contrib.auth.decorators import login_required # Dataset editor -from freemix.dataset import views +from viewshare.apps.legacy.dataset import views urlpatterns = patterns('', diff --git a/freemix/dataset/urls/editor.py b/viewshare/apps/legacy/dataset/urls/editor.py similarity index 95% rename from freemix/dataset/urls/editor.py rename to viewshare/apps/legacy/dataset/urls/editor.py index 0c37d073..89332c98 100644 --- a/freemix/dataset/urls/editor.py +++ b/viewshare/apps/legacy/dataset/urls/editor.py @@ -3,7 +3,7 @@ from django.views.generic.base import TemplateView # Dataset editor -from freemix.dataset import views +from viewshare.apps.legacy.dataset import views urlpatterns = patterns('', url(r'^(?P[a-zA-Z0-9_.-]+)/(?P[a-zA-Z0-9_.-]+)/editor/$', diff --git a/freemix/dataset/urls/list.py b/viewshare/apps/legacy/dataset/urls/list.py similarity index 89% rename from freemix/dataset/urls/list.py rename to viewshare/apps/legacy/dataset/urls/list.py index 9d8eb5f4..96a8fbb2 100644 --- a/freemix/dataset/urls/list.py +++ b/viewshare/apps/legacy/dataset/urls/list.py @@ -1,7 +1,6 @@ -from django.conf import settings from django.conf.urls.defaults import url, patterns from django.contrib.auth.decorators import login_required -from freemix.dataset import views +from viewshare.apps.legacy.dataset import views # Dataset List URLs urlpatterns = patterns('', diff --git a/freemix/dataset/urls/transaction.py b/viewshare/apps/legacy/dataset/urls/transaction.py similarity index 92% rename from freemix/dataset/urls/transaction.py rename to viewshare/apps/legacy/dataset/urls/transaction.py index dd8c1212..4ab061d5 100644 --- a/freemix/dataset/urls/transaction.py +++ b/viewshare/apps/legacy/dataset/urls/transaction.py @@ -1,6 +1,8 @@ -from freemix.dataset import views from django.conf.urls.defaults import url, patterns +from viewshare.apps.legacy.dataset import views + + urlpatterns = patterns('', url(r'^tx/(?P[a-f0-9-]+)/$', views.ProcessTransactionView.as_view(), name='datasource_transaction'), url(r'^tx/(?P[a-f0-9-]+)/result.json$', views.DataSourceTransactionResultView.as_view(), name='datasource_transaction_result'), diff --git a/freemix/dataset/urls/viewer.py b/viewshare/apps/legacy/dataset/urls/viewer.py similarity index 89% rename from freemix/dataset/urls/viewer.py rename to viewshare/apps/legacy/dataset/urls/viewer.py index 5b5c30f6..4b7559cc 100644 --- a/freemix/dataset/urls/viewer.py +++ b/viewshare/apps/legacy/dataset/urls/viewer.py @@ -1,7 +1,7 @@ from django.conf.urls.defaults import url, patterns # Dataset parameters -from freemix.dataset import views +from viewshare.apps.legacy.dataset import views urlpatterns = patterns('', url(r"^(?P[a-zA-Z0-9_.-]+)/(?P[a-zA-Z0-9_.-]+)/$", diff --git a/freemix/dataset/utils.py b/viewshare/apps/legacy/dataset/utils.py similarity index 92% rename from freemix/dataset/utils.py rename to viewshare/apps/legacy/dataset/utils.py index f818b02e..45da1185 100644 --- a/freemix/dataset/utils.py +++ b/viewshare/apps/legacy/dataset/utils.py @@ -1,6 +1,6 @@ from django.utils.translation import ugettext_lazy as _ -from freemix.dataset.models import TX_STATUS +from viewshare.apps.legacy.dataset.models import TX_STATUS def pretty_print_transaction_status(status_id): diff --git a/freemix/dataset/views.py b/viewshare/apps/legacy/dataset/views.py similarity index 99% rename from freemix/dataset/views.py rename to viewshare/apps/legacy/dataset/views.py index 3efb229e..6b52aa6f 100644 --- a/freemix/dataset/views.py +++ b/viewshare/apps/legacy/dataset/views.py @@ -18,8 +18,8 @@ from django.views.generic.edit import CreateView, UpdateView from django.views.generic.list import ListView -from freemix.dataset import conf, forms, models -from freemix.dataset.utils import pretty_print_transaction_status +from viewshare.apps.legacy.dataset import models +from viewshare.apps.legacy.dataset.utils import pretty_print_transaction_status from freemix.permissions import PermissionsRegistry from freemix.views import ( OwnerListView, @@ -31,6 +31,8 @@ #----------------------------------------------------------------------------------------------------------------------# # Data Profile Views +from viewshare.apps.legacy.dataset import forms, conf + def get_request_instance(request, *args, **kwargs): if not hasattr(request, "parent_object"): diff --git a/viewshare/apps/profiles/views.py b/viewshare/apps/profiles/views.py index 3a687aca..31484a72 100644 --- a/viewshare/apps/profiles/views.py +++ b/viewshare/apps/profiles/views.py @@ -13,7 +13,7 @@ from viewshare.apps.vendor.friends.forms import InviteFriendForm from viewshare.apps.vendor.friends.models import (FriendshipInvitation, Friendship) -from freemix.dataset.models import DataSource +from viewshare.apps.legacy.dataset.models import DataSource from freemix.permissions import PermissionsRegistry from viewshare.apps.profiles.forms import ProfileForm diff --git a/viewshare/apps/share/views.py b/viewshare/apps/share/views.py index 32d559f4..c8bdfd6e 100644 --- a/viewshare/apps/share/views.py +++ b/viewshare/apps/share/views.py @@ -7,7 +7,6 @@ from django.views.generic.edit import CreateView from viewshare.apps.share import models -from freemix.dataset import models as dataset_models from freemix.exhibit.models import Exhibit from freemix.views import BaseJSONView from viewshare.apps.share import forms diff --git a/viewshare/apps/support/views.py b/viewshare/apps/support/views.py index 79660484..db57411c 100644 --- a/viewshare/apps/support/views.py +++ b/viewshare/apps/support/views.py @@ -5,11 +5,11 @@ from django.template import loader, RequestContext from django.views.generic import View -from freemix.dataset.models import parse_profile_json, DataSource +from viewshare.apps.legacy.dataset.models import parse_profile_json, DataSource from viewshare.apps.support.backends import get_support_backend from viewshare.utilities.views import get_akara_version -from freemix.dataset.transform import AKARA_URL_PREFIX +from viewshare.apps.legacy.dataset.transform import AKARA_URL_PREFIX from freemix import __version__ as freemix_version from freemix.utils import get_user, get_site_url diff --git a/viewshare/apps/upload/admin.py b/viewshare/apps/upload/admin.py index 2555ac96..a70e187d 100644 --- a/viewshare/apps/upload/admin.py +++ b/viewshare/apps/upload/admin.py @@ -1,6 +1,6 @@ from django.contrib import admin from . import models -from freemix.dataset.admin import DataSourceAdmin +from viewshare.apps.legacy.dataset.admin import DataSourceAdmin class URLDataSourceAdmin(DataSourceAdmin): diff --git a/viewshare/apps/upload/conf.py b/viewshare/apps/upload/conf.py index ed3af149..561dd92b 100644 --- a/viewshare/apps/upload/conf.py +++ b/viewshare/apps/upload/conf.py @@ -1,6 +1,9 @@ -from django.conf import settings from urlparse import urljoin -from freemix.dataset.transform import AKARA_URL_PREFIX + +from django.conf import settings + +from viewshare.apps.legacy.dataset.transform import AKARA_URL_PREFIX + AKARA_CONTENTDM_URL = getattr(settings, "AKARA_CONTENTDM_URL", diff --git a/viewshare/apps/upload/forms.py b/viewshare/apps/upload/forms.py index 34e20249..d220720a 100644 --- a/viewshare/apps/upload/forms.py +++ b/viewshare/apps/upload/forms.py @@ -1,7 +1,7 @@ from django import forms from django.forms.widgets import Select from django.utils.translation import ugettext_lazy as _ -from freemix.dataset.models import DataSource +from viewshare.apps.legacy.dataset.models import DataSource from viewshare.apps.upload import models diff --git a/viewshare/apps/upload/models.py b/viewshare/apps/upload/models.py index c650d701..b6dbf516 100644 --- a/viewshare/apps/upload/models.py +++ b/viewshare/apps/upload/models.py @@ -7,10 +7,10 @@ from django.db import models from django.utils.translation import ugettext_lazy as _ -from freemix.dataset.models import (DataSource, +from viewshare.apps.legacy.dataset.models import (DataSource, URLDataSourceMixin, make_file_data_source_mixin) -from freemix.dataset.transform import AkaraTransformClient +from viewshare.apps.legacy.dataset.transform import AkaraTransformClient from viewshare.apps.upload import conf diff --git a/viewshare/apps/upload/views.py b/viewshare/apps/upload/views.py index 59373c07..3a27aed3 100644 --- a/viewshare/apps/upload/views.py +++ b/viewshare/apps/upload/views.py @@ -1,15 +1,17 @@ import logging +import urllib2 + from django.utils.decorators import method_decorator from django.views.decorators.cache import cache_page from django.views.generic.base import View from django.views.generic.edit import CreateView -from freemix.dataset.transform import AkaraTransformClient -from freemix.dataset.views import DataSourceRegistry -from freemix.views import JSONResponse +from viewshare.apps.legacy.dataset.transform import AkaraTransformClient +from viewshare.apps.legacy.dataset.views import DataSourceRegistry +from freemix.views import JSONResponse from viewshare.apps.upload import forms, conf from viewshare.apps.upload import models -import urllib2 + logger = logging.getLogger(__name__) diff --git a/viewshare/utilities/feeds.py b/viewshare/utilities/feeds.py index 91be5415..91fc7c5e 100644 --- a/viewshare/utilities/feeds.py +++ b/viewshare/utilities/feeds.py @@ -1,14 +1,14 @@ from django.contrib.auth.models import AnonymousUser from django.contrib.syndication.views import Feed from django.utils.feedgenerator import Atom1Feed -from freemix.permissions import PermissionsRegistry +from django.core.urlresolvers import reverse +from freemix.permissions import PermissionsRegistry from freemix.utils import get_user -from freemix.dataset.models import Dataset +from viewshare.apps.legacy.dataset.models import Dataset from freemix.exhibit.models import Exhibit from freemix.utils import get_site_url -from django.core.urlresolvers import reverse class ItemMixin: def item_pubdate(self, item): diff --git a/viewshare/utilities/views.py b/viewshare/utilities/views.py index 3677c820..343189e0 100644 --- a/viewshare/utilities/views.py +++ b/viewshare/utilities/views.py @@ -1,16 +1,16 @@ -from django.contrib.auth.decorators import login_required +from urllib2 import urlopen +from urlparse import urljoin + from django.core.urlresolvers import reverse from django.http import HttpResponseServerError from django.template import loader, RequestContext -from urllib2 import urlopen - from django.core.cache import cache - from django.conf import settings -from urlparse import urljoin from django.template.response import TemplateResponse from django.views.generic.base import RedirectView -from freemix.dataset.transform import AKARA_URL_PREFIX + +from viewshare.apps.legacy.dataset.transform import AKARA_URL_PREFIX + AKARA_VERSION_URL = getattr(settings, "AKARA_VERSION_URL", urljoin(AKARA_URL_PREFIX, "freemix.loader.revision")) From 5ea22b21cadd748a8bed7e31e1972e10fefb0f23 Mon Sep 17 00:00:00 2001 From: David Feeney Date: Mon, 15 Jul 2013 15:30:48 -0400 Subject: [PATCH 128/515] finishing the move of the dataset app to legacy --- docs/ecosystem.rst | 2 +- .../management/commands/delete_expired_datasources.py | 2 +- .../management/commands/delete_expired_transactions.py | 2 +- viewshare/apps/legacy/dataset/urls/__init__.py | 10 +++++----- viewshare/settings.py | 2 +- viewshare/urls.py | 4 ++-- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/docs/ecosystem.rst b/docs/ecosystem.rst index 7b86f7d1..a2c6c032 100644 --- a/docs/ecosystem.rst +++ b/docs/ecosystem.rst @@ -60,7 +60,7 @@ Custom apps ----------- * Freemix specific * freemix - * freemix.dataset + * viewshare.apps.legacy.dataset * A DataSet can be thought of as a group of information related to uploaded data. A DataSet contains information about: * The raw data that was uploaded to Viewshare * Descriptions of the columns in uploaded data diff --git a/viewshare/apps/legacy/dataset/management/commands/delete_expired_datasources.py b/viewshare/apps/legacy/dataset/management/commands/delete_expired_datasources.py index 4440c6e6..3dae0ab8 100644 --- a/viewshare/apps/legacy/dataset/management/commands/delete_expired_datasources.py +++ b/viewshare/apps/legacy/dataset/management/commands/delete_expired_datasources.py @@ -13,7 +13,7 @@ class Command(NoArgsCommand): def handle_noargs(self, **options): logging.basicConfig(level=logging.DEBUG, format="%(message)s") logging.debug("Deleting expired " - "freemix.dataset.models.DataSource models") + "viewshare.apps.legacy.dataset.models.DataSource models") transactions = DataSource.objects.all() expired_transactions = [x for x in transactions if x.is_expired()] record_count = len(expired_transactions) diff --git a/viewshare/apps/legacy/dataset/management/commands/delete_expired_transactions.py b/viewshare/apps/legacy/dataset/management/commands/delete_expired_transactions.py index 2d5145ec..7becefb8 100644 --- a/viewshare/apps/legacy/dataset/management/commands/delete_expired_transactions.py +++ b/viewshare/apps/legacy/dataset/management/commands/delete_expired_transactions.py @@ -12,7 +12,7 @@ class Command(NoArgsCommand): def handle_noargs(self, **options): logging.basicConfig(level=logging.DEBUG, format="%(message)s") logging.debug("Deleting expired " - "freemix.dataset.models.DataSourceTransaction models") + "viewshare.apps.legacy.dataset.models.DataSourceTransaction models") transactions = DataSourceTransaction.objects.all() expired_transactions = [x for x in transactions if x.is_expired()] record_count = len(expired_transactions) diff --git a/viewshare/apps/legacy/dataset/urls/__init__.py b/viewshare/apps/legacy/dataset/urls/__init__.py index 5428cb50..da2b3c4f 100644 --- a/viewshare/apps/legacy/dataset/urls/__init__.py +++ b/viewshare/apps/legacy/dataset/urls/__init__.py @@ -3,11 +3,11 @@ urlpatterns = patterns('', - (r'^', include('freemix.dataset.urls.list')), - (r'^source/', include('freemix.dataset.urls.datasource')), - (r'^', include('freemix.dataset.urls.base')), - (r'^', include('freemix.dataset.urls.viewer')), - (r'^', include('freemix.dataset.urls.editor')), + (r'^', include('viewshare.apps.legacy.dataset.urls.list')), + (r'^source/', include('viewshare.apps.legacy.dataset.urls.datasource')), + (r'^', include('viewshare.apps.legacy.dataset.urls.base')), + (r'^', include('viewshare.apps.legacy.dataset.urls.viewer')), + (r'^', include('viewshare.apps.legacy.dataset.urls.editor')), ) diff --git a/viewshare/settings.py b/viewshare/settings.py index 142ebfec..702c8116 100644 --- a/viewshare/settings.py +++ b/viewshare/settings.py @@ -121,7 +121,7 @@ # Freemix specific 'freemix', - 'freemix.dataset', + 'viewshare.apps.legacy.dataset', 'freemix.exhibit', 'viewshare.apps.augment', 'viewshare.apps.share', diff --git a/viewshare/urls.py b/viewshare/urls.py index 016ed413..9cd0da1b 100644 --- a/viewshare/urls.py +++ b/viewshare/urls.py @@ -44,8 +44,8 @@ name='exhibit_list_by_user_connections'), (r'^upload/', include('viewshare.apps.upload.urls')), - (r'^data/', include('freemix.dataset.urls')), - # (r'^source/', include('freemix.dataset.urls.datasource')), + (r'^data/', include('viewshare.apps.legacy.dataset.urls')), + # (r'^source/', include('viewshare.apps.legacy.dataset.urls.datasource')), (r'^views/', include('freemix.exhibit.urls')), (r'^augment/', include('viewshare.apps.augment.urls')), From 64e68904d03292db552c5f7643323cf4b408c298 Mon Sep 17 00:00:00 2001 From: David Feeney Date: Tue, 16 Jul 2013 11:00:24 -0400 Subject: [PATCH 129/515] ensure all necessary exhibits exist for data migration --- ...ublished_exhibits_for_isolated_datasets.py | 155 ++++++++++++++++ ...grate_data_profile_properties_and_data.py} | 0 .../migrations/0014_populate_profile.py | 161 +++++++++++++++++ .../migrations/0004_auto__add_datasource.py | 171 ++++++++++++++++++ .../0005_auto__add_referencedatasource.py | 168 +++++++++++++++++ viewshare/apps/upload/models.py | 56 ++++-- 6 files changed, 699 insertions(+), 12 deletions(-) create mode 100644 freemix/exhibit/migrations/0012_published_exhibits_for_isolated_datasets.py rename freemix/exhibit/migrations/{0012_migrate_data_profile_properties_and_data.py => 0013_migrate_data_profile_properties_and_data.py} (100%) create mode 100644 freemix/exhibit/migrations/0014_populate_profile.py create mode 100644 viewshare/apps/upload/migrations/0004_auto__add_datasource.py create mode 100644 viewshare/apps/upload/migrations/0005_auto__add_referencedatasource.py diff --git a/freemix/exhibit/migrations/0012_published_exhibits_for_isolated_datasets.py b/freemix/exhibit/migrations/0012_published_exhibits_for_isolated_datasets.py new file mode 100644 index 00000000..ec705ce7 --- /dev/null +++ b/freemix/exhibit/migrations/0012_published_exhibits_for_isolated_datasets.py @@ -0,0 +1,155 @@ +# -*- coding: utf-8 -*- +import datetime +from south.db import db +from south.v2 import DataMigration +from django.db import models +from django.db.models import F + +class Migration(DataMigration): + + def forwards(self, orm): + + canvas = orm.Canvas.objects.get(slug='two-column-left') + + qs = orm['dataset.dataset'].objects.filter(exhibits__publishedexhibit__owner=F('owner')) + + for ds in orm['dataset.dataset'].objects.exclude(pk__in=qs.values_list('pk', flat=True)): + exhibit = orm.PublishedExhibit(created=ds.created, + modified=ds.modified, + slug=ds.slug, + title=ds.title, + description=ds.description, + is_public=ds.published, + owner=ds.owner, + canvas=canvas, + dataset=ds) + exhibit.save() + + def backwards(self, orm): + "Write your backwards methods here." + + 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']", 'symmetrical': 'False', 'blank': 'True'}) + }, + 'auth.permission': { + 'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", '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']", 'symmetrical': 'False', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + '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']", 'symmetrical': 'False', 'blank': 'True'}), + 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'}) + }, + 'contenttypes.contenttype': { + 'Meta': {'ordering': "('name',)", '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'}) + }, + 'dataset.dataset': { + 'Meta': {'ordering': "('-modified',)", 'unique_together': "(('slug', 'owner'),)", 'object_name': 'Dataset'}, + 'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'modified': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + 'owner': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'datasets'", 'null': 'True', 'to': "orm['auth.User']"}), + 'published': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'slug': ('django_extensions.db.fields.AutoSlugField', [], {'allow_duplicates': 'False', 'max_length': '50', 'separator': "u'-'", 'blank': 'True', 'populate_from': "'title'", 'overwrite': 'False'}), + 'title': ('django.db.models.fields.CharField', [], {'max_length': '255'}) + }, + 'exhibit.canvas': { + 'Meta': {'object_name': 'Canvas'}, + 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'enabled': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'location': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '100'}), + 'slug': ('django_extensions.db.fields.AutoSlugField', [], {'allow_duplicates': 'False', 'max_length': '50', 'separator': "u'-'", 'blank': 'True', 'populate_from': "'title'", 'overwrite': 'False'}), + 'thumbnail': ('django.db.models.fields.URLField', [], {'max_length': '200'}), + 'title': ('django.db.models.fields.CharField', [], {'max_length': '255'}) + }, + 'exhibit.compositeproperty': { + 'Meta': {'object_name': 'CompositeProperty', '_ormbases': ['exhibit.ExhibitProperty']}, + 'exhibitproperty_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['exhibit.ExhibitProperty']", 'unique': 'True', 'primary_key': 'True'}) + }, + 'exhibit.datajsonfile': { + 'Meta': {'object_name': 'DataJSONFile'}, + 'exhibit': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'data'", 'unique': 'True', 'to': "orm['exhibit.Exhibit']"}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'json': ('django.db.models.fields.TextField', [], {'default': "'{}'"}) + }, + 'exhibit.delimitedlistproperty': { + 'Meta': {'object_name': 'DelimitedListProperty'}, + 'delimiter': ('django.db.models.fields.TextField', [], {}), + 'exhibitproperty_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['exhibit.ExhibitProperty']", 'unique': 'True', 'primary_key': 'True'}), + 'source': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'+'", 'to': "orm['exhibit.ExhibitProperty']"}) + }, + 'exhibit.draftexhibit': { + 'Meta': {'ordering': "('-modified',)", 'object_name': 'DraftExhibit', '_ormbases': ['exhibit.Exhibit']}, + 'exhibit_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['exhibit.Exhibit']", 'unique': 'True', 'primary_key': 'True'}), + 'owner': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'draft_exhibits'", 'null': 'True', 'to': "orm['auth.User']"}), + 'parent': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['exhibit.PublishedExhibit']", 'null': 'True', 'blank': 'True'}), + 'uuid': ('django.db.models.fields.CharField', [], {'max_length': '36', 'blank': 'True'}) + }, + 'exhibit.exhibit': { + 'Meta': {'ordering': "('-modified', '-created')", 'object_name': 'Exhibit'}, + 'canvas': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['exhibit.Canvas']"}), + 'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + 'dataset': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'exhibits'", 'null': 'True', 'to': "orm['dataset.Dataset']"}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'modified': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + 'profile': ('django.db.models.fields.TextField', [], {'default': "'{}'"}) + }, + 'exhibit.exhibitproperty': { + 'Meta': {'unique_together': "(('exhibit', 'name'),)", 'object_name': 'ExhibitProperty'}, + 'classname': ('django.db.models.fields.CharField', [], {'max_length': '32', 'null': 'True'}), + 'exhibit': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'properties'", 'to': "orm['exhibit.Exhibit']"}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'label': ('django.db.models.fields.CharField', [], {'max_length': '255'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '255'}), + 'value_type': ('django.db.models.fields.CharField', [], {'default': "'text'", 'max_length': '10'}) + }, + 'exhibit.patternlistproperty': { + 'Meta': {'object_name': 'PatternListProperty'}, + 'exhibitproperty_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['exhibit.ExhibitProperty']", 'unique': 'True', 'primary_key': 'True'}), + 'pattern': ('django.db.models.fields.TextField', [], {}), + 'source': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'+'", 'to': "orm['exhibit.ExhibitProperty']"}) + }, + 'exhibit.propertyreference': { + 'Meta': {'ordering': "('order',)", 'unique_together': "(('derived', 'source'),)", 'object_name': 'PropertyReference'}, + 'derived': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'properties'", 'to': "orm['exhibit.CompositeProperty']"}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'order': ('django.db.models.fields.PositiveSmallIntegerField', [], {}), + 'source': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['exhibit.ExhibitProperty']"}) + }, + 'exhibit.publishedexhibit': { + 'Meta': {'ordering': "('-modified',)", 'unique_together': "(('slug', 'owner'),)", 'object_name': 'PublishedExhibit', '_ormbases': ['exhibit.Exhibit']}, + 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'exhibit_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['exhibit.Exhibit']", 'unique': 'True', 'primary_key': 'True'}), + 'is_public': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'owner': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'published_exhibits'", 'null': 'True', 'to': "orm['auth.User']"}), + 'slug': ('django_extensions.db.fields.AutoSlugField', [], {'allow_duplicates': 'False', 'max_length': '50', 'separator': "u'-'", 'blank': 'True', 'populate_from': "'title'", 'overwrite': 'False'}), + 'title': ('django.db.models.fields.CharField', [], {'max_length': '255'}) + } + } + + complete_apps = ['exhibit'] + symmetrical = True diff --git a/freemix/exhibit/migrations/0012_migrate_data_profile_properties_and_data.py b/freemix/exhibit/migrations/0013_migrate_data_profile_properties_and_data.py similarity index 100% rename from freemix/exhibit/migrations/0012_migrate_data_profile_properties_and_data.py rename to freemix/exhibit/migrations/0013_migrate_data_profile_properties_and_data.py diff --git a/freemix/exhibit/migrations/0014_populate_profile.py b/freemix/exhibit/migrations/0014_populate_profile.py new file mode 100644 index 00000000..ee1642f1 --- /dev/null +++ b/freemix/exhibit/migrations/0014_populate_profile.py @@ -0,0 +1,161 @@ +# -*- coding: utf-8 -*- +import datetime +import json +from south.db import db +from south.v2 import DataMigration +from django.db import models +import uuid + +class Migration(DataMigration): + + def forwards(self, orm): + for exhibit in orm.Exhibit.objects.filter(profile='{}'): + names = [p.name for p in exhibit.properties.all()] + profile = { + "facets": {}, + "views": { + "views": [{ + "name": "List", + "id": str(uuid.uuid4()), + "lens": { + "properties": names, + "type": "list" + } + }] + }, + "default_lens": { + "properties": names, + "type": "list" + } + } + exhibit.profile = json.dumps(profile) + exhibit.save() + + def backwards(self, orm): + "Write your backwards methods here." + + 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']", 'symmetrical': 'False', 'blank': 'True'}) + }, + 'auth.permission': { + 'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", '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']", 'symmetrical': 'False', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + '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']", 'symmetrical': 'False', 'blank': 'True'}), + 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'}) + }, + 'contenttypes.contenttype': { + 'Meta': {'ordering': "('name',)", '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'}) + }, + 'dataset.dataset': { + 'Meta': {'ordering': "('-modified',)", 'unique_together': "(('slug', 'owner'),)", 'object_name': 'Dataset'}, + 'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'modified': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + 'owner': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'datasets'", 'null': 'True', 'to': "orm['auth.User']"}), + 'published': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'slug': ('django_extensions.db.fields.AutoSlugField', [], {'allow_duplicates': 'False', 'max_length': '50', 'separator': "u'-'", 'blank': 'True', 'populate_from': "'title'", 'overwrite': 'False'}), + 'title': ('django.db.models.fields.CharField', [], {'max_length': '255'}) + }, + 'exhibit.canvas': { + 'Meta': {'object_name': 'Canvas'}, + 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'enabled': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'location': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '100'}), + 'slug': ('django_extensions.db.fields.AutoSlugField', [], {'allow_duplicates': 'False', 'max_length': '50', 'separator': "u'-'", 'blank': 'True', 'populate_from': "'title'", 'overwrite': 'False'}), + 'thumbnail': ('django.db.models.fields.URLField', [], {'max_length': '200'}), + 'title': ('django.db.models.fields.CharField', [], {'max_length': '255'}) + }, + 'exhibit.compositeproperty': { + 'Meta': {'object_name': 'CompositeProperty', '_ormbases': ['exhibit.ExhibitProperty']}, + 'exhibitproperty_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['exhibit.ExhibitProperty']", 'unique': 'True', 'primary_key': 'True'}) + }, + 'exhibit.datajsonfile': { + 'Meta': {'object_name': 'DataJSONFile'}, + 'exhibit': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'data'", 'unique': 'True', 'to': "orm['exhibit.Exhibit']"}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'json': ('django.db.models.fields.TextField', [], {'default': "'{}'"}) + }, + 'exhibit.delimitedlistproperty': { + 'Meta': {'object_name': 'DelimitedListProperty'}, + 'delimiter': ('django.db.models.fields.TextField', [], {}), + 'exhibitproperty_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['exhibit.ExhibitProperty']", 'unique': 'True', 'primary_key': 'True'}), + 'source': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'+'", 'to': "orm['exhibit.ExhibitProperty']"}) + }, + 'exhibit.draftexhibit': { + 'Meta': {'ordering': "('-modified',)", 'object_name': 'DraftExhibit', '_ormbases': ['exhibit.Exhibit']}, + 'exhibit_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['exhibit.Exhibit']", 'unique': 'True', 'primary_key': 'True'}), + 'owner': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'draft_exhibits'", 'null': 'True', 'to': "orm['auth.User']"}), + 'parent': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['exhibit.PublishedExhibit']", 'null': 'True', 'blank': 'True'}), + 'uuid': ('django.db.models.fields.CharField', [], {'max_length': '36', 'blank': 'True'}) + }, + 'exhibit.exhibit': { + 'Meta': {'ordering': "('-modified', '-created')", 'object_name': 'Exhibit'}, + 'canvas': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['exhibit.Canvas']"}), + 'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + 'dataset': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'exhibits'", 'null': 'True', 'to': "orm['dataset.Dataset']"}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'modified': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + 'profile': ('django.db.models.fields.TextField', [], {'default': "'{}'"}) + }, + 'exhibit.exhibitproperty': { + 'Meta': {'unique_together': "(('exhibit', 'name'),)", 'object_name': 'ExhibitProperty'}, + 'classname': ('django.db.models.fields.CharField', [], {'max_length': '32', 'null': 'True'}), + 'exhibit': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'properties'", 'to': "orm['exhibit.Exhibit']"}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'label': ('django.db.models.fields.CharField', [], {'max_length': '255'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '255'}), + 'value_type': ('django.db.models.fields.CharField', [], {'default': "'text'", 'max_length': '10'}) + }, + 'exhibit.patternlistproperty': { + 'Meta': {'object_name': 'PatternListProperty'}, + 'exhibitproperty_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['exhibit.ExhibitProperty']", 'unique': 'True', 'primary_key': 'True'}), + 'pattern': ('django.db.models.fields.TextField', [], {}), + 'source': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'+'", 'to': "orm['exhibit.ExhibitProperty']"}) + }, + 'exhibit.propertyreference': { + 'Meta': {'ordering': "('order',)", 'unique_together': "(('derived', 'source'),)", 'object_name': 'PropertyReference'}, + 'derived': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'properties'", 'to': "orm['exhibit.CompositeProperty']"}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'order': ('django.db.models.fields.PositiveSmallIntegerField', [], {}), + 'source': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['exhibit.ExhibitProperty']"}) + }, + 'exhibit.publishedexhibit': { + 'Meta': {'ordering': "('-modified',)", 'unique_together': "(('slug', 'owner'),)", 'object_name': 'PublishedExhibit', '_ormbases': ['exhibit.Exhibit']}, + 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'exhibit_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['exhibit.Exhibit']", 'unique': 'True', 'primary_key': 'True'}), + 'is_public': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'owner': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'published_exhibits'", 'null': 'True', 'to': "orm['auth.User']"}), + 'slug': ('django_extensions.db.fields.AutoSlugField', [], {'allow_duplicates': 'False', 'max_length': '50', 'separator': "u'-'", 'blank': 'True', 'populate_from': "'title'", 'overwrite': 'False'}), + 'title': ('django.db.models.fields.CharField', [], {'max_length': '255'}) + } + } + + complete_apps = ['exhibit'] + symmetrical = True diff --git a/viewshare/apps/upload/migrations/0004_auto__add_datasource.py b/viewshare/apps/upload/migrations/0004_auto__add_datasource.py new file mode 100644 index 00000000..93e408c6 --- /dev/null +++ b/viewshare/apps/upload/migrations/0004_auto__add_datasource.py @@ -0,0 +1,171 @@ +# -*- coding: utf-8 -*- +import datetime +from south.db import db +from south.v2 import SchemaMigration +from django.db import models + + +class Migration(SchemaMigration): + + depends_on = ( + ("exhibit", "0014_populate_profile"), + ) + + + def forwards(self, orm): + # Adding model 'DataSource' + db.create_table('upload_datasource', ( + ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), + ('created', self.gf('django.db.models.fields.DateTimeField')(default=datetime.datetime.now, blank=True)), + ('modified', self.gf('django.db.models.fields.DateTimeField')(default=datetime.datetime.now, blank=True)), + ('classname', self.gf('django.db.models.fields.CharField')(max_length=32, null=True)), + ('exhibit', self.gf('django.db.models.fields.related.OneToOneField')(related_name='source', unique=True, to=orm['exhibit.Exhibit'])), + )) + db.send_create_signal('upload', ['DataSource']) + + + def backwards(self, orm): + # Deleting model 'DataSource' + db.delete_table('upload_datasource') + + + 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']", 'symmetrical': 'False', 'blank': 'True'}) + }, + 'auth.permission': { + 'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", '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']", 'symmetrical': 'False', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + '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']", 'symmetrical': 'False', 'blank': 'True'}), + 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'}) + }, + 'contenttypes.contenttype': { + 'Meta': {'ordering': "('name',)", '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'}) + }, + 'dataset.dataset': { + 'Meta': {'ordering': "('-modified',)", 'unique_together': "(('slug', 'owner'),)", 'object_name': 'Dataset'}, + 'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'modified': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + 'owner': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'datasets'", 'null': 'True', 'to': "orm['auth.User']"}), + 'published': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'slug': ('django_extensions.db.fields.AutoSlugField', [], {'allow_duplicates': 'False', 'max_length': '50', 'separator': "u'-'", 'blank': 'True', 'populate_from': "'title'", 'overwrite': 'False'}), + 'title': ('django.db.models.fields.CharField', [], {'max_length': '255'}) + }, + 'dataset.datasource': { + 'Meta': {'ordering': "('-modified', '-created')", 'object_name': 'DataSource'}, + 'classname': ('django.db.models.fields.CharField', [], {'max_length': '32', 'null': 'True'}), + 'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + 'dataset': ('django.db.models.fields.related.OneToOneField', [], {'blank': 'True', 'related_name': "'source'", 'unique': 'True', 'null': 'True', 'to': "orm['dataset.Dataset']"}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'modified': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + 'owner': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'data_sources'", 'null': 'True', 'to': "orm['auth.User']"}), + 'uuid': ('django.db.models.fields.CharField', [], {'max_length': '36', 'blank': 'True'}) + }, + 'exhibit.canvas': { + 'Meta': {'object_name': 'Canvas'}, + 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'enabled': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'location': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '100'}), + 'slug': ('django_extensions.db.fields.AutoSlugField', [], {'allow_duplicates': 'False', 'max_length': '50', 'separator': "u'-'", 'blank': 'True', 'populate_from': "'title'", 'overwrite': 'False'}), + 'thumbnail': ('django.db.models.fields.URLField', [], {'max_length': '200'}), + 'title': ('django.db.models.fields.CharField', [], {'max_length': '255'}) + }, + 'exhibit.exhibit': { + 'Meta': {'ordering': "('-modified', '-created')", 'object_name': 'Exhibit'}, + 'canvas': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['exhibit.Canvas']"}), + 'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + 'dataset': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'exhibits'", 'null': 'True', 'to': "orm['dataset.Dataset']"}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'modified': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + 'profile': ('django.db.models.fields.TextField', [], {'default': "'{}'"}) + }, + 'upload.contentdmdatasource': { + 'Meta': {'object_name': 'ContentDMDataSource', '_ormbases': ['dataset.DataSource']}, + 'collection': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}), + 'datasource_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['dataset.DataSource']", 'unique': 'True', 'primary_key': 'True'}), + 'limit': ('django.db.models.fields.IntegerField', [], {'default': "'100'"}), + 'query': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}), + 'url': ('django.db.models.fields.URLField', [], {'max_length': '200'}) + }, + 'upload.datasource': { + 'Meta': {'ordering': "('-modified', '-created')", 'object_name': 'DataSource'}, + 'classname': ('django.db.models.fields.CharField', [], {'max_length': '32', 'null': 'True'}), + 'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + 'exhibit': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'source'", 'unique': 'True', 'to': "orm['exhibit.Exhibit']"}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'modified': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}) + }, + 'upload.filedatasource': { + 'Meta': {'object_name': 'FileDataSource', '_ormbases': ['dataset.DataSource']}, + 'datasource_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['dataset.DataSource']", 'unique': 'True', 'primary_key': 'True'}), + 'file': ('django.db.models.fields.files.FileField', [], {'max_length': '255'}) + }, + 'upload.jsonfiledatasource': { + 'Meta': {'object_name': 'JSONFileDataSource', '_ormbases': ['dataset.DataSource']}, + 'datasource_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['dataset.DataSource']", 'unique': 'True', 'primary_key': 'True'}), + 'file': ('django.db.models.fields.files.FileField', [], {'max_length': '255'}), + 'mapping': ('django.db.models.fields.TextField', [], {}), + 'path': ('django.db.models.fields.TextField', [], {}) + }, + 'upload.jsonurldatasource': { + 'Meta': {'object_name': 'JSONURLDataSource', '_ormbases': ['dataset.DataSource']}, + 'datasource_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['dataset.DataSource']", 'unique': 'True', 'primary_key': 'True'}), + 'mapping': ('django.db.models.fields.TextField', [], {}), + 'path': ('django.db.models.fields.TextField', [], {}), + 'url': ('django.db.models.fields.URLField', [], {'max_length': '200'}) + }, + 'upload.modsfiledatasource': { + 'Meta': {'object_name': 'ModsFileDataSource', '_ormbases': ['dataset.DataSource']}, + 'datasource_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['dataset.DataSource']", 'unique': 'True', 'primary_key': 'True'}), + 'diagnostics': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'file': ('django.db.models.fields.files.FileField', [], {'max_length': '255'}) + }, + 'upload.modsurldatasource': { + 'Meta': {'object_name': 'ModsURLDataSource', '_ormbases': ['dataset.DataSource']}, + 'datasource_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['dataset.DataSource']", 'unique': 'True', 'primary_key': 'True'}), + 'diagnostics': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'url': ('django.db.models.fields.URLField', [], {'max_length': '200'}) + }, + 'upload.oaidatasource': { + 'Meta': {'object_name': 'OAIDataSource', '_ormbases': ['dataset.DataSource']}, + 'datasource_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['dataset.DataSource']", 'unique': 'True', 'primary_key': 'True'}), + 'limit': ('django.db.models.fields.IntegerField', [], {'default': "'100'"}), + 'set': ('django.db.models.fields.CharField', [], {'max_length': '255'}), + 'title': ('django.db.models.fields.CharField', [], {'max_length': '255'}), + 'url': ('django.db.models.fields.URLField', [], {'max_length': '200'}) + }, + 'upload.urldatasource': { + 'Meta': {'object_name': 'URLDataSource', '_ormbases': ['dataset.DataSource']}, + 'datasource_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['dataset.DataSource']", 'unique': 'True', 'primary_key': 'True'}), + 'url': ('django.db.models.fields.URLField', [], {'max_length': '200'}) + } + } + + complete_apps = ['upload'] \ No newline at end of file diff --git a/viewshare/apps/upload/migrations/0005_auto__add_referencedatasource.py b/viewshare/apps/upload/migrations/0005_auto__add_referencedatasource.py new file mode 100644 index 00000000..74962bb8 --- /dev/null +++ b/viewshare/apps/upload/migrations/0005_auto__add_referencedatasource.py @@ -0,0 +1,168 @@ +# -*- coding: 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 'ReferenceDataSource' + db.create_table('upload_referencedatasource', ( + ('datasource_ptr', self.gf('django.db.models.fields.related.OneToOneField')(to=orm['dataset.DataSource'], unique=True, primary_key=True)), + ('referenced', self.gf('django.db.models.fields.related.ForeignKey')(related_name='references', to=orm['exhibit.Exhibit'])), + )) + db.send_create_signal('upload', ['ReferenceDataSource']) + + + def backwards(self, orm): + # Deleting model 'ReferenceDataSource' + db.delete_table('upload_referencedatasource') + + + 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']", 'symmetrical': 'False', 'blank': 'True'}) + }, + 'auth.permission': { + 'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", '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']", 'symmetrical': 'False', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + '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']", 'symmetrical': 'False', 'blank': 'True'}), + 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'}) + }, + 'contenttypes.contenttype': { + 'Meta': {'ordering': "('name',)", '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'}) + }, + 'dataset.dataset': { + 'Meta': {'ordering': "('-modified',)", 'unique_together': "(('slug', 'owner'),)", 'object_name': 'Dataset'}, + 'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'modified': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + 'owner': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'datasets'", 'null': 'True', 'to': "orm['auth.User']"}), + 'published': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'slug': ('django_extensions.db.fields.AutoSlugField', [], {'allow_duplicates': 'False', 'max_length': '50', 'separator': "u'-'", 'blank': 'True', 'populate_from': "'title'", 'overwrite': 'False'}), + 'title': ('django.db.models.fields.CharField', [], {'max_length': '255'}) + }, + 'dataset.datasource': { + 'Meta': {'ordering': "('-modified', '-created')", 'object_name': 'DataSource'}, + 'classname': ('django.db.models.fields.CharField', [], {'max_length': '32', 'null': 'True'}), + 'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + 'dataset': ('django.db.models.fields.related.OneToOneField', [], {'blank': 'True', 'related_name': "'source'", 'unique': 'True', 'null': 'True', 'to': "orm['dataset.Dataset']"}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'modified': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + 'owner': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'data_sources'", 'null': 'True', 'to': "orm['auth.User']"}), + 'uuid': ('django.db.models.fields.CharField', [], {'max_length': '36', 'blank': 'True'}) + }, + 'exhibit.canvas': { + 'Meta': {'object_name': 'Canvas'}, + 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'enabled': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'location': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '100'}), + 'slug': ('django_extensions.db.fields.AutoSlugField', [], {'allow_duplicates': 'False', 'max_length': '50', 'separator': "u'-'", 'blank': 'True', 'populate_from': "'title'", 'overwrite': 'False'}), + 'thumbnail': ('django.db.models.fields.URLField', [], {'max_length': '200'}), + 'title': ('django.db.models.fields.CharField', [], {'max_length': '255'}) + }, + 'exhibit.exhibit': { + 'Meta': {'ordering': "('-modified', '-created')", 'object_name': 'Exhibit'}, + 'canvas': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['exhibit.Canvas']"}), + 'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + 'dataset': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'exhibits'", 'null': 'True', 'to': "orm['dataset.Dataset']"}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'modified': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + 'profile': ('django.db.models.fields.TextField', [], {'default': "'{}'"}) + }, + 'upload.contentdmdatasource': { + 'Meta': {'object_name': 'ContentDMDataSource', '_ormbases': ['dataset.DataSource']}, + 'collection': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}), + 'datasource_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['dataset.DataSource']", 'unique': 'True', 'primary_key': 'True'}), + 'limit': ('django.db.models.fields.IntegerField', [], {'default': "'100'"}), + 'query': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}), + 'url': ('django.db.models.fields.URLField', [], {'max_length': '200'}) + }, + 'upload.datasource': { + 'Meta': {'ordering': "('-modified', '-created')", 'object_name': 'DataSource'}, + 'classname': ('django.db.models.fields.CharField', [], {'max_length': '32', 'null': 'True'}), + 'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + 'exhibit': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'source'", 'unique': 'True', 'to': "orm['exhibit.Exhibit']"}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'modified': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}) + }, + 'upload.filedatasource': { + 'Meta': {'object_name': 'FileDataSource', '_ormbases': ['dataset.DataSource']}, + 'datasource_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['dataset.DataSource']", 'unique': 'True', 'primary_key': 'True'}), + 'file': ('django.db.models.fields.files.FileField', [], {'max_length': '255'}) + }, + 'upload.jsonfiledatasource': { + 'Meta': {'object_name': 'JSONFileDataSource', '_ormbases': ['dataset.DataSource']}, + 'datasource_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['dataset.DataSource']", 'unique': 'True', 'primary_key': 'True'}), + 'file': ('django.db.models.fields.files.FileField', [], {'max_length': '255'}), + 'mapping': ('django.db.models.fields.TextField', [], {}), + 'path': ('django.db.models.fields.TextField', [], {}) + }, + 'upload.jsonurldatasource': { + 'Meta': {'object_name': 'JSONURLDataSource', '_ormbases': ['dataset.DataSource']}, + 'datasource_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['dataset.DataSource']", 'unique': 'True', 'primary_key': 'True'}), + 'mapping': ('django.db.models.fields.TextField', [], {}), + 'path': ('django.db.models.fields.TextField', [], {}), + 'url': ('django.db.models.fields.URLField', [], {'max_length': '200'}) + }, + 'upload.modsfiledatasource': { + 'Meta': {'object_name': 'ModsFileDataSource', '_ormbases': ['dataset.DataSource']}, + 'datasource_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['dataset.DataSource']", 'unique': 'True', 'primary_key': 'True'}), + 'diagnostics': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'file': ('django.db.models.fields.files.FileField', [], {'max_length': '255'}) + }, + 'upload.modsurldatasource': { + 'Meta': {'object_name': 'ModsURLDataSource', '_ormbases': ['dataset.DataSource']}, + 'datasource_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['dataset.DataSource']", 'unique': 'True', 'primary_key': 'True'}), + 'diagnostics': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'url': ('django.db.models.fields.URLField', [], {'max_length': '200'}) + }, + 'upload.oaidatasource': { + 'Meta': {'object_name': 'OAIDataSource', '_ormbases': ['dataset.DataSource']}, + 'datasource_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['dataset.DataSource']", 'unique': 'True', 'primary_key': 'True'}), + 'limit': ('django.db.models.fields.IntegerField', [], {'default': "'100'"}), + 'set': ('django.db.models.fields.CharField', [], {'max_length': '255'}), + 'title': ('django.db.models.fields.CharField', [], {'max_length': '255'}), + 'url': ('django.db.models.fields.URLField', [], {'max_length': '200'}) + }, + 'upload.referencedatasource': { + 'Meta': {'ordering': "('-modified', '-created')", 'object_name': 'ReferenceDataSource', '_ormbases': ['dataset.DataSource']}, + 'datasource_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['dataset.DataSource']", 'unique': 'True', 'primary_key': 'True'}), + 'referenced': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'references'", 'to': "orm['exhibit.Exhibit']"}) + }, + 'upload.urldatasource': { + 'Meta': {'object_name': 'URLDataSource', '_ormbases': ['dataset.DataSource']}, + 'datasource_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['dataset.DataSource']", 'unique': 'True', 'primary_key': 'True'}), + 'url': ('django.db.models.fields.URLField', [], {'max_length': '200'}) + } + } + + complete_apps = ['upload'] \ No newline at end of file diff --git a/viewshare/apps/upload/models.py b/viewshare/apps/upload/models.py index b6dbf516..6837b79e 100644 --- a/viewshare/apps/upload/models.py +++ b/viewshare/apps/upload/models.py @@ -6,13 +6,45 @@ from django.core.urlresolvers import reverse from django.db import models from django.utils.translation import ugettext_lazy as _ +from django_extensions.db.models import TimeStampedModel +from freemix.exhibit.models import Exhibit + +from viewshare.apps.legacy.dataset import models as ds_models -from viewshare.apps.legacy.dataset.models import (DataSource, - URLDataSourceMixin, - make_file_data_source_mixin) from viewshare.apps.legacy.dataset.transform import AkaraTransformClient from viewshare.apps.upload import conf +class DataSource(TimeStampedModel): + """ + This class should be extended to define the source from which the data in + Datasets are derived. + + Extending subclasses should include any variable parameters that define a + dataset. In addition, they should override the `refresh()` method to + simply perform the data generation and return the result. + """ + classname = models.CharField(max_length=32, editable=False, null=True) + + exhibit = models.OneToOneField(Exhibit, + related_name="source") + + def get_concrete(self): + if self.classname == "DataSource": + return self + return self.__getattribute__(self.classname.lower()) + + def is_concrete(self): + return self.classname == self.__class__.__name__ + + +class ReferenceDataSource(ds_models.DataSource): + """ + A Data Source that references another exhibit + """ + + referenced = models.ForeignKey(Exhibit, + related_name="references") + def source_upload_path(instance, filename): return join(instance.uuid, filename) @@ -28,16 +60,16 @@ def url(self, name): fs = ViewshareFileStorage(location=conf.FILE_UPLOAD_PATH) -file_datasource_mixin = make_file_data_source_mixin(storage=fs, +file_datasource_mixin = ds_models.make_file_data_source_mixin(storage=fs, upload_to=source_upload_path) -class URLDataSource(URLDataSourceMixin, DataSource): +class URLDataSource(ds_models.URLDataSourceMixin, ds_models.DataSource): """Generic URL data source """ -class FileDataSource(file_datasource_mixin, DataSource): +class FileDataSource(file_datasource_mixin, ds_models.DataSource): """Generic File data source """ @@ -47,7 +79,7 @@ class FileDataSource(file_datasource_mixin, DataSource): _limit_help_text_ = _("The maximum number of records to load") -class ContentDMDataSource(URLDataSourceMixin, DataSource): +class ContentDMDataSource(ds_models.URLDataSourceMixin, ds_models.DataSource): """ Data source for loading data from a particular CONTENTdm site based on collection name or query. @@ -88,7 +120,7 @@ def get_transform_body(self): return None -class OAIDataSource(URLDataSourceMixin, DataSource): +class OAIDataSource(ds_models.URLDataSourceMixin, ds_models.DataSource): """Data source for loading an OAI set. """ @@ -120,7 +152,7 @@ def __unicode__(self): return "%s (%s, %s)" % (self.title, self.url, self.set) -class JSONURLDataSource(URLDataSourceMixin, DataSource): +class JSONURLDataSource(ds_models.URLDataSourceMixin, ds_models.DataSource): """Load JSON from a URL """ path = models.TextField(_("Items Array")) @@ -140,7 +172,7 @@ def __unicode__(self): return "%s (%s)" % (self.url, self.path) -class JSONFileDataSource(file_datasource_mixin, DataSource): +class JSONFileDataSource(file_datasource_mixin, ds_models.DataSource): """Load JSON from a file """ path = models.TextField(_("Items Array")) @@ -186,11 +218,11 @@ def get_transform_params(self): return p -class ModsURLDataSource(ModsMixin, URLDataSourceMixin, DataSource): +class ModsURLDataSource(ModsMixin, ds_models.URLDataSourceMixin, ds_models.DataSource): """Load XMLMODS from a URL """ -class ModsFileDataSource(ModsMixin, file_datasource_mixin, DataSource): +class ModsFileDataSource(ModsMixin, file_datasource_mixin, ds_models.DataSource): """Load XMLMODS from an uploaded file """ From 2a01dfd280ee8b1cee739ab2b079244cf0499511 Mon Sep 17 00:00:00 2001 From: David Feeney Date: Tue, 16 Jul 2013 11:02:31 -0400 Subject: [PATCH 130/515] fix references to refactored and changed models --- freemix/exhibit/urls.py | 47 +++++++++++++++++++ freemix/exhibit/urls/__init__.py | 13 ----- freemix/exhibit/urls/dataset.py | 30 ------------ freemix/exhibit/urls/display.py | 18 ------- freemix/exhibit/urls/editor.py | 20 -------- freemix/exhibit/urls/embed.py | 11 ----- freemix/exhibit/urls/list.py | 11 ----- freemix/exhibit/views.py | 9 ++-- freemix/permissions.py | 2 +- viewshare/apps/augment/admin.py | 4 +- viewshare/apps/augment/forms.py | 2 +- viewshare/apps/augment/urls.py | 2 +- .../templatetags/connection_helpers.py | 2 +- .../apps/legacy/dataset/urls/__init__.py | 28 ++++++++++- viewshare/apps/profiles/views.py | 2 +- viewshare/apps/share/views.py | 1 + viewshare/urls.py | 2 - 17 files changed, 85 insertions(+), 119 deletions(-) create mode 100644 freemix/exhibit/urls.py delete mode 100644 freemix/exhibit/urls/__init__.py delete mode 100644 freemix/exhibit/urls/dataset.py delete mode 100644 freemix/exhibit/urls/display.py delete mode 100644 freemix/exhibit/urls/editor.py delete mode 100644 freemix/exhibit/urls/embed.py delete mode 100644 freemix/exhibit/urls/list.py diff --git a/freemix/exhibit/urls.py b/freemix/exhibit/urls.py new file mode 100644 index 00000000..4539263d --- /dev/null +++ b/freemix/exhibit/urls.py @@ -0,0 +1,47 @@ +from django.conf.urls import url, patterns +from django.contrib.auth.decorators import login_required +from django.views.generic import TemplateView +from freemix.exhibit import views + +urlpatterns = patterns('', + #display + + url(r"^(?P[a-zA-Z0-9_.-]+)/(?P[a-zA-Z0-9_.-]+)/profile.json$", + views.ExhibitProfileJSONView.as_view(), + name="exhibit_profile_json"), + + url(r"^(?P[a-zA-Z0-9_.-]+)/(?P[a-zA-Z0-9_.-]+)/$", + views.ExhibitDisplayView.as_view(), + name="exhibit_display"), + + url(r'^(?P[a-zA-Z0-9_.-]+)/(?P[a-zA-Z0-9_.-]+)/detail/$', + views.ExhibitDetailView.as_view(), + name='exhibit_detail'), + + # list + + url(r'^(?P[a-zA-Z0-9_.-]+)/$', + views.ExhibitListView.as_view(), + name='exhibit_list_by_owner'), + + #embed + + url(r'^(?P[a-zA-Z0-9_.-]+)/(?P[a-zA-Z0-9_.-]+)/embed.js$', + views.embedded_exhibit_view, + name='exhibit_embed_js'), + + #editor + + url(r'^(?P[a-zA-Z0-9_.-]+)/(?P[a-zA-Z0-9_.-]+)/editor/$', + login_required(views.ExhibitProfileUpdateView.as_view()), + name='exhibit_edit'), + + url(r'^(?P[a-zA-Z0-9_.-]+)/(?P[a-zA-Z0-9_.-]+)/detail/edit/$', + login_required(views.ExhibitDetailEditView.as_view()), + name="exhibit_edit_form"), + + url(r'^(?P[a-zA-Z0-9_.-]+)/(?P[a-zA-Z0-9_.-]+)/editor/create_success/$', + TemplateView.as_view(template_name="exhibit/create/success.html"), + name="exhibit_create_success"), +) + diff --git a/freemix/exhibit/urls/__init__.py b/freemix/exhibit/urls/__init__.py deleted file mode 100644 index afe02e7f..00000000 --- a/freemix/exhibit/urls/__init__.py +++ /dev/null @@ -1,13 +0,0 @@ -from django.conf.urls.defaults import * -from django.contrib.auth.decorators import login_required -from freemix.exhibit import views -urlpatterns = patterns('', - - - (r'^', include('freemix.exhibit.urls.display')), - - (r'^', include('freemix.exhibit.urls.list')), - (r'^', include('freemix.exhibit.urls.embed')), - (r'^', include('freemix.exhibit.urls.editor')), - -) diff --git a/freemix/exhibit/urls/dataset.py b/freemix/exhibit/urls/dataset.py deleted file mode 100644 index 6b597807..00000000 --- a/freemix/exhibit/urls/dataset.py +++ /dev/null @@ -1,30 +0,0 @@ -# URL patterns for linking exhibits to their dataset - -from django.conf.urls.defaults import url -from django.contrib.auth.decorators import login_required -from freemix.exhibit import views - -urlpatterns = ( - url(r'^(?P[a-zA-Z0-9_.-]+)/(?P[a-zA-Z0-9_.-]+)/views.html$', - views.ExhibitsByDatasetListView.as_view(), - name='exhibits_by_dataset' - ), - url(r'^(?P[a-zA-Z0-9_.-]+)/(?P[a-zA-Z0-9_.-]+)/view/profile.json$', - views.StockExhibitProfileJSONView.as_view(), - name='exhibit_profile_template' - ), - - url(r'^(?P[a-zA-Z0-9_.-]+)/(?P[a-zA-Z0-9_.-]+)/view/canvases.html', - views.CanvasListView.as_view(), - name='exhibit_canvas_chooser' - ), - - url(r'^(?P[a-zA-Z0-9_.-]+)/(?P[a-zA-Z0-9_.-]+)/view/create/(?P[a-zA-Z0-9_.-]+)/$', - login_required(views.ExhibitCreateFormView.as_view()), - name="exhibit_create_form"), - - url(r'^(?P[a-zA-Z0-9_.-]+)/(?P[a-zA-Z0-9_.-]+)/view/$', - login_required(views.ExhibitCreateView.as_view()), - name='exhibit_create_editor' - ), -) \ No newline at end of file diff --git a/freemix/exhibit/urls/display.py b/freemix/exhibit/urls/display.py deleted file mode 100644 index 4796e696..00000000 --- a/freemix/exhibit/urls/display.py +++ /dev/null @@ -1,18 +0,0 @@ -from django.conf.urls.defaults import url, patterns -from freemix.exhibit import views - -urlpatterns = patterns('', - url(r"^(?P[a-zA-Z0-9_.-]+)/(?P[a-zA-Z0-9_.-]+)/profile.json$", - views.ExhibitProfileJSONView.as_view(), - name="exhibit_profile_json"), - - url(r"^(?P[a-zA-Z0-9_.-]+)/(?P[a-zA-Z0-9_.-]+)/$", - views.ExhibitDisplayView.as_view(), - name="exhibit_display"), - - url(r'^(?P[a-zA-Z0-9_.-]+)/(?P[a-zA-Z0-9_.-]+)/detail/$', - views.ExhibitDetailView.as_view(), - name='exhibit_detail'), - -) - diff --git a/freemix/exhibit/urls/editor.py b/freemix/exhibit/urls/editor.py deleted file mode 100644 index 93a20493..00000000 --- a/freemix/exhibit/urls/editor.py +++ /dev/null @@ -1,20 +0,0 @@ -from django.conf.urls.defaults import url, patterns -from django.contrib.auth.decorators import login_required -from django.views.generic.base import TemplateView - -# Dataset editor -from freemix.exhibit import views - -urlpatterns = patterns('', - url(r'^(?P[a-zA-Z0-9_.-]+)/(?P[a-zA-Z0-9_.-]+)/editor/$', - login_required(views.ExhibitProfileUpdateView.as_view()), - name='exhibit_edit'), - - url(r'^(?P[a-zA-Z0-9_.-]+)/(?P[a-zA-Z0-9_.-]+)/detail/edit/$', - login_required(views.ExhibitDetailEditView.as_view()), - name="exhibit_edit_form"), - - url(r'^(?P[a-zA-Z0-9_.-]+)/(?P[a-zA-Z0-9_.-]+)/editor/create_success/$', - TemplateView.as_view(template_name="exhibit/create/success.html"), - name="exhibit_create_success"), -) diff --git a/freemix/exhibit/urls/embed.py b/freemix/exhibit/urls/embed.py deleted file mode 100644 index 2db79da8..00000000 --- a/freemix/exhibit/urls/embed.py +++ /dev/null @@ -1,11 +0,0 @@ -from django.conf.urls.defaults import url, patterns - -from freemix.exhibit import views - -urlpatterns = patterns('', - - url(r'^(?P[a-zA-Z0-9_.-]+)/(?P[a-zA-Z0-9_.-]+)/embed.js$', - views.embedded_exhibit_view, - name='exhibit_embed_js'), - -) \ No newline at end of file diff --git a/freemix/exhibit/urls/list.py b/freemix/exhibit/urls/list.py deleted file mode 100644 index 200e1fef..00000000 --- a/freemix/exhibit/urls/list.py +++ /dev/null @@ -1,11 +0,0 @@ -from django.conf.urls.defaults import url, patterns - -from freemix.exhibit import views - -urlpatterns = patterns('', - - url(r'^(?P[a-zA-Z0-9_.-]+)/$', - views.ExhibitListView.as_view(), - name='exhibit_list_by_owner'), - -) \ No newline at end of file diff --git a/freemix/exhibit/views.py b/freemix/exhibit/views.py index e6e9de22..8be7d0b6 100644 --- a/freemix/exhibit/views.py +++ b/freemix/exhibit/views.py @@ -201,7 +201,7 @@ class ExhibitView(OwnerSlugPermissionMixin, DetailView): select_related = ("owner", "dataset", "dataset__owner") def get_queryset(self): - return models.Exhibit.objects.select_related(*self.select_related) + return models.PublishedExhibit.objects.select_related(*self.select_related) object_perm = "exhibit.can_view" template_name = "exhibit/exhibit_display.html" @@ -348,8 +348,7 @@ def get(self, request, *args, **kwargs): def get_exhibit(request, owner, slug): if not hasattr(request, "exhibit"): - qs = models.Exhibit.objects.select_related("owner", "dataset") - request.exhibit = get_object_or_404(qs, slug=slug, owner__username=owner) + request.exhibit = get_object_or_404(models.PublishedExhibit, slug=slug, owner__username=owner) return request.exhibit class ExhibitProfileJSONView(BaseJSONView): @@ -359,7 +358,7 @@ def get_parent_object(self): def get_doc(self): ex = self.get_parent_object() - return models.Exhibit.objects.filter(id=ex.id).values_list("profile", flat=True)[0] + return models.PublishedExhibit.objects.filter(id=ex.id).values_list("profile", flat=True)[0] def check_perms(self): return self.request.user.has_perm("exhibit.can_view", self.get_parent_object()) @@ -367,7 +366,7 @@ def check_perms(self): def cache_control_header(self): cache_control = super(ExhibitProfileJSONView, self).cache_control_header() - if not self.request.exhibit.published: + if not self.request.exhibit.is_public: cache_control += ", private" else: cache_control += ", public" diff --git a/freemix/permissions.py b/freemix/permissions.py index 209804df..c7689fe0 100644 --- a/freemix/permissions.py +++ b/freemix/permissions.py @@ -75,7 +75,7 @@ def check_owner(user_obj, obj): return user_obj.id == obj.owner_id def check_published(user_obj, obj): - if obj.published: + if obj.is_public: return True return check_owner(user_obj, obj) diff --git a/viewshare/apps/augment/admin.py b/viewshare/apps/augment/admin.py index be3becb5..4c77d5cf 100644 --- a/viewshare/apps/augment/admin.py +++ b/viewshare/apps/augment/admin.py @@ -1,6 +1,6 @@ from django.contrib import admin -from .viewshare.apps.augment.models import ListPattern, AugmentationErrorCode -from .viewshare.apps.augment.forms import ListPatternForm +from viewshare.apps.augment.models import ListPattern, AugmentationErrorCode +from viewshare.apps.augment.forms import ListPatternForm class ListPatternAdmin(admin.ModelAdmin): form = ListPatternForm diff --git a/viewshare/apps/augment/forms.py b/viewshare/apps/augment/forms.py index cda50cc4..5335b16f 100644 --- a/viewshare/apps/augment/forms.py +++ b/viewshare/apps/augment/forms.py @@ -1,5 +1,5 @@ from django import forms -from .viewshare.apps.augment.models import ListPattern +from viewshare.apps.augment.models import ListPattern class ListPatternForm(forms.ModelForm): diff --git a/viewshare/apps/augment/urls.py b/viewshare/apps/augment/urls.py index 6e56abb8..7fea38bf 100644 --- a/viewshare/apps/augment/urls.py +++ b/viewshare/apps/augment/urls.py @@ -1,4 +1,4 @@ -from django.conf.urls.defaults import * +from django.conf.urls import * from viewshare.apps.augment import views urlpatterns = patterns('', diff --git a/viewshare/apps/connections/templatetags/connection_helpers.py b/viewshare/apps/connections/templatetags/connection_helpers.py index 122502a3..82c86767 100644 --- a/viewshare/apps/connections/templatetags/connection_helpers.py +++ b/viewshare/apps/connections/templatetags/connection_helpers.py @@ -19,7 +19,7 @@ def connection_list(context, queryset, max_count=10, pageable=True): @register.inclusion_tag("profiles/user_counts.html", takes_context=True) def user_counts(context, target_user): request = context["request"] - exhibit_count = target_user.exhibits.filter(PermissionsRegistry.get_filter("exhibit.can_view", request.user)).count() + exhibit_count = target_user.published_exhibits.filter(PermissionsRegistry.get_filter("exhibit.can_view", request.user)).count() dataset_count = target_user.datasets.filter(PermissionsRegistry.get_filter("dataset.can_view", request.user)).count() return { diff --git a/viewshare/apps/legacy/dataset/urls/__init__.py b/viewshare/apps/legacy/dataset/urls/__init__.py index da2b3c4f..06e4e8e2 100644 --- a/viewshare/apps/legacy/dataset/urls/__init__.py +++ b/viewshare/apps/legacy/dataset/urls/__init__.py @@ -1,5 +1,8 @@ from django.conf import settings -from django.conf.urls.defaults import patterns, include +from django.conf.urls import * +from freemix.exhibit import views +from django.contrib.auth.decorators import login_required +from django.views.generic import TemplateView urlpatterns = patterns('', @@ -13,5 +16,26 @@ if "freemix.exhibit" in settings.INSTALLED_APPS: urlpatterns += patterns('', - (r'^', include('freemix.exhibit.urls.dataset')), + url(r'^(?P[a-zA-Z0-9_.-]+)/(?P[a-zA-Z0-9_.-]+)/views.html$', + views.ExhibitsByDatasetListView.as_view(), + name='exhibits_by_dataset' + ), + url(r'^(?P[a-zA-Z0-9_.-]+)/(?P[a-zA-Z0-9_.-]+)/view/profile.json$', + views.StockExhibitProfileJSONView.as_view(), + name='exhibit_profile_template' + ), + + url(r'^(?P[a-zA-Z0-9_.-]+)/(?P[a-zA-Z0-9_.-]+)/view/canvases.html', + views.CanvasListView.as_view(), + name='exhibit_canvas_chooser' + ), + + url(r'^(?P[a-zA-Z0-9_.-]+)/(?P[a-zA-Z0-9_.-]+)/view/create/(?P[a-zA-Z0-9_.-]+)/$', + login_required(views.ExhibitCreateFormView.as_view()), + name="exhibit_create_form"), + + url(r'^(?P[a-zA-Z0-9_.-]+)/(?P[a-zA-Z0-9_.-]+)/view/$', + login_required(views.ExhibitCreateView.as_view()), + name='exhibit_create_editor' + ), ) diff --git a/viewshare/apps/profiles/views.py b/viewshare/apps/profiles/views.py index 31484a72..0d895a04 100644 --- a/viewshare/apps/profiles/views.py +++ b/viewshare/apps/profiles/views.py @@ -155,7 +155,7 @@ def profile(request, username, template_name="profiles/profile.html", exhibit_filter = PermissionsRegistry.get_filter("exhibit.can_view", request.user) - exhibits = other_user.exhibits.filter(exhibit_filter) + exhibits = other_user.published_exhibits.filter(exhibit_filter) exhibits = exhibits.select_related("owner", "dataset__owner", "dataset") return render_to_response(template_name, dict({ diff --git a/viewshare/apps/share/views.py b/viewshare/apps/share/views.py index c8bdfd6e..e13f75bb 100644 --- a/viewshare/apps/share/views.py +++ b/viewshare/apps/share/views.py @@ -8,6 +8,7 @@ from viewshare.apps.share import models from freemix.exhibit.models import Exhibit +from viewshare.apps.legacy.dataset import models as dataset_models from freemix.views import BaseJSONView from viewshare.apps.share import forms diff --git a/viewshare/urls.py b/viewshare/urls.py index 9cd0da1b..59970009 100644 --- a/viewshare/urls.py +++ b/viewshare/urls.py @@ -44,8 +44,6 @@ name='exhibit_list_by_user_connections'), (r'^upload/', include('viewshare.apps.upload.urls')), - (r'^data/', include('viewshare.apps.legacy.dataset.urls')), - # (r'^source/', include('viewshare.apps.legacy.dataset.urls.datasource')), (r'^views/', include('freemix.exhibit.urls')), (r'^augment/', include('viewshare.apps.augment.urls')), From 590ba9ae6a0c207d09ac4fb2b00063e9c4278848 Mon Sep 17 00:00:00 2001 From: David Feeney Date: Wed, 24 Jul 2013 15:21:40 -0400 Subject: [PATCH 131/515] remove duplicate re-numbered migration from merge --- ...igrate_data_profile_properties_and_data.py | 230 ------------------ 1 file changed, 230 deletions(-) delete mode 100644 freemix/exhibit/migrations/0012_migrate_data_profile_properties_and_data.py diff --git a/freemix/exhibit/migrations/0012_migrate_data_profile_properties_and_data.py b/freemix/exhibit/migrations/0012_migrate_data_profile_properties_and_data.py deleted file mode 100644 index d5f722ef..00000000 --- a/freemix/exhibit/migrations/0012_migrate_data_profile_properties_and_data.py +++ /dev/null @@ -1,230 +0,0 @@ -# -*- coding: utf-8 -*- -import datetime -import json -from south.db import db -from south.v2 import DataMigration -from django.db import models - -def find_type(p): - for t in ["location", "text", "image", "date", "url", "number"]: - if "property:type=%s"%t in p["tags"]: - return t - - return "text" - -class Migration(DataMigration): - - def forwards(self, orm): - - # Migrate Dataset's json files into the new exhibit data model - - for exhibit in orm.Exhibit.objects.all(): - dataset = exhibit.dataset - data = orm["dataset.datasetjsonfile"].objects.get(dataset=dataset).data - profile = orm["dataset.datasetprofile"].objects.get(dataset=dataset).data - orm.DataJSONFile(exhibit=exhibit, json=data).save() - - profile = json.loads(profile) - properties = {} - second_pass = [] - for p in profile["properties"]: - # Do a first run through the properties to - # ensure that all properties exist before - # creating references - k = p.keys() - value_type = find_type(p) - name = p["property"] - label = p["label"] - - if "composite" in k: - classname = "CompositeProperty" - second_pass.append(p) - elif "delimiter" in k: - classname = "DelimitedListProperty" - second_pass.append(p) - elif "pattern" in k: - classname = "PatternListProperty" - second_pass.append(p) - else: - classname="ExhibitProperty" - - prop = orm.ExhibitProperty(exhibit=exhibit, - name=name, - label=label, - value_type=value_type, - classname=classname) - prop.save() - properties[name] = prop - - for p in second_pass: - # Now create the extension objects for augmented properties - - prop = properties[p["property"]] - - if "composite" in k: - ext = orm.CompositeProperty(exhibitproperty_ptr=prop) - ext.__dict__ = prop.__dict__ - ext.save() - counter = 1 - for c in p["composite"]: - ref = orm.PropertyReference(derived=ext, - source=properties[c], - order=counter) - counter += 1 - ref.save() - - elif "delimiter" in k: - ext = orm.DelimitedListProperty(exhibitproperty_ptr=prop, - source=properties[p["extract"]], - delimiter=p["delimiter"]) - ext.__dict__ = prop.__dict__ - ext.save() - elif "pattern" in k: - ext = orm.PatternListProperty(exhibitproperty_ptr=prop, - source=properties[p["extract"]], - pattern=p["pattern"]) - ext.__dict__ = prop.__dict__ - ext.save() - exhibit.save() - - - def backwards(self, orm): - "Write your backwards methods here." - - 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']", 'symmetrical': 'False', 'blank': 'True'}) - }, - 'auth.permission': { - 'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", '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']", 'symmetrical': 'False', 'blank': 'True'}), - 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), - 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), - 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), - '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']", 'symmetrical': 'False', 'blank': 'True'}), - 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'}) - }, - 'contenttypes.contenttype': { - 'Meta': {'ordering': "('name',)", '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'}) - }, - 'dataset.dataset': { - 'Meta': {'ordering': "('-modified',)", 'unique_together': "(('slug', 'owner'),)", 'object_name': 'Dataset'}, - 'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), - 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), - 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'modified': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), - 'owner': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'datasets'", 'null': 'True', 'to': "orm['auth.User']"}), - 'published': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), - 'slug': ('django_extensions.db.fields.AutoSlugField', [], {'allow_duplicates': 'False', 'max_length': '50', 'separator': "u'-'", 'blank': 'True', 'populate_from': "'title'", 'overwrite': 'False'}), - 'title': ('django.db.models.fields.CharField', [], {'max_length': '255'}) - }, - 'dataset.datasetjsonfile': { - 'Meta': {'object_name': 'DatasetJSONFile'}, - 'data': ('django.db.models.fields.TextField', [], {'default': "'{}'"}), - 'dataset': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'data'", 'unique': 'True', 'to': "orm['dataset.Dataset']"}), - 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}) - }, - 'dataset.datasetprofile': { - 'Meta': {'object_name': 'DatasetProfile'}, - 'data': ('django.db.models.fields.TextField', [], {'default': "'{}'"}), - 'dataset': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'profile'", 'unique': 'True', 'to': "orm['dataset.Dataset']"}), - 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}) - }, - 'exhibit.canvas': { - 'Meta': {'object_name': 'Canvas'}, - 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), - 'enabled': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), - 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'location': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '100'}), - 'slug': ('django_extensions.db.fields.AutoSlugField', [], {'allow_duplicates': 'False', 'max_length': '50', 'separator': "u'-'", 'blank': 'True', 'populate_from': "'title'", 'overwrite': 'False'}), - 'thumbnail': ('django.db.models.fields.URLField', [], {'max_length': '200'}), - 'title': ('django.db.models.fields.CharField', [], {'max_length': '255'}) - }, - 'exhibit.compositeproperty': { - 'Meta': {'object_name': 'CompositeProperty', '_ormbases': ['exhibit.ExhibitProperty']}, - 'exhibitproperty_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['exhibit.ExhibitProperty']", 'unique': 'True', 'primary_key': 'True'}) - }, - 'exhibit.datajsonfile': { - 'Meta': {'object_name': 'DataJSONFile'}, - 'exhibit': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'data'", 'unique': 'True', 'to': "orm['exhibit.Exhibit']"}), - 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'json': ('django.db.models.fields.TextField', [], {'default': "'{}'"}) - }, - 'exhibit.delimitedlistproperty': { - 'Meta': {'object_name': 'DelimitedListProperty'}, - 'delimiter': ('django.db.models.fields.TextField', [], {}), - 'exhibitproperty_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['exhibit.ExhibitProperty']", 'unique': 'True', 'primary_key': 'True'}), - 'source': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'+'", 'to': "orm['exhibit.ExhibitProperty']"}) - }, - 'exhibit.draftexhibit': { - 'Meta': {'ordering': "('-modified',)", 'object_name': 'DraftExhibit', '_ormbases': ['exhibit.Exhibit']}, - 'exhibit_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['exhibit.Exhibit']", 'unique': 'True', 'primary_key': 'True'}), - 'owner': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'draft_exhibits'", 'null': 'True', 'to': "orm['auth.User']"}), - 'parent': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['exhibit.PublishedExhibit']", 'null': 'True', 'blank': 'True'}), - 'uuid': ('django.db.models.fields.CharField', [], {'max_length': '36', 'blank': 'True'}) - }, - 'exhibit.exhibit': { - 'Meta': {'ordering': "('-modified', '-created')", 'object_name': 'Exhibit'}, - 'canvas': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['exhibit.Canvas']"}), - 'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), - 'dataset': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'exhibits'", 'null': 'True', 'to': "orm['dataset.Dataset']"}), - 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'modified': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), - 'profile': ('django.db.models.fields.TextField', [], {'default': "'{}'"}) - }, - 'exhibit.exhibitproperty': { - 'Meta': {'unique_together': "(('exhibit', 'name'),)", 'object_name': 'ExhibitProperty'}, - 'classname': ('django.db.models.fields.CharField', [], {'max_length': '32', 'null': 'True'}), - 'exhibit': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'properties'", 'to': "orm['exhibit.Exhibit']"}), - 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'label': ('django.db.models.fields.CharField', [], {'max_length': '255'}), - 'name': ('django.db.models.fields.CharField', [], {'max_length': '255'}), - 'value_type': ('django.db.models.fields.CharField', [], {'default': "'text'", 'max_length': '10'}) - }, - 'exhibit.patternlistproperty': { - 'Meta': {'object_name': 'PatternListProperty'}, - 'exhibitproperty_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['exhibit.ExhibitProperty']", 'unique': 'True', 'primary_key': 'True'}), - 'pattern': ('django.db.models.fields.TextField', [], {}), - 'source': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'+'", 'to': "orm['exhibit.ExhibitProperty']"}) - }, - 'exhibit.propertyreference': { - 'Meta': {'ordering': "('order',)", 'unique_together': "(('derived', 'source'),)", 'object_name': 'PropertyReference'}, - 'derived': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'properties'", 'to': "orm['exhibit.CompositeProperty']"}), - 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'order': ('django.db.models.fields.PositiveSmallIntegerField', [], {}), - 'source': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['exhibit.ExhibitProperty']"}) - }, - 'exhibit.publishedexhibit': { - 'Meta': {'ordering': "('-modified',)", 'unique_together': "(('slug', 'owner'),)", 'object_name': 'PublishedExhibit', '_ormbases': ['exhibit.Exhibit']}, - 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), - 'exhibit_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['exhibit.Exhibit']", 'unique': 'True', 'primary_key': 'True'}), - 'is_public': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), - 'owner': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'published_exhibits'", 'null': 'True', 'to': "orm['auth.User']"}), - 'slug': ('django_extensions.db.fields.AutoSlugField', [], {'allow_duplicates': 'False', 'max_length': '50', 'separator': "u'-'", 'blank': 'True', 'populate_from': "'title'", 'overwrite': 'False'}), - 'title': ('django.db.models.fields.CharField', [], {'max_length': '255'}) - } - } - - complete_apps = ['exhibit'] - symmetrical = True From 677d5b7023708c49da10406c363161f068b57323 Mon Sep 17 00:00:00 2001 From: David Feeney Date: Mon, 29 Jul 2013 12:15:33 -0400 Subject: [PATCH 132/515] start removing dataset url references --- viewshare/urls.py | 9 ------- viewshare/utilities/feeds.py | 50 ------------------------------------ 2 files changed, 59 deletions(-) diff --git a/viewshare/urls.py b/viewshare/urls.py index 59970009..36a71d40 100644 --- a/viewshare/urls.py +++ b/viewshare/urls.py @@ -34,11 +34,6 @@ 'viewshare.apps.connections.views.connection_list_by_user', name='connection_list_by_user') , - # Lists of connections datasets and views - url(r'data/(?P[a-zA-Z0-9_.-]+)/connections/$', - 'viewshare.apps.connections.views.datasets_by_user_connections', - name='datasets_by_user_connections'), - url(r'views/(?P[a-zA-Z0-9_.-]+)/connections/$', 'viewshare.apps.connections.views.exhibit_list_by_user_connections', name='exhibit_list_by_user_connections'), @@ -55,10 +50,6 @@ (r'^feeds/latest_views_atom/$', feeds.AtomLatestDataViews()), (r'^feeds/views/(?P[a-zA-Z0-9_.-]+)/$', feeds.UserDataViews()), (r'^feeds/views_atom/(?P[a-zA-Z0-9_.-]+)/$', feeds.AtomUserDataViews()), - (r'^feeds/latest_data/$', feeds.LatestDatasets()), - (r'^feeds/latest_data_atom/$', feeds.AtomLatestDatasets()), - (r'^feeds/data/(?P[a-zA-Z0-9_.-]+)/$', feeds.UserDatasets()), - (r'^feeds/data_atom/(?P[a-zA-Z0-9_.-]+)/$', feeds.AtomUserDatasets()), # home page url(r'^$', 'viewshare.apps.discover.views.front_page', name="front_page"), diff --git a/viewshare/utilities/feeds.py b/viewshare/utilities/feeds.py index 91fc7c5e..0c117b22 100644 --- a/viewshare/utilities/feeds.py +++ b/viewshare/utilities/feeds.py @@ -5,7 +5,6 @@ from freemix.permissions import PermissionsRegistry from freemix.utils import get_user -from viewshare.apps.legacy.dataset.models import Dataset from freemix.exhibit.models import Exhibit from freemix.utils import get_site_url @@ -71,52 +70,3 @@ def items(self, obj): class AtomUserDataViews(UserDataViews): feed_type = Atom1Feed subtitle = UserDataViews.description - - - - -class LatestDatasets(ItemMixin, Feed): - title = "Datasets" - description = "Latest Datasets" - - link = get_site_url() - - def items(self): - u = AnonymousUser() - filter = PermissionsRegistry.get_filter('dataset.can_view', u) - - return Dataset.objects.filter(filter).order_by('-created')[:10] - - -class AtomLatestDatasets(LatestDatasets): - feed_type = Atom1Feed - subtitle = LatestDatasets.description - - -class UserDatasets(ItemMixin, Feed): - - # Parse the username from the URL - def get_object(self, request, owner): - return get_user(username=owner) - - def title(self, obj): - return "Latest Datasets created by %s" % obj.username - - def description(self, obj): - return "Latest Datasets for %(user)s" % { 'user': obj.username } - - # Link to user's profile - def link(self, obj): - return get_site_url(reverse("profile_detail", kwargs={'username': - obj.username})) - - # Return only this user's data. - def items(self, obj): - filter = PermissionsRegistry.get_filter('dataset.can_view', AnonymousUser()) - return Dataset.objects.filter(owner=obj).filter(filter).order_by('-created')[:10] - - -class AtomUserDatasets(UserDatasets): - feed_type = Atom1Feed - subtitle = UserDatasets.description - From 1ffa7b69b7a3323dffe50ee3ed45ab743c6e6ba6 Mon Sep 17 00:00:00 2001 From: David Feeney Date: Tue, 30 Jul 2013 11:41:10 -0400 Subject: [PATCH 133/515] migrate data sources to upload, create reference datasources, remove reference to dataset in exhibit --- .../migrations/0015_drop_dataset_reference.py | 137 +++++++++ freemix/exhibit/models.py | 17 -- viewshare/apps/augment/conf.py | 2 +- viewshare/apps/augment/views.py | 2 +- viewshare/apps/legacy/dataset/admin.py | 46 +-- .../0013_datasource_exhibit_reference.py | 131 +++++++++ .../migrations/0014_ds_reference_exhibit.py | 148 ++++++++++ viewshare/apps/legacy/dataset/models.py | 11 +- viewshare/apps/support/views.py | 2 +- viewshare/apps/upload/admin.py | 18 +- viewshare/apps/upload/conf.py | 2 +- .../0006_create_reference_datasources.py | 184 ++++++++++++ .../apps/upload/migrations/0007_new_ds_ptr.py | 240 ++++++++++++++++ .../migrations/0008_migrate_datasources.py | 220 ++++++++++++++ .../0009_drop_dataset_datasource_refs.py | 272 ++++++++++++++++++ .../0010_rename_new_ds_ptr__datasource_ptr.py | 173 +++++++++++ viewshare/apps/upload/models.py | 95 +++++- .../{legacy/dataset => upload}/transform.py | 0 viewshare/apps/upload/views.py | 2 +- viewshare/utilities/views.py | 2 +- 20 files changed, 1634 insertions(+), 70 deletions(-) create mode 100644 freemix/exhibit/migrations/0015_drop_dataset_reference.py create mode 100644 viewshare/apps/legacy/dataset/migrations/0013_datasource_exhibit_reference.py create mode 100644 viewshare/apps/legacy/dataset/migrations/0014_ds_reference_exhibit.py create mode 100644 viewshare/apps/upload/migrations/0006_create_reference_datasources.py create mode 100644 viewshare/apps/upload/migrations/0007_new_ds_ptr.py create mode 100644 viewshare/apps/upload/migrations/0008_migrate_datasources.py create mode 100644 viewshare/apps/upload/migrations/0009_drop_dataset_datasource_refs.py create mode 100644 viewshare/apps/upload/migrations/0010_rename_new_ds_ptr__datasource_ptr.py rename viewshare/apps/{legacy/dataset => upload}/transform.py (100%) diff --git a/freemix/exhibit/migrations/0015_drop_dataset_reference.py b/freemix/exhibit/migrations/0015_drop_dataset_reference.py new file mode 100644 index 00000000..f11b179a --- /dev/null +++ b/freemix/exhibit/migrations/0015_drop_dataset_reference.py @@ -0,0 +1,137 @@ +# -*- coding: utf-8 -*- +import datetime +from south.db import db +from south.v2 import SchemaMigration +from django.db import models + + +class Migration(SchemaMigration): + + depends_on = ( + ('upload', '0010_rename_new_ds_ptr__datasource_ptr'), + ) + + def forwards(self, orm): + # Deleting field 'Exhibit.dataset' + db.delete_column(u'exhibit_exhibit', 'dataset_id') + + + def backwards(self, orm): + # Adding field 'Exhibit.dataset' + db.add_column(u'exhibit_exhibit', 'dataset', + self.gf('django.db.models.fields.related.ForeignKey')(related_name='exhibits', null=True, to=orm['dataset.Dataset'], blank=True), + keep_default=False) + + + models = { + u'auth.group': { + 'Meta': {'object_name': 'Group'}, + u'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': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}) + }, + u'auth.permission': { + 'Meta': {'ordering': "(u'content_type__app_label', u'content_type__model', u'codename')", 'unique_together': "((u'content_type', u'codename'),)", 'object_name': 'Permission'}, + 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['contenttypes.ContentType']"}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}) + }, + u'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': u"orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + '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': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}), + 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'}) + }, + u'contenttypes.contenttype': { + 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"}, + 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + u'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'}) + }, + u'exhibit.canvas': { + 'Meta': {'object_name': 'Canvas'}, + 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'enabled': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'location': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '100'}), + 'slug': ('django_extensions.db.fields.AutoSlugField', [], {'allow_duplicates': 'False', 'max_length': '50', 'separator': "u'-'", 'blank': 'True', 'populate_from': "'title'", 'overwrite': 'False'}), + 'thumbnail': ('django.db.models.fields.URLField', [], {'max_length': '200'}), + 'title': ('django.db.models.fields.CharField', [], {'max_length': '255'}) + }, + u'exhibit.compositeproperty': { + 'Meta': {'object_name': 'CompositeProperty', '_ormbases': [u'exhibit.ExhibitProperty']}, + u'exhibitproperty_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['exhibit.ExhibitProperty']", 'unique': 'True', 'primary_key': 'True'}) + }, + u'exhibit.datajsonfile': { + 'Meta': {'object_name': 'DataJSONFile'}, + 'exhibit': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'data'", 'unique': 'True', 'to': u"orm['exhibit.Exhibit']"}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'json': ('django.db.models.fields.TextField', [], {'default': "'{}'"}) + }, + u'exhibit.delimitedlistproperty': { + 'Meta': {'object_name': 'DelimitedListProperty'}, + 'delimiter': ('django.db.models.fields.TextField', [], {}), + u'exhibitproperty_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['exhibit.ExhibitProperty']", 'unique': 'True', 'primary_key': 'True'}), + 'source': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'+'", 'to': u"orm['exhibit.ExhibitProperty']"}) + }, + u'exhibit.draftexhibit': { + 'Meta': {'ordering': "('-modified',)", 'object_name': 'DraftExhibit', '_ormbases': [u'exhibit.Exhibit']}, + u'exhibit_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['exhibit.Exhibit']", 'unique': 'True', 'primary_key': 'True'}), + 'owner': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'draft_exhibits'", 'null': 'True', 'to': u"orm['auth.User']"}), + 'parent': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['exhibit.PublishedExhibit']", 'null': 'True', 'blank': 'True'}), + 'uuid': ('django.db.models.fields.CharField', [], {'max_length': '36', 'blank': 'True'}) + }, + u'exhibit.exhibit': { + 'Meta': {'ordering': "('-modified', '-created')", 'object_name': 'Exhibit'}, + 'canvas': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['exhibit.Canvas']"}), + 'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'modified': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + 'profile': ('django.db.models.fields.TextField', [], {'default': "'{}'"}) + }, + u'exhibit.exhibitproperty': { + 'Meta': {'unique_together': "(('exhibit', 'name'),)", 'object_name': 'ExhibitProperty'}, + 'classname': ('django.db.models.fields.CharField', [], {'max_length': '32', 'null': 'True'}), + 'exhibit': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'properties'", 'to': u"orm['exhibit.Exhibit']"}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'label': ('django.db.models.fields.CharField', [], {'max_length': '255'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '255'}), + 'value_type': ('django.db.models.fields.CharField', [], {'default': "'text'", 'max_length': '10'}) + }, + u'exhibit.patternlistproperty': { + 'Meta': {'object_name': 'PatternListProperty'}, + u'exhibitproperty_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['exhibit.ExhibitProperty']", 'unique': 'True', 'primary_key': 'True'}), + 'pattern': ('django.db.models.fields.TextField', [], {}), + 'source': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'+'", 'to': u"orm['exhibit.ExhibitProperty']"}) + }, + u'exhibit.propertyreference': { + 'Meta': {'ordering': "('order',)", 'unique_together': "(('derived', 'source'),)", 'object_name': 'PropertyReference'}, + 'derived': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'properties'", 'to': u"orm['exhibit.CompositeProperty']"}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'order': ('django.db.models.fields.PositiveSmallIntegerField', [], {}), + 'source': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['exhibit.ExhibitProperty']"}) + }, + u'exhibit.publishedexhibit': { + 'Meta': {'ordering': "('-modified',)", 'unique_together': "(('slug', 'owner'),)", 'object_name': 'PublishedExhibit', '_ormbases': [u'exhibit.Exhibit']}, + 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + u'exhibit_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['exhibit.Exhibit']", 'unique': 'True', 'primary_key': 'True'}), + 'is_public': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'owner': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'published_exhibits'", 'null': 'True', 'to': u"orm['auth.User']"}), + 'slug': ('django_extensions.db.fields.AutoSlugField', [], {'allow_duplicates': 'False', 'max_length': '50', 'separator': "u'-'", 'blank': 'True', 'populate_from': "'title'", 'overwrite': 'False'}), + 'title': ('django.db.models.fields.CharField', [], {'max_length': '255'}) + } + } + + complete_apps = ['exhibit'] \ No newline at end of file diff --git a/freemix/exhibit/models.py b/freemix/exhibit/models.py index 6597cd2b..83567158 100644 --- a/freemix/exhibit/models.py +++ b/freemix/exhibit/models.py @@ -6,8 +6,6 @@ from django_extensions.db.fields.json import JSONField from django_extensions.db.models import (TitleSlugDescriptionModel, TimeStampedModel) -from viewshare.apps.legacy.dataset.models import Dataset - class Canvas(TitleSlugDescriptionModel): @@ -38,23 +36,8 @@ class Exhibit(TimeStampedModel): profile = JSONField() - dataset = models.ForeignKey(Dataset, - null=True, - blank=True, - related_name="exhibits") - canvas = models.ForeignKey(Canvas) - def dataset_available(self, user): - """ - True if the provided user is able to view the dataset associated - with this exhibit - """ - ds = self.dataset - if not ds or not user.has_perm("dataset.can_view", ds): - return False - return True - def update_from_profile(self, profile): self.profile = profile self.save() diff --git a/viewshare/apps/augment/conf.py b/viewshare/apps/augment/conf.py index aec6b4b6..0d7cb593 100644 --- a/viewshare/apps/augment/conf.py +++ b/viewshare/apps/augment/conf.py @@ -2,7 +2,7 @@ from django.conf import settings -from viewshare.apps.legacy.dataset.transform import AKARA_URL_PREFIX +from viewshare.apps.upload.transform import AKARA_URL_PREFIX AKARA_AUGMENT_URL = getattr(settings, "AKARA_AUGMENT_URL", urljoin(AKARA_URL_PREFIX, "augment.freemix.json")) diff --git a/viewshare/apps/augment/views.py b/viewshare/apps/augment/views.py index 191991b4..57679902 100644 --- a/viewshare/apps/augment/views.py +++ b/viewshare/apps/augment/views.py @@ -2,7 +2,7 @@ from viewshare.apps.augment import models -from viewshare.apps.legacy.dataset.transform import RawTransformView, AkaraTransformClient +from viewshare.apps.upload.transform import RawTransformView, AkaraTransformClient from freemix.views import JSONResponse from viewshare.apps.augment import conf diff --git a/viewshare/apps/legacy/dataset/admin.py b/viewshare/apps/legacy/dataset/admin.py index 3d54b0f9..d8941edd 100644 --- a/viewshare/apps/legacy/dataset/admin.py +++ b/viewshare/apps/legacy/dataset/admin.py @@ -1,23 +1,23 @@ -from django.contrib import admin -from viewshare.apps.legacy.dataset import models - - -def make_json_data_inline(m): - class JSONDataFileInline(admin.TabularInline): - model=m - return JSONDataFileInline - -class DatasetAdmin(admin.ModelAdmin): - inlines = (make_json_data_inline(models.DatasetProfile), - make_json_data_inline(models.DatasetJSONFile), - make_json_data_inline(models.DatasetPropertiesCache) - ) - list_display = ('slug','owner',) - search_fields = ('slug','title', 'description','owner__username') -admin.site.register(models.Dataset, DatasetAdmin) - -class TransactionInline(admin.TabularInline): - model = models.DataSourceTransaction - -class DataSourceAdmin(admin.ModelAdmin): - inlines=[TransactionInline] \ No newline at end of file +#from django.contrib import admin +#from viewshare.apps.legacy.dataset import models +# +# +#def make_json_data_inline(m): +# class JSONDataFileInline(admin.TabularInline): +# model=m +# return JSONDataFileInline +# +#class DatasetAdmin(admin.ModelAdmin): +# inlines = (make_json_data_inline(models.DatasetProfile), +# make_json_data_inline(models.DatasetJSONFile), +# make_json_data_inline(models.DatasetPropertiesCache) +# ) +# list_display = ('slug','owner',) +# search_fields = ('slug','title', 'description','owner__username') +#admin.site.register(models.Dataset, DatasetAdmin) +# +#class TransactionInline(admin.TabularInline): +# model = models.DataSourceTransaction +# +#class DataSourceAdmin(admin.ModelAdmin): +# inlines=[TransactionInline] \ No newline at end of file diff --git a/viewshare/apps/legacy/dataset/migrations/0013_datasource_exhibit_reference.py b/viewshare/apps/legacy/dataset/migrations/0013_datasource_exhibit_reference.py new file mode 100644 index 00000000..e46be590 --- /dev/null +++ b/viewshare/apps/legacy/dataset/migrations/0013_datasource_exhibit_reference.py @@ -0,0 +1,131 @@ +# -*- coding: 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 field 'DataSource.exhibit' + db.add_column(u'dataset_datasource', 'exhibit', + self.gf('django.db.models.fields.related.OneToOneField')(blank=True, related_name='ds_source', unique=True, null=True, to=orm['exhibit.Exhibit']), + keep_default=False) + + + def backwards(self, orm): + # Deleting field 'DataSource.exhibit' + db.delete_column(u'dataset_datasource', 'exhibit_id') + + + models = { + u'auth.group': { + 'Meta': {'object_name': 'Group'}, + u'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': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}) + }, + u'auth.permission': { + 'Meta': {'ordering': "(u'content_type__app_label', u'content_type__model', u'codename')", 'unique_together': "((u'content_type', u'codename'),)", 'object_name': 'Permission'}, + 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['contenttypes.ContentType']"}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}) + }, + u'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': u"orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + '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': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}), + 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'}) + }, + u'contenttypes.contenttype': { + 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"}, + 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + u'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'}) + }, + u'dataset.dataset': { + 'Meta': {'ordering': "('-modified',)", 'unique_together': "(('slug', 'owner'),)", 'object_name': 'Dataset'}, + 'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'modified': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + 'owner': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'datasets'", 'null': 'True', 'to': u"orm['auth.User']"}), + 'published': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'slug': ('django_extensions.db.fields.AutoSlugField', [], {'allow_duplicates': 'False', 'max_length': '50', 'separator': "u'-'", 'blank': 'True', 'populate_from': "'title'", 'overwrite': 'False'}), + 'title': ('django.db.models.fields.CharField', [], {'max_length': '255'}) + }, + u'dataset.datasetjsonfile': { + 'Meta': {'object_name': 'DatasetJSONFile'}, + 'data': ('django.db.models.fields.TextField', [], {'default': "'{}'"}), + 'dataset': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'data'", 'unique': 'True', 'to': u"orm['dataset.Dataset']"}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}) + }, + u'dataset.datasetprofile': { + 'Meta': {'object_name': 'DatasetProfile'}, + 'data': ('django.db.models.fields.TextField', [], {'default': "'{}'"}), + 'dataset': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'profile'", 'unique': 'True', 'to': u"orm['dataset.Dataset']"}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}) + }, + u'dataset.datasetpropertiescache': { + 'Meta': {'object_name': 'DatasetPropertiesCache'}, + 'data': ('django.db.models.fields.TextField', [], {'default': "'{}'"}), + 'dataset': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'properties_cache'", 'unique': 'True', 'to': u"orm['dataset.Dataset']"}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}) + }, + u'dataset.datasource': { + 'Meta': {'ordering': "('-modified', '-created')", 'object_name': 'DataSource'}, + 'classname': ('django.db.models.fields.CharField', [], {'max_length': '32', 'null': 'True'}), + 'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + 'dataset': ('django.db.models.fields.related.OneToOneField', [], {'blank': 'True', 'related_name': "'source'", 'unique': 'True', 'null': 'True', 'to': u"orm['dataset.Dataset']"}), + 'exhibit': ('django.db.models.fields.related.OneToOneField', [], {'blank': 'True', 'related_name': "'ds_source'", 'unique': 'True', 'null': 'True', 'to': u"orm['exhibit.Exhibit']"}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'modified': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + 'owner': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'data_sources'", 'null': 'True', 'to': u"orm['auth.User']"}), + 'uuid': ('django.db.models.fields.CharField', [], {'max_length': '36', 'blank': 'True'}) + }, + u'dataset.datasourcetransaction': { + 'Meta': {'ordering': "('-modified', '-created')", 'object_name': 'DataSourceTransaction'}, + 'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'is_complete': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'modified': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + 'result': ('django.db.models.fields.TextField', [], {'default': "'{}'", 'null': 'True', 'blank': 'True'}), + 'source': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'transactions'", 'to': u"orm['dataset.DataSource']"}), + 'status': ('django.db.models.fields.IntegerField', [], {'default': '1'}), + 'tx_id': ('django.db.models.fields.CharField', [], {'max_length': '36', 'blank': 'True'}) + }, + u'exhibit.canvas': { + 'Meta': {'object_name': 'Canvas'}, + 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'enabled': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'location': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '100'}), + 'slug': ('django_extensions.db.fields.AutoSlugField', [], {'allow_duplicates': 'False', 'max_length': '50', 'separator': "u'-'", 'blank': 'True', 'populate_from': "'title'", 'overwrite': 'False'}), + 'thumbnail': ('django.db.models.fields.URLField', [], {'max_length': '200'}), + 'title': ('django.db.models.fields.CharField', [], {'max_length': '255'}) + }, + u'exhibit.exhibit': { + 'Meta': {'ordering': "('-modified', '-created')", 'object_name': 'Exhibit'}, + 'canvas': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['exhibit.Canvas']"}), + 'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + 'dataset': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'exhibits'", 'null': 'True', 'to': u"orm['dataset.Dataset']"}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'modified': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + 'profile': ('django.db.models.fields.TextField', [], {'default': "'{}'"}) + } + } + + complete_apps = ['dataset'] \ No newline at end of file diff --git a/viewshare/apps/legacy/dataset/migrations/0014_ds_reference_exhibit.py b/viewshare/apps/legacy/dataset/migrations/0014_ds_reference_exhibit.py new file mode 100644 index 00000000..60b07559 --- /dev/null +++ b/viewshare/apps/legacy/dataset/migrations/0014_ds_reference_exhibit.py @@ -0,0 +1,148 @@ +# -*- coding: utf-8 -*- +import datetime +from south.db import db +from south.v2 import DataMigration +from django.db import models + +class Migration(DataMigration): + + depends_on = ( + ("exhibit", "0014_populate_profile"), + ) + + def forwards(self, orm): + """ + Ensure existing data sources point to an exhibit owned by the + correct owner. This is dependent on exhibit migration 0014, after + which all datasets have exhibits. + """ + for source in orm['dataset.DataSource'].objects.filter(dataset__isnull=False): + ds = source.dataset + exhibit = ds.exhibits.filter(publishedexhibit__owner=ds.owner)[0] + source.exhibit = exhibit + source.save() + + + def backwards(self, orm): + "Write your backwards methods here." + + models = { + u'auth.group': { + 'Meta': {'object_name': 'Group'}, + u'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': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}) + }, + u'auth.permission': { + 'Meta': {'ordering': "(u'content_type__app_label', u'content_type__model', u'codename')", 'unique_together': "((u'content_type', u'codename'),)", 'object_name': 'Permission'}, + 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['contenttypes.ContentType']"}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}) + }, + u'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': u"orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + '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': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}), + 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'}) + }, + u'contenttypes.contenttype': { + 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"}, + 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + u'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'}) + }, + u'dataset.dataset': { + 'Meta': {'ordering': "('-modified',)", 'unique_together': "(('slug', 'owner'),)", 'object_name': 'Dataset'}, + 'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'modified': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + 'owner': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'datasets'", 'null': 'True', 'to': u"orm['auth.User']"}), + 'published': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'slug': ('django_extensions.db.fields.AutoSlugField', [], {'allow_duplicates': 'False', 'max_length': '50', 'separator': "u'-'", 'blank': 'True', 'populate_from': "'title'", 'overwrite': 'False'}), + 'title': ('django.db.models.fields.CharField', [], {'max_length': '255'}) + }, + u'dataset.datasetjsonfile': { + 'Meta': {'object_name': 'DatasetJSONFile'}, + 'data': ('django.db.models.fields.TextField', [], {'default': "'{}'"}), + 'dataset': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'data'", 'unique': 'True', 'to': u"orm['dataset.Dataset']"}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}) + }, + u'dataset.datasetprofile': { + 'Meta': {'object_name': 'DatasetProfile'}, + 'data': ('django.db.models.fields.TextField', [], {'default': "'{}'"}), + 'dataset': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'profile'", 'unique': 'True', 'to': u"orm['dataset.Dataset']"}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}) + }, + u'dataset.datasetpropertiescache': { + 'Meta': {'object_name': 'DatasetPropertiesCache'}, + 'data': ('django.db.models.fields.TextField', [], {'default': "'{}'"}), + 'dataset': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'properties_cache'", 'unique': 'True', 'to': u"orm['dataset.Dataset']"}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}) + }, + u'dataset.datasource': { + 'Meta': {'ordering': "('-modified', '-created')", 'object_name': 'DataSource'}, + 'classname': ('django.db.models.fields.CharField', [], {'max_length': '32', 'null': 'True'}), + 'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + 'dataset': ('django.db.models.fields.related.OneToOneField', [], {'blank': 'True', 'related_name': "'source'", 'unique': 'True', 'null': 'True', 'to': u"orm['dataset.Dataset']"}), + 'exhibit': ('django.db.models.fields.related.OneToOneField', [], {'blank': 'True', 'related_name': "'ds_source'", 'unique': 'True', 'null': 'True', 'to': u"orm['exhibit.Exhibit']"}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'modified': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + 'owner': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'data_sources'", 'null': 'True', 'to': u"orm['auth.User']"}), + 'uuid': ('django.db.models.fields.CharField', [], {'max_length': '36', 'blank': 'True'}) + }, + u'dataset.datasourcetransaction': { + 'Meta': {'ordering': "('-modified', '-created')", 'object_name': 'DataSourceTransaction'}, + 'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'is_complete': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'modified': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + 'result': ('django.db.models.fields.TextField', [], {'default': "'{}'", 'null': 'True', 'blank': 'True'}), + 'source': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'transactions'", 'to': u"orm['dataset.DataSource']"}), + 'status': ('django.db.models.fields.IntegerField', [], {'default': '1'}), + 'tx_id': ('django.db.models.fields.CharField', [], {'max_length': '36', 'blank': 'True'}) + }, + u'exhibit.canvas': { + 'Meta': {'object_name': 'Canvas'}, + 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'enabled': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'location': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '100'}), + 'slug': ('django_extensions.db.fields.AutoSlugField', [], {'allow_duplicates': 'False', 'max_length': '50', 'separator': "u'-'", 'blank': 'True', 'populate_from': "'title'", 'overwrite': 'False'}), + 'thumbnail': ('django.db.models.fields.URLField', [], {'max_length': '200'}), + 'title': ('django.db.models.fields.CharField', [], {'max_length': '255'}) + }, + u'exhibit.exhibit': { + 'Meta': {'ordering': "('-modified', '-created')", 'object_name': 'Exhibit'}, + 'canvas': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['exhibit.Canvas']"}), + 'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + 'dataset': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'exhibits'", 'null': 'True', 'to': u"orm['dataset.Dataset']"}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'modified': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + 'profile': ('django.db.models.fields.TextField', [], {'default': "'{}'"}) + }, + 'exhibit.publishedexhibit': { + 'Meta': {'ordering': "('-modified',)", 'unique_together': "(('slug', 'owner'),)", 'object_name': 'PublishedExhibit', '_ormbases': ['exhibit.Exhibit']}, + 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'exhibit_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['exhibit.Exhibit']", 'unique': 'True', 'primary_key': 'True'}), + 'is_public': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'owner': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'published_exhibits'", 'null': 'True', 'to': "orm['auth.User']"}), + 'slug': ('django_extensions.db.fields.AutoSlugField', [], {'allow_duplicates': 'False', 'max_length': '50', 'separator': "u'-'", 'blank': 'True', 'populate_from': "'title'", 'overwrite': 'False'}), + 'title': ('django.db.models.fields.CharField', [], {'max_length': '255'}) + } + } + + complete_apps = ['dataset'] + symmetrical = True diff --git a/viewshare/apps/legacy/dataset/models.py b/viewshare/apps/legacy/dataset/models.py index 0bf4b886..5765b4ed 100644 --- a/viewshare/apps/legacy/dataset/models.py +++ b/viewshare/apps/legacy/dataset/models.py @@ -13,8 +13,8 @@ from django_extensions.db.fields.json import JSONField from django_extensions.db.models import ( TimeStampedModel, TitleSlugDescriptionModel) -from viewshare.apps.legacy.dataset.transform import AKARA_TRANSFORM_URL -from viewshare.apps.legacy.dataset.transform import AkaraTransformClient +from viewshare.apps.upload.transform import AKARA_TRANSFORM_URL +from viewshare.apps.upload.transform import AkaraTransformClient logger = logging.getLogger(__name__) @@ -270,6 +270,13 @@ class DataSource(TimeStampedModel): blank=True, related_name="source") + exhibit = models.OneToOneField( + 'exhibit.Exhibit', + null=True, + blank=True, + related_name="ds_source") + + uuid = UUIDField(version=4) @models.permalink diff --git a/viewshare/apps/support/views.py b/viewshare/apps/support/views.py index db57411c..f261a613 100644 --- a/viewshare/apps/support/views.py +++ b/viewshare/apps/support/views.py @@ -9,7 +9,7 @@ from viewshare.apps.support.backends import get_support_backend from viewshare.utilities.views import get_akara_version -from viewshare.apps.legacy.dataset.transform import AKARA_URL_PREFIX +from viewshare.apps.upload.transform import AKARA_URL_PREFIX from freemix import __version__ as freemix_version from freemix.utils import get_user, get_site_url diff --git a/viewshare/apps/upload/admin.py b/viewshare/apps/upload/admin.py index a70e187d..a857b1c5 100644 --- a/viewshare/apps/upload/admin.py +++ b/viewshare/apps/upload/admin.py @@ -1,19 +1,20 @@ from django.contrib import admin from . import models -from viewshare.apps.legacy.dataset.admin import DataSourceAdmin -class URLDataSourceAdmin(DataSourceAdmin): - list_display = ('uuid', 'url',) +class URLDataSourceAdmin(admin.ModelAdmin): + list_display = ('url',) -class FileDataSourceAdmin(DataSourceAdmin): - list_display = ('uuid', 'file') +class FileDataSourceAdmin(admin.ModelAdmin): + list_display = ('file',) -class OAIDataSourceAdmin(DataSourceAdmin): - list_display = ('uuid', 'title') +class OAIDataSourceAdmin(admin.ModelAdmin): + list_display = ('title',) +class ReferenceDataSourceAdmin(admin.ModelAdmin): + list_display = ('referenced',) admin.site.register(models.URLDataSource, URLDataSourceAdmin) admin.site.register(models.FileDataSource, FileDataSourceAdmin) @@ -21,3 +22,6 @@ class OAIDataSourceAdmin(DataSourceAdmin): admin.site.register(models.ModsFileDataSource, FileDataSourceAdmin) admin.site.register(models.ModsURLDataSource, URLDataSourceAdmin) admin.site.register(models.OAIDataSource, OAIDataSourceAdmin) +admin.site.register(models.ReferenceDataSource, ReferenceDataSourceAdmin) +admin.site.register(models.JSONFileDataSource, FileDataSourceAdmin) +admin.site.register(models.JSONURLDataSource, URLDataSourceAdmin) \ No newline at end of file diff --git a/viewshare/apps/upload/conf.py b/viewshare/apps/upload/conf.py index 561dd92b..7d39eae5 100644 --- a/viewshare/apps/upload/conf.py +++ b/viewshare/apps/upload/conf.py @@ -2,7 +2,7 @@ from django.conf import settings -from viewshare.apps.legacy.dataset.transform import AKARA_URL_PREFIX +from viewshare.apps.upload.transform import AKARA_URL_PREFIX AKARA_CONTENTDM_URL = getattr(settings, diff --git a/viewshare/apps/upload/migrations/0006_create_reference_datasources.py b/viewshare/apps/upload/migrations/0006_create_reference_datasources.py new file mode 100644 index 00000000..8fec7c07 --- /dev/null +++ b/viewshare/apps/upload/migrations/0006_create_reference_datasources.py @@ -0,0 +1,184 @@ +# -*- coding: utf-8 -*- +import datetime +from south.db import db +from south.v2 import DataMigration +from django.db import models + +class Migration(DataMigration): + + depends_on = ( + ("dataset", "0014_ds_reference_exhibit"), + ) + + def forwards(self, orm): + """ + For datasets that have a datasource, ensure all exhibits that aren't + linked from existing data sources have a reference data source + """ + for e in orm['exhibit.Exhibit'].objects.filter(ds_source__isnull=True): + ds = e.dataset + if ds is None: + continue + ref = ds.source + if ref is None: + continue + source = orm['upload.ReferenceDataSource']( + referenced=ref.exhibit, + classname="ReferenceDataSource", + exhibit=e, + created=e.created, + modified=e.modified + ) + source.save() + + + def backwards(self, orm): + "Write your backwards methods here." + + models = { + u'auth.group': { + 'Meta': {'object_name': 'Group'}, + u'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': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}) + }, + u'auth.permission': { + 'Meta': {'ordering': "(u'content_type__app_label', u'content_type__model', u'codename')", 'unique_together': "((u'content_type', u'codename'),)", 'object_name': 'Permission'}, + 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['contenttypes.ContentType']"}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}) + }, + u'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': u"orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + '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': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}), + 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'}) + }, + u'contenttypes.contenttype': { + 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"}, + 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + u'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'}) + }, + u'dataset.dataset': { + 'Meta': {'ordering': "('-modified',)", 'unique_together': "(('slug', 'owner'),)", 'object_name': 'Dataset'}, + 'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'modified': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + 'owner': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'datasets'", 'null': 'True', 'to': u"orm['auth.User']"}), + 'published': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'slug': ('django_extensions.db.fields.AutoSlugField', [], {'allow_duplicates': 'False', 'max_length': '50', 'separator': "u'-'", 'blank': 'True', 'populate_from': "'title'", 'overwrite': 'False'}), + 'title': ('django.db.models.fields.CharField', [], {'max_length': '255'}) + }, + u'dataset.datasource': { + 'Meta': {'ordering': "('-modified', '-created')", 'object_name': 'DataSource'}, + 'classname': ('django.db.models.fields.CharField', [], {'max_length': '32', 'null': 'True'}), + 'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + 'dataset': ('django.db.models.fields.related.OneToOneField', [], {'blank': 'True', 'related_name': "'source'", 'unique': 'True', 'null': 'True', 'to': u"orm['dataset.Dataset']"}), + 'exhibit': ('django.db.models.fields.related.OneToOneField', [], {'blank': 'True', 'related_name': "'ds_source'", 'unique': 'True', 'null': 'True', 'to': u"orm['exhibit.Exhibit']"}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'modified': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + 'owner': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'data_sources'", 'null': 'True', 'to': u"orm['auth.User']"}), + 'uuid': ('django.db.models.fields.CharField', [], {'max_length': '36', 'blank': 'True'}) + }, + u'exhibit.canvas': { + 'Meta': {'object_name': 'Canvas'}, + 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'enabled': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'location': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '100'}), + 'slug': ('django_extensions.db.fields.AutoSlugField', [], {'allow_duplicates': 'False', 'max_length': '50', 'separator': "u'-'", 'blank': 'True', 'populate_from': "'title'", 'overwrite': 'False'}), + 'thumbnail': ('django.db.models.fields.URLField', [], {'max_length': '200'}), + 'title': ('django.db.models.fields.CharField', [], {'max_length': '255'}) + }, + u'exhibit.exhibit': { + 'Meta': {'ordering': "('-modified', '-created')", 'object_name': 'Exhibit'}, + 'canvas': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['exhibit.Canvas']"}), + 'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + 'dataset': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'exhibits'", 'null': 'True', 'to': u"orm['dataset.Dataset']"}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'modified': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + 'profile': ('django.db.models.fields.TextField', [], {'default': "'{}'"}) + }, + u'upload.contentdmdatasource': { + 'Meta': {'object_name': 'ContentDMDataSource', '_ormbases': [u'dataset.DataSource']}, + 'collection': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}), + u'datasource_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['dataset.DataSource']", 'unique': 'True', 'primary_key': 'True'}), + 'limit': ('django.db.models.fields.IntegerField', [], {'default': "'100'"}), + 'query': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}), + 'url': ('django.db.models.fields.URLField', [], {'max_length': '200'}) + }, + u'upload.datasource': { + 'Meta': {'ordering': "('-modified', '-created')", 'object_name': 'DataSource'}, + 'classname': ('django.db.models.fields.CharField', [], {'max_length': '32', 'null': 'True'}), + 'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + 'exhibit': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'source'", 'unique': 'True', 'to': u"orm['exhibit.Exhibit']"}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'modified': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}) + }, + u'upload.filedatasource': { + 'Meta': {'object_name': 'FileDataSource', '_ormbases': [u'dataset.DataSource']}, + u'datasource_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['dataset.DataSource']", 'unique': 'True', 'primary_key': 'True'}), + 'file': ('django.db.models.fields.files.FileField', [], {'max_length': '255'}) + }, + u'upload.jsonfiledatasource': { + 'Meta': {'object_name': 'JSONFileDataSource', '_ormbases': [u'dataset.DataSource']}, + u'datasource_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['dataset.DataSource']", 'unique': 'True', 'primary_key': 'True'}), + 'file': ('django.db.models.fields.files.FileField', [], {'max_length': '255'}), + 'mapping': ('django.db.models.fields.TextField', [], {}), + 'path': ('django.db.models.fields.TextField', [], {}) + }, + u'upload.jsonurldatasource': { + 'Meta': {'object_name': 'JSONURLDataSource', '_ormbases': [u'dataset.DataSource']}, + u'datasource_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['dataset.DataSource']", 'unique': 'True', 'primary_key': 'True'}), + 'mapping': ('django.db.models.fields.TextField', [], {}), + 'path': ('django.db.models.fields.TextField', [], {}), + 'url': ('django.db.models.fields.URLField', [], {'max_length': '200'}) + }, + u'upload.modsfiledatasource': { + 'Meta': {'object_name': 'ModsFileDataSource', '_ormbases': [u'dataset.DataSource']}, + u'datasource_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['dataset.DataSource']", 'unique': 'True', 'primary_key': 'True'}), + 'diagnostics': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'file': ('django.db.models.fields.files.FileField', [], {'max_length': '255'}) + }, + u'upload.modsurldatasource': { + 'Meta': {'object_name': 'ModsURLDataSource', '_ormbases': [u'dataset.DataSource']}, + u'datasource_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['dataset.DataSource']", 'unique': 'True', 'primary_key': 'True'}), + 'diagnostics': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'url': ('django.db.models.fields.URLField', [], {'max_length': '200'}) + }, + u'upload.oaidatasource': { + 'Meta': {'object_name': 'OAIDataSource', '_ormbases': [u'dataset.DataSource']}, + u'datasource_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['dataset.DataSource']", 'unique': 'True', 'primary_key': 'True'}), + 'limit': ('django.db.models.fields.IntegerField', [], {'default': "'100'"}), + 'set': ('django.db.models.fields.CharField', [], {'max_length': '255'}), + 'title': ('django.db.models.fields.CharField', [], {'max_length': '255'}), + 'url': ('django.db.models.fields.URLField', [], {'max_length': '200'}) + }, + u'upload.referencedatasource': { + 'Meta': {'ordering': "('-modified', '-created')", 'object_name': 'ReferenceDataSource', '_ormbases': [u'dataset.DataSource']}, + u'datasource_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['dataset.DataSource']", 'unique': 'True', 'primary_key': 'True'}), + 'referenced': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'references'", 'to': u"orm['exhibit.Exhibit']"}) + }, + u'upload.urldatasource': { + 'Meta': {'object_name': 'URLDataSource', '_ormbases': [u'dataset.DataSource']}, + u'datasource_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['dataset.DataSource']", 'unique': 'True', 'primary_key': 'True'}), + 'url': ('django.db.models.fields.URLField', [], {'max_length': '200'}) + } + } + + complete_apps = ['upload'] + symmetrical = True diff --git a/viewshare/apps/upload/migrations/0007_new_ds_ptr.py b/viewshare/apps/upload/migrations/0007_new_ds_ptr.py new file mode 100644 index 00000000..910e7e05 --- /dev/null +++ b/viewshare/apps/upload/migrations/0007_new_ds_ptr.py @@ -0,0 +1,240 @@ +# -*- coding: 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 field 'ModsURLDataSource.new_ds_ptr' + db.add_column(u'upload_modsurldatasource', 'new_ds_ptr', + self.gf('django.db.models.fields.related.OneToOneField')(to=orm['upload.DataSource'], unique=True, null=True), + keep_default=False) + + # Adding field 'OAIDataSource.new_ds_ptr' + db.add_column(u'upload_oaidatasource', 'new_ds_ptr', + self.gf('django.db.models.fields.related.OneToOneField')(to=orm['upload.DataSource'], unique=True, null=True), + keep_default=False) + + # Adding field 'URLDataSource.new_ds_ptr' + db.add_column(u'upload_urldatasource', 'new_ds_ptr', + self.gf('django.db.models.fields.related.OneToOneField')(to=orm['upload.DataSource'], unique=True, null=True), + keep_default=False) + + # Adding field 'JSONFileDataSource.new_ds_ptr' + db.add_column(u'upload_jsonfiledatasource', 'new_ds_ptr', + self.gf('django.db.models.fields.related.OneToOneField')(to=orm['upload.DataSource'], unique=True, null=True), + keep_default=False) + + # Adding field 'ContentDMDataSource.new_ds_ptr' + db.add_column(u'upload_contentdmdatasource', 'new_ds_ptr', + self.gf('django.db.models.fields.related.OneToOneField')(to=orm['upload.DataSource'], unique=True, null=True), + keep_default=False) + + # Adding field 'JSONURLDataSource.new_ds_ptr' + db.add_column(u'upload_jsonurldatasource', 'new_ds_ptr', + self.gf('django.db.models.fields.related.OneToOneField')(to=orm['upload.DataSource'], unique=True, null=True), + keep_default=False) + + # Adding field 'FileDataSource.new_ds_ptr' + db.add_column(u'upload_filedatasource', 'new_ds_ptr', + self.gf('django.db.models.fields.related.OneToOneField')(to=orm['upload.DataSource'], unique=True, null=True), + keep_default=False) + + # Adding field 'ModsFileDataSource.new_ds_ptr' + db.add_column(u'upload_modsfiledatasource', 'new_ds_ptr', + self.gf('django.db.models.fields.related.OneToOneField')(to=orm['upload.DataSource'], unique=True, null=True), + keep_default=False) + + # Adding field 'ReferenceDataSource.new_ds_ptr' + db.add_column(u'upload_referencedatasource', 'new_ds_ptr', + self.gf('django.db.models.fields.related.OneToOneField')(to=orm['upload.DataSource'], unique=True, null=True), + keep_default=False) + + + def backwards(self, orm): + # Deleting field 'ModsURLDataSource.new_ds_ptr' + db.delete_column(u'upload_modsurldatasource', 'new_ds_ptr_id') + + # Deleting field 'OAIDataSource.new_ds_ptr' + db.delete_column(u'upload_oaidatasource', 'new_ds_ptr_id') + + # Deleting field 'URLDataSource.new_ds_ptr' + db.delete_column(u'upload_urldatasource', 'new_ds_ptr_id') + + # Deleting field 'JSONFileDataSource.new_ds_ptr' + db.delete_column(u'upload_jsonfiledatasource', 'new_ds_ptr_id') + + # Deleting field 'ContentDMDataSource.new_ds_ptr' + db.delete_column(u'upload_contentdmdatasource', 'new_ds_ptr_id') + + # Deleting field 'JSONURLDataSource.new_ds_ptr' + db.delete_column(u'upload_jsonurldatasource', 'new_ds_ptr_id') + + # Deleting field 'FileDataSource.new_ds_ptr' + db.delete_column(u'upload_filedatasource', 'new_ds_ptr_id') + + # Deleting field 'ModsFileDataSource.new_ds_ptr' + db.delete_column(u'upload_modsfiledatasource', 'new_ds_ptr_id') + + # Deleting field 'ReferenceDataSource.new_ds_ptr' + db.delete_column(u'upload_referencedatasource', 'new_ds_ptr_id') + + + models = { + u'auth.group': { + 'Meta': {'object_name': 'Group'}, + u'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': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}) + }, + u'auth.permission': { + 'Meta': {'ordering': "(u'content_type__app_label', u'content_type__model', u'codename')", 'unique_together': "((u'content_type', u'codename'),)", 'object_name': 'Permission'}, + 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['contenttypes.ContentType']"}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}) + }, + u'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': u"orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + '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': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}), + 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'}) + }, + u'contenttypes.contenttype': { + 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"}, + 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + u'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'}) + }, + u'dataset.dataset': { + 'Meta': {'ordering': "('-modified',)", 'unique_together': "(('slug', 'owner'),)", 'object_name': 'Dataset'}, + 'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'modified': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + 'owner': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'datasets'", 'null': 'True', 'to': u"orm['auth.User']"}), + 'published': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'slug': ('django_extensions.db.fields.AutoSlugField', [], {'allow_duplicates': 'False', 'max_length': '50', 'separator': "u'-'", 'blank': 'True', 'populate_from': "'title'", 'overwrite': 'False'}), + 'title': ('django.db.models.fields.CharField', [], {'max_length': '255'}) + }, + u'dataset.datasource': { + 'Meta': {'ordering': "('-modified', '-created')", 'object_name': 'DataSource'}, + 'classname': ('django.db.models.fields.CharField', [], {'max_length': '32', 'null': 'True'}), + 'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + 'dataset': ('django.db.models.fields.related.OneToOneField', [], {'blank': 'True', 'related_name': "'source'", 'unique': 'True', 'null': 'True', 'to': u"orm['dataset.Dataset']"}), + 'exhibit': ('django.db.models.fields.related.OneToOneField', [], {'blank': 'True', 'related_name': "'ds_source'", 'unique': 'True', 'null': 'True', 'to': u"orm['exhibit.Exhibit']"}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'modified': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + 'owner': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'data_sources'", 'null': 'True', 'to': u"orm['auth.User']"}), + 'uuid': ('django.db.models.fields.CharField', [], {'max_length': '36', 'blank': 'True'}) + }, + u'exhibit.canvas': { + 'Meta': {'object_name': 'Canvas'}, + 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'enabled': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'location': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '100'}), + 'slug': ('django_extensions.db.fields.AutoSlugField', [], {'allow_duplicates': 'False', 'max_length': '50', 'separator': "u'-'", 'blank': 'True', 'populate_from': "'title'", 'overwrite': 'False'}), + 'thumbnail': ('django.db.models.fields.URLField', [], {'max_length': '200'}), + 'title': ('django.db.models.fields.CharField', [], {'max_length': '255'}) + }, + u'exhibit.exhibit': { + 'Meta': {'ordering': "('-modified', '-created')", 'object_name': 'Exhibit'}, + 'canvas': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['exhibit.Canvas']"}), + 'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + 'dataset': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'exhibits'", 'null': 'True', 'to': u"orm['dataset.Dataset']"}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'modified': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + 'profile': ('django.db.models.fields.TextField', [], {'default': "'{}'"}) + }, + u'upload.contentdmdatasource': { + 'Meta': {'object_name': 'ContentDMDataSource', '_ormbases': [u'dataset.DataSource']}, + 'collection': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}), + u'datasource_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['dataset.DataSource']", 'unique': 'True', 'primary_key': 'True'}), + 'limit': ('django.db.models.fields.IntegerField', [], {'default': "'100'"}), + 'new_ds_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['upload.DataSource']", 'unique': 'True', 'null': 'True'}), + 'query': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}), + 'url': ('django.db.models.fields.URLField', [], {'max_length': '200'}) + }, + u'upload.datasource': { + 'Meta': {'ordering': "('-modified', '-created')", 'object_name': 'DataSource'}, + 'classname': ('django.db.models.fields.CharField', [], {'max_length': '32', 'null': 'True'}), + 'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + 'exhibit': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'source'", 'unique': 'True', 'to': u"orm['exhibit.Exhibit']"}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'modified': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}) + }, + u'upload.filedatasource': { + 'Meta': {'object_name': 'FileDataSource', '_ormbases': [u'dataset.DataSource']}, + u'datasource_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['dataset.DataSource']", 'unique': 'True', 'primary_key': 'True'}), + 'file': ('django.db.models.fields.files.FileField', [], {'max_length': '255'}), + 'new_ds_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['upload.DataSource']", 'unique': 'True', 'null': 'True'}) + }, + u'upload.jsonfiledatasource': { + 'Meta': {'object_name': 'JSONFileDataSource', '_ormbases': [u'dataset.DataSource']}, + u'datasource_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['dataset.DataSource']", 'unique': 'True', 'primary_key': 'True'}), + 'file': ('django.db.models.fields.files.FileField', [], {'max_length': '255'}), + 'mapping': ('django.db.models.fields.TextField', [], {}), + 'new_ds_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['upload.DataSource']", 'unique': 'True', 'null': 'True'}), + 'path': ('django.db.models.fields.TextField', [], {}) + }, + u'upload.jsonurldatasource': { + 'Meta': {'object_name': 'JSONURLDataSource', '_ormbases': [u'dataset.DataSource']}, + u'datasource_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['dataset.DataSource']", 'unique': 'True', 'primary_key': 'True'}), + 'mapping': ('django.db.models.fields.TextField', [], {}), + 'new_ds_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['upload.DataSource']", 'unique': 'True', 'null': 'True'}), + 'path': ('django.db.models.fields.TextField', [], {}), + 'url': ('django.db.models.fields.URLField', [], {'max_length': '200'}) + }, + u'upload.modsfiledatasource': { + 'Meta': {'object_name': 'ModsFileDataSource', '_ormbases': [u'dataset.DataSource']}, + u'datasource_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['dataset.DataSource']", 'unique': 'True', 'primary_key': 'True'}), + 'diagnostics': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'file': ('django.db.models.fields.files.FileField', [], {'max_length': '255'}), + 'new_ds_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['upload.DataSource']", 'unique': 'True', 'null': 'True'}) + }, + u'upload.modsurldatasource': { + 'Meta': {'object_name': 'ModsURLDataSource', '_ormbases': [u'dataset.DataSource']}, + u'datasource_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['dataset.DataSource']", 'unique': 'True', 'primary_key': 'True'}), + 'diagnostics': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'new_ds_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['upload.DataSource']", 'unique': 'True', 'null': 'True'}), + 'url': ('django.db.models.fields.URLField', [], {'max_length': '200'}) + }, + u'upload.oaidatasource': { + 'Meta': {'object_name': 'OAIDataSource', '_ormbases': [u'dataset.DataSource']}, + u'datasource_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['dataset.DataSource']", 'unique': 'True', 'primary_key': 'True'}), + 'limit': ('django.db.models.fields.IntegerField', [], {'default': "'100'"}), + 'new_ds_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['upload.DataSource']", 'unique': 'True', 'null': 'True'}), + 'set': ('django.db.models.fields.CharField', [], {'max_length': '255'}), + 'title': ('django.db.models.fields.CharField', [], {'max_length': '255'}), + 'url': ('django.db.models.fields.URLField', [], {'max_length': '200'}) + }, + u'upload.referencedatasource': { + 'Meta': {'ordering': "('-modified', '-created')", 'object_name': 'ReferenceDataSource', '_ormbases': [u'dataset.DataSource']}, + u'datasource_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['dataset.DataSource']", 'unique': 'True', 'primary_key': 'True'}), + 'new_ds_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['upload.DataSource']", 'unique': 'True', 'null': 'True'}), + 'referenced': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'references'", 'to': u"orm['exhibit.Exhibit']"}) + }, + u'upload.urldatasource': { + 'Meta': {'object_name': 'URLDataSource', '_ormbases': [u'dataset.DataSource']}, + u'datasource_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['dataset.DataSource']", 'unique': 'True', 'primary_key': 'True'}), + 'new_ds_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['upload.DataSource']", 'unique': 'True', 'null': 'True'}), + 'url': ('django.db.models.fields.URLField', [], {'max_length': '200'}) + } + } + + complete_apps = ['upload'] \ No newline at end of file diff --git a/viewshare/apps/upload/migrations/0008_migrate_datasources.py b/viewshare/apps/upload/migrations/0008_migrate_datasources.py new file mode 100644 index 00000000..3650c39e --- /dev/null +++ b/viewshare/apps/upload/migrations/0008_migrate_datasources.py @@ -0,0 +1,220 @@ +# -*- coding: utf-8 -*- +import datetime +from south.db import db +from south.v2 import DataMigration +from django.db import models +source_types = ( + "upload.FileDataSource", + "upload.jsonfiledatasource", + "upload.contentdmdatasource", + "upload.jsonurldatasource", + "upload.modsfiledatasource", + "upload.modsurldatasource", + "upload.oaidatasource", + "upload.referencedatasource", + "upload.urldatasource" + + +) + +def migrate_datasource(ds): + source = orm["upload.DataSource"]( + classname=ds.classname, + created=ds.created, + exhibit=ds.exhibit, + modified=ds.modified + ) + source.save() + ds.new_ds_ptr=source + ds.save() + +class Migration(DataMigration): + + def forwards(self, orm): + """ + Migrate data sources from dataset to upload app by iterating over + exhibits and pointing to their data sources, so orphaned data sources + aren't migrated. + """ + for t in source_types: + for ds in orm[t].objects.filter(exhibit__isnull=False): + source = orm["upload.DataSource"]( + classname=ds.classname, + created=ds.created, + exhibit=ds.exhibit, + modified=ds.modified + ) + source.save() + ds.new_ds_ptr=source + ds.save() + + for ds in orm["dataset.datasource"].objects.filter(classname="DataSource", exhibit__isnull=False): + source = orm["upload.DataSource"]( + classname=ds.classname, + created=ds.created, + exhibit=ds.exhibit, + modified=ds.modified + ) + source.save() + + orm["dataset.datasource"].objects.filter(exhibit__isnull=True).delete() + + def backwards(self, orm): + "Write your backwards methods here." + + models = { + u'auth.group': { + 'Meta': {'object_name': 'Group'}, + u'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': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}) + }, + u'auth.permission': { + 'Meta': {'ordering': "(u'content_type__app_label', u'content_type__model', u'codename')", 'unique_together': "((u'content_type', u'codename'),)", 'object_name': 'Permission'}, + 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['contenttypes.ContentType']"}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}) + }, + u'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': u"orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + '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': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}), + 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'}) + }, + u'contenttypes.contenttype': { + 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"}, + 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + u'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'}) + }, + u'dataset.dataset': { + 'Meta': {'ordering': "('-modified',)", 'unique_together': "(('slug', 'owner'),)", 'object_name': 'Dataset'}, + 'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'modified': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + 'owner': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'datasets'", 'null': 'True', 'to': u"orm['auth.User']"}), + 'published': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'slug': ('django_extensions.db.fields.AutoSlugField', [], {'allow_duplicates': 'False', 'max_length': '50', 'separator': "u'-'", 'blank': 'True', 'populate_from': "'title'", 'overwrite': 'False'}), + 'title': ('django.db.models.fields.CharField', [], {'max_length': '255'}) + }, + u'dataset.datasource': { + 'Meta': {'ordering': "('-modified', '-created')", 'object_name': 'DataSource'}, + 'classname': ('django.db.models.fields.CharField', [], {'max_length': '32', 'null': 'True'}), + 'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + 'dataset': ('django.db.models.fields.related.OneToOneField', [], {'blank': 'True', 'related_name': "'source'", 'unique': 'True', 'null': 'True', 'to': u"orm['dataset.Dataset']"}), + 'exhibit': ('django.db.models.fields.related.OneToOneField', [], {'blank': 'True', 'related_name': "'ds_source'", 'unique': 'True', 'null': 'True', 'to': u"orm['exhibit.Exhibit']"}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'modified': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + 'owner': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'data_sources'", 'null': 'True', 'to': u"orm['auth.User']"}), + 'uuid': ('django.db.models.fields.CharField', [], {'max_length': '36', 'blank': 'True'}) + }, + u'exhibit.canvas': { + 'Meta': {'object_name': 'Canvas'}, + 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'enabled': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'location': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '100'}), + 'slug': ('django_extensions.db.fields.AutoSlugField', [], {'allow_duplicates': 'False', 'max_length': '50', 'separator': "u'-'", 'blank': 'True', 'populate_from': "'title'", 'overwrite': 'False'}), + 'thumbnail': ('django.db.models.fields.URLField', [], {'max_length': '200'}), + 'title': ('django.db.models.fields.CharField', [], {'max_length': '255'}) + }, + u'exhibit.exhibit': { + 'Meta': {'ordering': "('-modified', '-created')", 'object_name': 'Exhibit'}, + 'canvas': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['exhibit.Canvas']"}), + 'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + 'dataset': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'exhibits'", 'null': 'True', 'to': u"orm['dataset.Dataset']"}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'modified': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + 'profile': ('django.db.models.fields.TextField', [], {'default': "'{}'"}) + }, + u'upload.contentdmdatasource': { + 'Meta': {'object_name': 'ContentDMDataSource', '_ormbases': [u'dataset.DataSource']}, + 'collection': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}), + u'datasource_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['dataset.DataSource']", 'unique': 'True', 'primary_key': 'True'}), + 'limit': ('django.db.models.fields.IntegerField', [], {'default': "'100'"}), + u'new_ds_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['upload.DataSource']", 'unique': 'True', 'null': 'True'}), + 'query': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}), + 'url': ('django.db.models.fields.URLField', [], {'max_length': '200'}) + }, + u'upload.datasource': { + 'Meta': {'ordering': "('-modified', '-created')", 'object_name': 'DataSource'}, + 'classname': ('django.db.models.fields.CharField', [], {'max_length': '32', 'null': 'True'}), + 'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + 'exhibit': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'source'", 'unique': 'True', 'to': u"orm['exhibit.Exhibit']"}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'modified': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}) + }, + u'upload.filedatasource': { + 'Meta': {'object_name': 'FileDataSource', '_ormbases': [u'dataset.DataSource']}, + u'datasource_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['dataset.DataSource']", 'unique': 'True', 'primary_key': 'True'}), + 'file': ('django.db.models.fields.files.FileField', [], {'max_length': '255'}), + u'new_ds_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['upload.DataSource']", 'unique': 'True', 'null': 'True'}) + }, + u'upload.jsonfiledatasource': { + 'Meta': {'object_name': 'JSONFileDataSource', '_ormbases': [u'dataset.DataSource']}, + u'datasource_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['dataset.DataSource']", 'unique': 'True', 'primary_key': 'True'}), + 'file': ('django.db.models.fields.files.FileField', [], {'max_length': '255'}), + 'mapping': ('django.db.models.fields.TextField', [], {}), + u'new_ds_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['upload.DataSource']", 'unique': 'True', 'null': 'True'}), + 'path': ('django.db.models.fields.TextField', [], {}) + }, + u'upload.jsonurldatasource': { + 'Meta': {'object_name': 'JSONURLDataSource', '_ormbases': [u'dataset.DataSource']}, + u'datasource_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['dataset.DataSource']", 'unique': 'True', 'primary_key': 'True'}), + 'mapping': ('django.db.models.fields.TextField', [], {}), + u'new_ds_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['upload.DataSource']", 'unique': 'True', 'null': 'True'}), + 'path': ('django.db.models.fields.TextField', [], {}), + 'url': ('django.db.models.fields.URLField', [], {'max_length': '200'}) + }, + u'upload.modsfiledatasource': { + 'Meta': {'object_name': 'ModsFileDataSource', '_ormbases': [u'dataset.DataSource']}, + u'datasource_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['dataset.DataSource']", 'unique': 'True', 'primary_key': 'True'}), + 'diagnostics': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'file': ('django.db.models.fields.files.FileField', [], {'max_length': '255'}), + u'new_ds_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['upload.DataSource']", 'unique': 'True', 'null': 'True'}) + }, + u'upload.modsurldatasource': { + 'Meta': {'object_name': 'ModsURLDataSource', '_ormbases': [u'dataset.DataSource']}, + u'datasource_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['dataset.DataSource']", 'unique': 'True', 'primary_key': 'True'}), + 'diagnostics': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + u'new_ds_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['upload.DataSource']", 'unique': 'True', 'null': 'True'}), + 'url': ('django.db.models.fields.URLField', [], {'max_length': '200'}) + }, + u'upload.oaidatasource': { + 'Meta': {'object_name': 'OAIDataSource', '_ormbases': [u'dataset.DataSource']}, + u'datasource_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['dataset.DataSource']", 'unique': 'True', 'primary_key': 'True'}), + 'limit': ('django.db.models.fields.IntegerField', [], {'default': "'100'"}), + u'new_ds_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['upload.DataSource']", 'unique': 'True', 'null': 'True'}), + 'set': ('django.db.models.fields.CharField', [], {'max_length': '255'}), + 'title': ('django.db.models.fields.CharField', [], {'max_length': '255'}), + 'url': ('django.db.models.fields.URLField', [], {'max_length': '200'}) + }, + u'upload.referencedatasource': { + 'Meta': {'ordering': "('-modified', '-created')", 'object_name': 'ReferenceDataSource', '_ormbases': [u'dataset.DataSource']}, + u'datasource_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['dataset.DataSource']", 'unique': 'True', 'primary_key': 'True'}), + u'new_ds_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['upload.DataSource']", 'unique': 'True', 'null': 'True'}), + 'referenced': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'references'", 'to': u"orm['exhibit.Exhibit']"}) + }, + u'upload.urldatasource': { + 'Meta': {'object_name': 'URLDataSource', '_ormbases': [u'dataset.DataSource']}, + u'datasource_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['dataset.DataSource']", 'unique': 'True', 'primary_key': 'True'}), + u'new_ds_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['upload.DataSource']", 'unique': 'True', 'null': 'True'}), + 'url': ('django.db.models.fields.URLField', [], {'max_length': '200'}) + } + } + + complete_apps = ['upload'] + symmetrical = True diff --git a/viewshare/apps/upload/migrations/0009_drop_dataset_datasource_refs.py b/viewshare/apps/upload/migrations/0009_drop_dataset_datasource_refs.py new file mode 100644 index 00000000..7247ad84 --- /dev/null +++ b/viewshare/apps/upload/migrations/0009_drop_dataset_datasource_refs.py @@ -0,0 +1,272 @@ +# -*- coding: 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): + # Deleting field 'ModsURLDataSource.datasource_ptr' + db.delete_column(u'upload_modsurldatasource', u'datasource_ptr_id') + + + # Changing field 'ModsURLDataSource.new_ds_ptr' + db.alter_column(u'upload_modsurldatasource', 'new_ds_ptr_id', self.gf('django.db.models.fields.related.OneToOneField')(default=0, to=orm['upload.DataSource'], unique=True, primary_key=True)) + # Deleting field 'OAIDataSource.datasource_ptr' + db.delete_column(u'upload_oaidatasource', u'datasource_ptr_id') + + + # Changing field 'OAIDataSource.new_ds_ptr' + db.alter_column(u'upload_oaidatasource', 'new_ds_ptr_id', self.gf('django.db.models.fields.related.OneToOneField')(default=0, to=orm['upload.DataSource'], unique=True, primary_key=True)) + # Deleting field 'URLDataSource.datasource_ptr' + db.delete_column(u'upload_urldatasource', u'datasource_ptr_id') + + + # Changing field 'URLDataSource.new_ds_ptr' + db.alter_column(u'upload_urldatasource', 'new_ds_ptr_id', self.gf('django.db.models.fields.related.OneToOneField')(default=0, to=orm['upload.DataSource'], unique=True, primary_key=True)) + # Deleting field 'JSONFileDataSource.datasource_ptr' + db.delete_column(u'upload_jsonfiledatasource', u'datasource_ptr_id') + + + # Changing field 'JSONFileDataSource.new_ds_ptr' + db.alter_column(u'upload_jsonfiledatasource', 'new_ds_ptr_id', self.gf('django.db.models.fields.related.OneToOneField')(default=0, to=orm['upload.DataSource'], unique=True, primary_key=True)) + # Deleting field 'ContentDMDataSource.datasource_ptr' + db.delete_column(u'upload_contentdmdatasource', u'datasource_ptr_id') + + + # Changing field 'ContentDMDataSource.new_ds_ptr' + db.alter_column(u'upload_contentdmdatasource', 'new_ds_ptr_id', self.gf('django.db.models.fields.related.OneToOneField')(default=0, to=orm['upload.DataSource'], unique=True, primary_key=True)) + # Deleting field 'JSONURLDataSource.datasource_ptr' + db.delete_column(u'upload_jsonurldatasource', u'datasource_ptr_id') + + + # Changing field 'JSONURLDataSource.new_ds_ptr' + db.alter_column(u'upload_jsonurldatasource', 'new_ds_ptr_id', self.gf('django.db.models.fields.related.OneToOneField')(default=0, to=orm['upload.DataSource'], unique=True, primary_key=True)) + # Deleting field 'FileDataSource.datasource_ptr' + db.delete_column(u'upload_filedatasource', u'datasource_ptr_id') + + + # Changing field 'FileDataSource.new_ds_ptr' + db.alter_column(u'upload_filedatasource', 'new_ds_ptr_id', self.gf('django.db.models.fields.related.OneToOneField')(default=0, to=orm['upload.DataSource'], unique=True, primary_key=True)) + # Deleting field 'ModsFileDataSource.datasource_ptr' + db.delete_column(u'upload_modsfiledatasource', u'datasource_ptr_id') + + + # Changing field 'ModsFileDataSource.new_ds_ptr' + db.alter_column(u'upload_modsfiledatasource', 'new_ds_ptr_id', self.gf('django.db.models.fields.related.OneToOneField')(default=0, to=orm['upload.DataSource'], unique=True, primary_key=True)) + # Deleting field 'ReferenceDataSource.datasource_ptr' + db.delete_column(u'upload_referencedatasource', u'datasource_ptr_id') + + + # Changing field 'ReferenceDataSource.new_ds_ptr' + db.alter_column(u'upload_referencedatasource', 'new_ds_ptr_id', self.gf('django.db.models.fields.related.OneToOneField')(default=0, to=orm['upload.DataSource'], unique=True, primary_key=True)) + + def backwards(self, orm): + + # User chose to not deal with backwards NULL issues for 'ModsURLDataSource.datasource_ptr' + raise RuntimeError("Cannot reverse this migration. 'ModsURLDataSource.datasource_ptr' and its values cannot be restored.") + + # Changing field 'ModsURLDataSource.new_ds_ptr' + db.alter_column(u'upload_modsurldatasource', u'new_ds_ptr_id', self.gf('django.db.models.fields.related.OneToOneField')(to=orm['upload.DataSource'], unique=True, null=True)) + # Adding field 'OAIDataSource.datasource_ptr' + db.add_column(u'upload_oaidatasource', u'datasource_ptr', + self.gf('django.db.models.fields.related.OneToOneField')(default=0, to=orm['dataset.DataSource'], unique=True, primary_key=True), + keep_default=False) + + + # Changing field 'OAIDataSource.new_ds_ptr' + db.alter_column(u'upload_oaidatasource', u'new_ds_ptr_id', self.gf('django.db.models.fields.related.OneToOneField')(to=orm['upload.DataSource'], unique=True, null=True)) + # Adding field 'URLDataSource.datasource_ptr' + db.add_column(u'upload_urldatasource', u'datasource_ptr', + self.gf('django.db.models.fields.related.OneToOneField')(default=0, to=orm['dataset.DataSource'], unique=True, primary_key=True), + keep_default=False) + + + # Changing field 'URLDataSource.new_ds_ptr' + db.alter_column(u'upload_urldatasource', u'new_ds_ptr_id', self.gf('django.db.models.fields.related.OneToOneField')(to=orm['upload.DataSource'], unique=True, null=True)) + # Adding field 'JSONFileDataSource.datasource_ptr' + db.add_column(u'upload_jsonfiledatasource', u'datasource_ptr', + self.gf('django.db.models.fields.related.OneToOneField')(default=0, to=orm['dataset.DataSource'], unique=True, primary_key=True), + keep_default=False) + + + # Changing field 'JSONFileDataSource.new_ds_ptr' + db.alter_column(u'upload_jsonfiledatasource', u'new_ds_ptr_id', self.gf('django.db.models.fields.related.OneToOneField')(to=orm['upload.DataSource'], unique=True, null=True)) + # Adding field 'ContentDMDataSource.datasource_ptr' + db.add_column(u'upload_contentdmdatasource', u'datasource_ptr', + self.gf('django.db.models.fields.related.OneToOneField')(default=0, to=orm['dataset.DataSource'], unique=True, primary_key=True), + keep_default=False) + + + # Changing field 'ContentDMDataSource.new_ds_ptr' + db.alter_column(u'upload_contentdmdatasource', u'new_ds_ptr_id', self.gf('django.db.models.fields.related.OneToOneField')(to=orm['upload.DataSource'], unique=True, null=True)) + # Adding field 'JSONURLDataSource.datasource_ptr' + db.add_column(u'upload_jsonurldatasource', u'datasource_ptr', + self.gf('django.db.models.fields.related.OneToOneField')(default=0, to=orm['dataset.DataSource'], unique=True, primary_key=True), + keep_default=False) + + + # Changing field 'JSONURLDataSource.new_ds_ptr' + db.alter_column(u'upload_jsonurldatasource', u'new_ds_ptr_id', self.gf('django.db.models.fields.related.OneToOneField')(to=orm['upload.DataSource'], unique=True, null=True)) + # Adding field 'FileDataSource.datasource_ptr' + db.add_column(u'upload_filedatasource', u'datasource_ptr', + self.gf('django.db.models.fields.related.OneToOneField')(default=0, to=orm['dataset.DataSource'], unique=True, primary_key=True), + keep_default=False) + + + # Changing field 'FileDataSource.new_ds_ptr' + db.alter_column(u'upload_filedatasource', u'new_ds_ptr_id', self.gf('django.db.models.fields.related.OneToOneField')(to=orm['upload.DataSource'], unique=True, null=True)) + # Adding field 'ModsFileDataSource.datasource_ptr' + db.add_column(u'upload_modsfiledatasource', u'datasource_ptr', + self.gf('django.db.models.fields.related.OneToOneField')(default=0, to=orm['dataset.DataSource'], unique=True, primary_key=True), + keep_default=False) + + + # Changing field 'ModsFileDataSource.new_ds_ptr' + db.alter_column(u'upload_modsfiledatasource', u'new_ds_ptr_id', self.gf('django.db.models.fields.related.OneToOneField')(to=orm['upload.DataSource'], unique=True, null=True)) + # Adding field 'ReferenceDataSource.datasource_ptr' + db.add_column(u'upload_referencedatasource', u'datasource_ptr', + self.gf('django.db.models.fields.related.OneToOneField')(default=0, to=orm['dataset.DataSource'], unique=True, primary_key=True), + keep_default=False) + + + # Changing field 'ReferenceDataSource.new_ds_ptr' + db.alter_column(u'upload_referencedatasource', u'new_ds_ptr_id', self.gf('django.db.models.fields.related.OneToOneField')(to=orm['upload.DataSource'], unique=True, null=True)) + + models = { + u'auth.group': { + 'Meta': {'object_name': 'Group'}, + u'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': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}) + }, + u'auth.permission': { + 'Meta': {'ordering': "(u'content_type__app_label', u'content_type__model', u'codename')", 'unique_together': "((u'content_type', u'codename'),)", 'object_name': 'Permission'}, + 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['contenttypes.ContentType']"}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}) + }, + u'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': u"orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + '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': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}), + 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'}) + }, + u'contenttypes.contenttype': { + 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"}, + 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + u'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'}) + }, + u'dataset.dataset': { + 'Meta': {'ordering': "('-modified',)", 'unique_together': "(('slug', 'owner'),)", 'object_name': 'Dataset'}, + 'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'modified': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + 'owner': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'datasets'", 'null': 'True', 'to': u"orm['auth.User']"}), + 'published': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'slug': ('django_extensions.db.fields.AutoSlugField', [], {'allow_duplicates': 'False', 'max_length': '50', 'separator': "u'-'", 'blank': 'True', 'populate_from': "'title'", 'overwrite': 'False'}), + 'title': ('django.db.models.fields.CharField', [], {'max_length': '255'}) + }, + u'exhibit.canvas': { + 'Meta': {'object_name': 'Canvas'}, + 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'enabled': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'location': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '100'}), + 'slug': ('django_extensions.db.fields.AutoSlugField', [], {'allow_duplicates': 'False', 'max_length': '50', 'separator': "u'-'", 'blank': 'True', 'populate_from': "'title'", 'overwrite': 'False'}), + 'thumbnail': ('django.db.models.fields.URLField', [], {'max_length': '200'}), + 'title': ('django.db.models.fields.CharField', [], {'max_length': '255'}) + }, + u'exhibit.exhibit': { + 'Meta': {'ordering': "('-modified', '-created')", 'object_name': 'Exhibit'}, + 'canvas': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['exhibit.Canvas']"}), + 'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + 'dataset': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'exhibits'", 'null': 'True', 'to': u"orm['dataset.Dataset']"}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'modified': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + 'profile': ('django.db.models.fields.TextField', [], {'default': "'{}'"}) + }, + u'upload.contentdmdatasource': { + 'Meta': {'object_name': 'ContentDMDataSource'}, + 'collection': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}), + 'limit': ('django.db.models.fields.IntegerField', [], {'default': "'100'"}), + 'new_ds_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['upload.DataSource']", 'unique': 'True', 'primary_key': 'True'}), + 'query': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}), + 'url': ('django.db.models.fields.URLField', [], {'max_length': '200'}) + }, + u'upload.datasource': { + 'Meta': {'ordering': "('-modified', '-created')", 'object_name': 'DataSource'}, + 'classname': ('django.db.models.fields.CharField', [], {'max_length': '32', 'null': 'True'}), + 'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + 'exhibit': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'source'", 'unique': 'True', 'to': u"orm['exhibit.Exhibit']"}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'modified': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}) + }, + u'upload.filedatasource': { + 'Meta': {'object_name': 'FileDataSource'}, + 'file': ('django.db.models.fields.files.FileField', [], {'max_length': '255'}), + 'new_ds_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['upload.DataSource']", 'unique': 'True', 'primary_key': 'True'}) + }, + u'upload.jsonfiledatasource': { + 'Meta': {'object_name': 'JSONFileDataSource'}, + 'file': ('django.db.models.fields.files.FileField', [], {'max_length': '255'}), + 'mapping': ('django.db.models.fields.TextField', [], {}), + 'new_ds_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['upload.DataSource']", 'unique': 'True', 'primary_key': 'True'}), + 'path': ('django.db.models.fields.TextField', [], {}) + }, + u'upload.jsonurldatasource': { + 'Meta': {'object_name': 'JSONURLDataSource'}, + 'mapping': ('django.db.models.fields.TextField', [], {}), + 'new_ds_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['upload.DataSource']", 'unique': 'True', 'primary_key': 'True'}), + 'path': ('django.db.models.fields.TextField', [], {}), + 'url': ('django.db.models.fields.URLField', [], {'max_length': '200'}) + }, + u'upload.modsfiledatasource': { + 'Meta': {'object_name': 'ModsFileDataSource'}, + 'diagnostics': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'file': ('django.db.models.fields.files.FileField', [], {'max_length': '255'}), + 'new_ds_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['upload.DataSource']", 'unique': 'True', 'primary_key': 'True'}) + }, + u'upload.modsurldatasource': { + 'Meta': {'object_name': 'ModsURLDataSource'}, + 'diagnostics': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'new_ds_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['upload.DataSource']", 'unique': 'True', 'primary_key': 'True'}), + 'url': ('django.db.models.fields.URLField', [], {'max_length': '200'}) + }, + u'upload.oaidatasource': { + 'Meta': {'object_name': 'OAIDataSource'}, + 'limit': ('django.db.models.fields.IntegerField', [], {'default': "'100'"}), + 'new_ds_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['upload.DataSource']", 'unique': 'True', 'primary_key': 'True'}), + 'set': ('django.db.models.fields.CharField', [], {'max_length': '255'}), + 'title': ('django.db.models.fields.CharField', [], {'max_length': '255'}), + 'url': ('django.db.models.fields.URLField', [], {'max_length': '200'}) + }, + u'upload.referencedatasource': { + 'Meta': {'object_name': 'ReferenceDataSource'}, + 'new_ds_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['upload.DataSource']", 'unique': 'True', 'primary_key': 'True'}), + 'referenced': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'references'", 'to': u"orm['exhibit.Exhibit']"}) + }, + u'upload.urldatasource': { + 'Meta': {'object_name': 'URLDataSource'}, + 'new_ds_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['upload.DataSource']", 'unique': 'True', 'primary_key': 'True'}), + 'url': ('django.db.models.fields.URLField', [], {'max_length': '200'}) + } + } + + complete_apps = ['upload'] \ No newline at end of file diff --git a/viewshare/apps/upload/migrations/0010_rename_new_ds_ptr__datasource_ptr.py b/viewshare/apps/upload/migrations/0010_rename_new_ds_ptr__datasource_ptr.py new file mode 100644 index 00000000..d57c2ed9 --- /dev/null +++ b/viewshare/apps/upload/migrations/0010_rename_new_ds_ptr__datasource_ptr.py @@ -0,0 +1,173 @@ +# -*- coding: 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): + + + db.rename_column(u'upload_modsurldatasource', 'new_ds_ptr_id', 'datasource_ptr_id') + db.rename_column(u'upload_filedatasource', 'new_ds_ptr_id', 'datasource_ptr_id') + db.rename_column(u'upload_urldatasource', 'new_ds_ptr_id', 'datasource_ptr_id') + db.rename_column(u'upload_jsonfiledatasource', 'new_ds_ptr_id', 'datasource_ptr_id') + db.rename_column(u'upload_contentdmdatasource', 'new_ds_ptr_id', 'datasource_ptr_id') + db.rename_column(u'upload_jsonurldatasource', 'new_ds_ptr_id', 'datasource_ptr_id') + db.rename_column(u'upload_oaidatasource', 'new_ds_ptr_id', 'datasource_ptr_id') + db.rename_column(u'upload_modsfiledatasource', 'new_ds_ptr_id', 'datasource_ptr_id') + db.rename_column(u'upload_referencedatasource', 'new_ds_ptr_id', 'datasource_ptr_id') + + + def backwards(self, orm): + + + db.rename_column(u'upload_modsurldatasource', 'datasource_ptr_id', 'new_ds_ptr_id') + db.rename_column(u'upload_filedatasource', 'datasource_ptr_id', 'new_ds_ptr_id') + db.rename_column(u'upload_urldatasource', 'datasource_ptr_id', 'new_ds_ptr_id') + db.rename_column(u'upload_jsonfiledatasource', 'datasource_ptr_id', 'new_ds_ptr_id') + db.rename_column(u'upload_contentdmdatasource', 'datasource_ptr_id', 'new_ds_ptr_id') + db.rename_column(u'upload_jsonurldatasource', 'datasource_ptr_id', 'new_ds_ptr_id') + db.rename_column(u'upload_oaidatasource', 'datasource_ptr_id', 'new_ds_ptr_id') + db.rename_column(u'upload_modsfiledatasource', 'datasource_ptr_id', 'new_ds_ptr_id') + db.rename_column(u'upload_referencedatasource', 'datasource_ptr_id', 'new_ds_ptr_id') + + + + models = { + u'auth.group': { + 'Meta': {'object_name': 'Group'}, + u'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': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}) + }, + u'auth.permission': { + 'Meta': {'ordering': "(u'content_type__app_label', u'content_type__model', u'codename')", 'unique_together': "((u'content_type', u'codename'),)", 'object_name': 'Permission'}, + 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['contenttypes.ContentType']"}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}) + }, + u'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': u"orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + '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': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}), + 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'}) + }, + u'contenttypes.contenttype': { + 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"}, + 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + u'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'}) + }, + u'dataset.dataset': { + 'Meta': {'ordering': "('-modified',)", 'unique_together': "(('slug', 'owner'),)", 'object_name': 'Dataset'}, + 'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'modified': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + 'owner': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'datasets'", 'null': 'True', 'to': u"orm['auth.User']"}), + 'published': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'slug': ('django_extensions.db.fields.AutoSlugField', [], {'allow_duplicates': 'False', 'max_length': '50', 'separator': "u'-'", 'blank': 'True', 'populate_from': "'title'", 'overwrite': 'False'}), + 'title': ('django.db.models.fields.CharField', [], {'max_length': '255'}) + }, + u'exhibit.canvas': { + 'Meta': {'object_name': 'Canvas'}, + 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'enabled': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'location': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '100'}), + 'slug': ('django_extensions.db.fields.AutoSlugField', [], {'allow_duplicates': 'False', 'max_length': '50', 'separator': "u'-'", 'blank': 'True', 'populate_from': "'title'", 'overwrite': 'False'}), + 'thumbnail': ('django.db.models.fields.URLField', [], {'max_length': '200'}), + 'title': ('django.db.models.fields.CharField', [], {'max_length': '255'}) + }, + u'exhibit.exhibit': { + 'Meta': {'ordering': "('-modified', '-created')", 'object_name': 'Exhibit'}, + 'canvas': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['exhibit.Canvas']"}), + 'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + 'dataset': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'exhibits'", 'null': 'True', 'to': u"orm['dataset.Dataset']"}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'modified': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + 'profile': ('django.db.models.fields.TextField', [], {'default': "'{}'"}) + }, + u'upload.contentdmdatasource': { + 'Meta': {'object_name': 'ContentDMDataSource', '_ormbases': [u'upload.DataSource']}, + 'collection': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}), + u'datasource_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['upload.DataSource']", 'unique': 'True', 'primary_key': 'True'}), + 'limit': ('django.db.models.fields.IntegerField', [], {'default': "'100'"}), + 'query': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}), + 'url': ('django.db.models.fields.URLField', [], {'max_length': '200'}) + }, + u'upload.datasource': { + 'Meta': {'ordering': "('-modified', '-created')", 'object_name': 'DataSource'}, + 'classname': ('django.db.models.fields.CharField', [], {'max_length': '32', 'null': 'True'}), + 'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + 'exhibit': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'source'", 'unique': 'True', 'to': u"orm['exhibit.Exhibit']"}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'modified': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}) + }, + u'upload.filedatasource': { + 'Meta': {'object_name': 'FileDataSource', '_ormbases': [u'upload.DataSource']}, + u'datasource_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['upload.DataSource']", 'unique': 'True', 'primary_key': 'True'}), + 'file': ('django.db.models.fields.files.FileField', [], {'max_length': '255'}) + }, + u'upload.jsonfiledatasource': { + 'Meta': {'object_name': 'JSONFileDataSource', '_ormbases': [u'upload.DataSource']}, + u'datasource_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['upload.DataSource']", 'unique': 'True', 'primary_key': 'True'}), + 'file': ('django.db.models.fields.files.FileField', [], {'max_length': '255'}), + 'mapping': ('django.db.models.fields.TextField', [], {}), + 'path': ('django.db.models.fields.TextField', [], {}) + }, + u'upload.jsonurldatasource': { + 'Meta': {'object_name': 'JSONURLDataSource', '_ormbases': [u'upload.DataSource']}, + u'datasource_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['upload.DataSource']", 'unique': 'True', 'primary_key': 'True'}), + 'mapping': ('django.db.models.fields.TextField', [], {}), + 'path': ('django.db.models.fields.TextField', [], {}), + 'url': ('django.db.models.fields.URLField', [], {'max_length': '200'}) + }, + u'upload.modsfiledatasource': { + 'Meta': {'object_name': 'ModsFileDataSource', '_ormbases': [u'upload.DataSource']}, + u'datasource_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['upload.DataSource']", 'unique': 'True', 'primary_key': 'True'}), + 'diagnostics': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'file': ('django.db.models.fields.files.FileField', [], {'max_length': '255'}) + }, + u'upload.modsurldatasource': { + 'Meta': {'object_name': 'ModsURLDataSource', '_ormbases': [u'upload.DataSource']}, + u'datasource_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['upload.DataSource']", 'unique': 'True', 'primary_key': 'True'}), + 'diagnostics': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'url': ('django.db.models.fields.URLField', [], {'max_length': '200'}) + }, + u'upload.oaidatasource': { + 'Meta': {'object_name': 'OAIDataSource', '_ormbases': [u'upload.DataSource']}, + u'datasource_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['upload.DataSource']", 'unique': 'True', 'primary_key': 'True'}), + 'limit': ('django.db.models.fields.IntegerField', [], {'default': "'100'"}), + 'set': ('django.db.models.fields.CharField', [], {'max_length': '255'}), + 'title': ('django.db.models.fields.CharField', [], {'max_length': '255'}), + 'url': ('django.db.models.fields.URLField', [], {'max_length': '200'}) + }, + u'upload.referencedatasource': { + 'Meta': {'ordering': "('-modified', '-created')", 'object_name': 'ReferenceDataSource', '_ormbases': [u'upload.DataSource']}, + u'datasource_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['upload.DataSource']", 'unique': 'True', 'primary_key': 'True'}), + 'referenced': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'references'", 'to': u"orm['exhibit.Exhibit']"}) + }, + u'upload.urldatasource': { + 'Meta': {'object_name': 'URLDataSource', '_ormbases': [u'upload.DataSource']}, + u'datasource_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['upload.DataSource']", 'unique': 'True', 'primary_key': 'True'}), + 'url': ('django.db.models.fields.URLField', [], {'max_length': '200'}) + } + } + + complete_apps = ['upload'] \ No newline at end of file diff --git a/viewshare/apps/upload/models.py b/viewshare/apps/upload/models.py index 6837b79e..1d554f8c 100644 --- a/viewshare/apps/upload/models.py +++ b/viewshare/apps/upload/models.py @@ -1,7 +1,7 @@ import urllib2 import json -from os.path import join, sep +from os.path import join, sep, basename from django.core.files.storage import FileSystemStorage from django.core.urlresolvers import reverse from django.db import models @@ -9,11 +9,11 @@ from django_extensions.db.models import TimeStampedModel from freemix.exhibit.models import Exhibit -from viewshare.apps.legacy.dataset import models as ds_models - -from viewshare.apps.legacy.dataset.transform import AkaraTransformClient +from viewshare.apps.upload.transform import (AkaraTransformClient, + AKARA_TRANSFORM_URL) from viewshare.apps.upload import conf + class DataSource(TimeStampedModel): """ This class should be extended to define the source from which the data in @@ -37,7 +37,7 @@ def is_concrete(self): return self.classname == self.__class__.__name__ -class ReferenceDataSource(ds_models.DataSource): +class ReferenceDataSource(DataSource): """ A Data Source that references another exhibit """ @@ -45,7 +45,6 @@ class ReferenceDataSource(ds_models.DataSource): referenced = models.ForeignKey(Exhibit, related_name="references") - def source_upload_path(instance, filename): return join(instance.uuid, filename) @@ -60,16 +59,82 @@ def url(self, name): fs = ViewshareFileStorage(location=conf.FILE_UPLOAD_PATH) -file_datasource_mixin = ds_models.make_file_data_source_mixin(storage=fs, + +class TransformMixin(models.Model): + """ + Contains the methods and parameters necessary to create a simple data + source that posts to a service and returns the result + """ + + transform = AkaraTransformClient(AKARA_TRANSFORM_URL) + + class Meta: + abstract = True + + def get_transform_params(self): + return {} + + def get_transform_body(self): + return None + + def refresh(self): + return self.transform( + body=self.get_transform_body(), + params=self.get_transform_params()) + + +class URLDataSourceMixin(TransformMixin, models.Model): + + url = models.URLField() + + class Meta: + abstract = True + + def get_transform_body(self): + r = urllib2.urlopen(self.url) + return r.read() + + def __unicode__(self): + return self.url + + +def make_file_data_source_mixin(storage, upload_to): + """ + Generate a mixin for a file based data source allowing for custom + storage and file path. + + storage -- A django FileStorage implementation + upload_to -- the default path for an uploaded file + """ + class FileDataSourceMixin(TransformMixin, models.Model): + file = models.FileField( + storage=storage, + upload_to=upload_to, + max_length=255) + + class Meta: + abstract = True + + def get_transform_body(self): + return self.file.read() + + def get_filename(self): + return basename(self.file.name) + + def __unicode__(self): + return self.file.name + return FileDataSourceMixin + +file_datasource_mixin = make_file_data_source_mixin(storage=fs, upload_to=source_upload_path) -class URLDataSource(ds_models.URLDataSourceMixin, ds_models.DataSource): +class URLDataSource(URLDataSourceMixin, DataSource): """Generic URL data source """ -class FileDataSource(file_datasource_mixin, ds_models.DataSource): +class FileDataSource(file_datasource_mixin, DataSource): """Generic File data source """ @@ -79,7 +144,7 @@ class FileDataSource(file_datasource_mixin, ds_models.DataSource): _limit_help_text_ = _("The maximum number of records to load") -class ContentDMDataSource(ds_models.URLDataSourceMixin, ds_models.DataSource): +class ContentDMDataSource(URLDataSourceMixin, DataSource): """ Data source for loading data from a particular CONTENTdm site based on collection name or query. @@ -120,7 +185,7 @@ def get_transform_body(self): return None -class OAIDataSource(ds_models.URLDataSourceMixin, ds_models.DataSource): +class OAIDataSource(URLDataSourceMixin, DataSource): """Data source for loading an OAI set. """ @@ -152,7 +217,7 @@ def __unicode__(self): return "%s (%s, %s)" % (self.title, self.url, self.set) -class JSONURLDataSource(ds_models.URLDataSourceMixin, ds_models.DataSource): +class JSONURLDataSource(URLDataSourceMixin, DataSource): """Load JSON from a URL """ path = models.TextField(_("Items Array")) @@ -172,7 +237,7 @@ def __unicode__(self): return "%s (%s)" % (self.url, self.path) -class JSONFileDataSource(file_datasource_mixin, ds_models.DataSource): +class JSONFileDataSource(file_datasource_mixin, DataSource): """Load JSON from a file """ path = models.TextField(_("Items Array")) @@ -218,11 +283,11 @@ def get_transform_params(self): return p -class ModsURLDataSource(ModsMixin, ds_models.URLDataSourceMixin, ds_models.DataSource): +class ModsURLDataSource(ModsMixin, URLDataSourceMixin, DataSource): """Load XMLMODS from a URL """ -class ModsFileDataSource(ModsMixin, file_datasource_mixin, ds_models.DataSource): +class ModsFileDataSource(ModsMixin, file_datasource_mixin, DataSource): """Load XMLMODS from an uploaded file """ diff --git a/viewshare/apps/legacy/dataset/transform.py b/viewshare/apps/upload/transform.py similarity index 100% rename from viewshare/apps/legacy/dataset/transform.py rename to viewshare/apps/upload/transform.py diff --git a/viewshare/apps/upload/views.py b/viewshare/apps/upload/views.py index 3a27aed3..c4b2a0ff 100644 --- a/viewshare/apps/upload/views.py +++ b/viewshare/apps/upload/views.py @@ -6,7 +6,7 @@ from django.views.generic.base import View from django.views.generic.edit import CreateView -from viewshare.apps.legacy.dataset.transform import AkaraTransformClient +from viewshare.apps.upload.transform import AkaraTransformClient from viewshare.apps.legacy.dataset.views import DataSourceRegistry from freemix.views import JSONResponse from viewshare.apps.upload import forms, conf diff --git a/viewshare/utilities/views.py b/viewshare/utilities/views.py index 343189e0..a9ce86d8 100644 --- a/viewshare/utilities/views.py +++ b/viewshare/utilities/views.py @@ -9,7 +9,7 @@ from django.template.response import TemplateResponse from django.views.generic.base import RedirectView -from viewshare.apps.legacy.dataset.transform import AKARA_URL_PREFIX +from viewshare.apps.upload.transform import AKARA_URL_PREFIX AKARA_VERSION_URL = getattr(settings, "AKARA_VERSION_URL", urljoin(AKARA_URL_PREFIX, "freemix.loader.revision")) From 4fa235f66b14a4eacafca9cdf73cd7cc0d50ebeb Mon Sep 17 00:00:00 2001 From: David Feeney Date: Tue, 13 Aug 2013 00:57:08 -0400 Subject: [PATCH 134/515] fix migrations to run under mysql --- ...010_rename_slug_title_description_owner.py | 8 +- ...add_delimitedlistproperty__add_exhibitp.py | 4 +- ...ublished_exhibits_for_isolated_datasets.py | 6 +- ...igrate_data_profile_properties_and_data.py | 102 +++++++++++++----- .../migrations/0014_populate_profile.py | 4 +- .../migrations/0015_drop_dataset_reference.py | 4 +- .../0006_create_reference_datasources.py | 27 ++--- .../migrations/0008_migrate_datasources.py | 11 -- .../0009_drop_dataset_datasource_refs.py | 37 +++---- 9 files changed, 123 insertions(+), 80 deletions(-) diff --git a/freemix/exhibit/migrations/0010_rename_slug_title_description_owner.py b/freemix/exhibit/migrations/0010_rename_slug_title_description_owner.py index 570b56a3..beb92fff 100644 --- a/freemix/exhibit/migrations/0010_rename_slug_title_description_owner.py +++ b/freemix/exhibit/migrations/0010_rename_slug_title_description_owner.py @@ -14,8 +14,8 @@ def forwards(self, orm): # Deleting field 'PublishedExhibit.publisher' db.rename_column('exhibit_publishedexhibit', 'publisher_id', 'owner_id') - db.alter_column('exhibit_publishedexhibit', 'owner_id', - self.gf('django.db.models.fields.related.ForeignKey')(blank=True, related_name='published_exhibits', null=True, to=orm['auth.User'])) + #db.alter_column('exhibit_publishedexhibit', 'owner_id', + # self.gf('django.db.models.fields.related.ForeignKey')(blank=True, related_name='published_exhibits', null=True, to=orm['auth.User'])) # Deleting field 'PublishedExhibit.d' db.rename_column('exhibit_publishedexhibit', 'd', 'description') @@ -43,8 +43,8 @@ def backwards(self, orm): # Deleting field 'PublishedExhibit.publisher' db.rename_column('exhibit_publishedexhibit', 'owner_id', 'publisher_id') - db.alter_column('exhibit_publishedexhibit', 'publisher_id', - self.gf('django.db.models.fields.related.ForeignKey')(blank=True, related_name='published_exhibits', null=True, to=orm['auth.User'])) + #db.alter_column('exhibit_publishedexhibit', 'publisher_id', + # self.gf('django.db.models.fields.related.ForeignKey')(blank=True, related_name='published_exhibits', null=True, to=orm['auth.User'])) # Deleting field 'PublishedExhibit.d' db.rename_column('exhibit_publishedexhibit', 'description', 'd') diff --git a/freemix/exhibit/migrations/0011_auto__add_patternlistproperty__add_delimitedlistproperty__add_exhibitp.py b/freemix/exhibit/migrations/0011_auto__add_patternlistproperty__add_delimitedlistproperty__add_exhibitp.py index 41483349..da335bf4 100644 --- a/freemix/exhibit/migrations/0011_auto__add_patternlistproperty__add_delimitedlistproperty__add_exhibitp.py +++ b/freemix/exhibit/migrations/0011_auto__add_patternlistproperty__add_delimitedlistproperty__add_exhibitp.py @@ -160,7 +160,7 @@ def backwards(self, orm): 'json': ('django.db.models.fields.TextField', [], {'default': "'{}'"}) }, 'exhibit.delimitedlistproperty': { - 'Meta': {'object_name': 'DelimitedListProperty'}, + 'Meta': {'object_name': 'DelimitedListProperty', '_ormbases': ['exhibit.ExhibitProperty']}, 'delimiter': ('django.db.models.fields.TextField', [], {}), 'exhibitproperty_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['exhibit.ExhibitProperty']", 'unique': 'True', 'primary_key': 'True'}), 'source': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'+'", 'to': "orm['exhibit.ExhibitProperty']"}) @@ -191,7 +191,7 @@ def backwards(self, orm): 'value_type': ('django.db.models.fields.CharField', [], {'default': "'text'", 'max_length': '10'}) }, 'exhibit.patternlistproperty': { - 'Meta': {'object_name': 'PatternListProperty'}, + 'Meta': {'object_name': 'PatternListProperty', '_ormbases': ['exhibit.ExhibitProperty']}, 'exhibitproperty_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['exhibit.ExhibitProperty']", 'unique': 'True', 'primary_key': 'True'}), 'pattern': ('django.db.models.fields.TextField', [], {}), 'source': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'+'", 'to': "orm['exhibit.ExhibitProperty']"}) diff --git a/freemix/exhibit/migrations/0012_published_exhibits_for_isolated_datasets.py b/freemix/exhibit/migrations/0012_published_exhibits_for_isolated_datasets.py index ec705ce7..5e2ec2a5 100644 --- a/freemix/exhibit/migrations/0012_published_exhibits_for_isolated_datasets.py +++ b/freemix/exhibit/migrations/0012_published_exhibits_for_isolated_datasets.py @@ -25,6 +25,8 @@ def forwards(self, orm): dataset=ds) exhibit.save() + orm.Exhibit.objects.filter(dataset=None).delete() + def backwards(self, orm): "Write your backwards methods here." @@ -97,7 +99,7 @@ def backwards(self, orm): 'json': ('django.db.models.fields.TextField', [], {'default': "'{}'"}) }, 'exhibit.delimitedlistproperty': { - 'Meta': {'object_name': 'DelimitedListProperty'}, + 'Meta': {'object_name': 'DelimitedListProperty', '_ormbases': ['exhibit.ExhibitProperty']}, 'delimiter': ('django.db.models.fields.TextField', [], {}), 'exhibitproperty_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['exhibit.ExhibitProperty']", 'unique': 'True', 'primary_key': 'True'}), 'source': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'+'", 'to': "orm['exhibit.ExhibitProperty']"}) @@ -128,7 +130,7 @@ def backwards(self, orm): 'value_type': ('django.db.models.fields.CharField', [], {'default': "'text'", 'max_length': '10'}) }, 'exhibit.patternlistproperty': { - 'Meta': {'object_name': 'PatternListProperty'}, + 'Meta': {'object_name': 'PatternListProperty', '_ormbases': ['exhibit.ExhibitProperty']}, 'exhibitproperty_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['exhibit.ExhibitProperty']", 'unique': 'True', 'primary_key': 'True'}), 'pattern': ('django.db.models.fields.TextField', [], {}), 'source': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'+'", 'to': "orm['exhibit.ExhibitProperty']"}) diff --git a/freemix/exhibit/migrations/0013_migrate_data_profile_properties_and_data.py b/freemix/exhibit/migrations/0013_migrate_data_profile_properties_and_data.py index d5f722ef..0c52aa09 100644 --- a/freemix/exhibit/migrations/0013_migrate_data_profile_properties_and_data.py +++ b/freemix/exhibit/migrations/0013_migrate_data_profile_properties_and_data.py @@ -7,18 +7,38 @@ def find_type(p): for t in ["location", "text", "image", "date", "url", "number"]: - if "property:type=%s"%t in p["tags"]: + if "tags" in p.keys() and "property:type=%s"%t in p["tags"]: return t return "text" +def create_property(orm, properties, exhibit, name): + prop = orm.ExhibitProperty(classname="ExhibitProperty", + name=name, + label=name, + value_type="text", + exhibit=exhibit) + prop.save() + properties[name] = prop + return prop + + class Migration(DataMigration): def forwards(self, orm): - # Migrate Dataset's json files into the new exhibit data model for exhibit in orm.Exhibit.objects.all(): + + # Create a dummy place holder property + + dummy = orm.ExhibitProperty(exhibit = exhibit, + name="dummy_for_south_migration", + label="dummy_for_south_migration", + value_type="text", + classname="ExhibitProperty") + dummy.save() + dataset = exhibit.dataset data = orm["dataset.datasetjsonfile"].objects.get(dataset=dataset).data profile = orm["dataset.datasetprofile"].objects.get(dataset=dataset).data @@ -28,31 +48,47 @@ def forwards(self, orm): properties = {} second_pass = [] for p in profile["properties"]: + + # Do a first run through the properties to # ensure that all properties exist before # creating references k = p.keys() + kw = {} value_type = find_type(p) name = p["property"] label = p["label"] + if name in properties.keys(): + print("Duplicate property: %s in %d" % (name, exhibit.id)) + continue + + if "composite" in k: classname = "CompositeProperty" + + cl = orm.CompositeProperty second_pass.append(p) elif "delimiter" in k: + cl = orm.DelimitedListProperty classname = "DelimitedListProperty" second_pass.append(p) + kw["source"] = dummy elif "pattern" in k: + cl = orm.PatternListProperty classname = "PatternListProperty" second_pass.append(p) + kw["source"] = dummy + else: + cl = orm.ExhibitProperty classname="ExhibitProperty" - - prop = orm.ExhibitProperty(exhibit=exhibit, - name=name, - label=label, - value_type=value_type, - classname=classname) + prop = cl(exhibit=exhibit, + name=name, + label=label, + value_type=value_type, + classname=classname, + **kw) prop.save() properties[name] = prop @@ -60,34 +96,50 @@ def forwards(self, orm): # Now create the extension objects for augmented properties prop = properties[p["property"]] - + k = p.keys() if "composite" in k: - ext = orm.CompositeProperty(exhibitproperty_ptr=prop) - ext.__dict__ = prop.__dict__ - ext.save() counter = 1 for c in p["composite"]: - ref = orm.PropertyReference(derived=ext, + + if not c in properties.keys(): + print("Property %s not found for Composite property in exhibit %d" % (c, exhibit.id)) + + create_property(orm, properties, exhibit, c) + ref = orm.PropertyReference(derived=prop, source=properties[c], order=counter) counter += 1 ref.save() + elif "delimiter" in k: - ext = orm.DelimitedListProperty(exhibitproperty_ptr=prop, - source=properties[p["extract"]], - delimiter=p["delimiter"]) - ext.__dict__ = prop.__dict__ - ext.save() + + if not p["extract"] in properties.keys(): + print ("Property %s not found for delimiter source in exhibit %d" % (p["extract"], exhibit.id)) + create_property(orm, properties, exhibit, p["extract"]) + prop.source = properties[p["extract"]] + prop.delimiter = p["delimiter"] + prop.save() + + elif "pattern" in k: - ext = orm.PatternListProperty(exhibitproperty_ptr=prop, - source=properties[p["extract"]], - pattern=p["pattern"]) - ext.__dict__ = prop.__dict__ - ext.save() + + if not p["extract"] in properties.keys(): + + print ("Property %s not found for pattern source in exhibit %d" % (p["extract"], exhibit.id)) + create_property(orm, properties, exhibit, p["extract"]) + + prop.source = properties[p["extract"]] + prop.pattern = p["pattern"] + prop.save() + + + dummy.delete() + exhibit.save() + def backwards(self, orm): "Write your backwards methods here." @@ -172,7 +224,7 @@ def backwards(self, orm): 'json': ('django.db.models.fields.TextField', [], {'default': "'{}'"}) }, 'exhibit.delimitedlistproperty': { - 'Meta': {'object_name': 'DelimitedListProperty'}, + 'Meta': {'object_name': 'DelimitedListProperty', '_ormbases': ['exhibit.ExhibitProperty']}, 'delimiter': ('django.db.models.fields.TextField', [], {}), 'exhibitproperty_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['exhibit.ExhibitProperty']", 'unique': 'True', 'primary_key': 'True'}), 'source': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'+'", 'to': "orm['exhibit.ExhibitProperty']"}) @@ -203,7 +255,7 @@ def backwards(self, orm): 'value_type': ('django.db.models.fields.CharField', [], {'default': "'text'", 'max_length': '10'}) }, 'exhibit.patternlistproperty': { - 'Meta': {'object_name': 'PatternListProperty'}, + 'Meta': {'object_name': 'PatternListProperty', '_ormbases': ['exhibit.ExhibitProperty']}, 'exhibitproperty_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['exhibit.ExhibitProperty']", 'unique': 'True', 'primary_key': 'True'}), 'pattern': ('django.db.models.fields.TextField', [], {}), 'source': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'+'", 'to': "orm['exhibit.ExhibitProperty']"}) diff --git a/freemix/exhibit/migrations/0014_populate_profile.py b/freemix/exhibit/migrations/0014_populate_profile.py index ee1642f1..68d05278 100644 --- a/freemix/exhibit/migrations/0014_populate_profile.py +++ b/freemix/exhibit/migrations/0014_populate_profile.py @@ -103,7 +103,7 @@ def backwards(self, orm): 'json': ('django.db.models.fields.TextField', [], {'default': "'{}'"}) }, 'exhibit.delimitedlistproperty': { - 'Meta': {'object_name': 'DelimitedListProperty'}, + 'Meta': {'object_name': 'DelimitedListProperty', '_ormbases': ['exhibit.ExhibitProperty']}, 'delimiter': ('django.db.models.fields.TextField', [], {}), 'exhibitproperty_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['exhibit.ExhibitProperty']", 'unique': 'True', 'primary_key': 'True'}), 'source': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'+'", 'to': "orm['exhibit.ExhibitProperty']"}) @@ -134,7 +134,7 @@ def backwards(self, orm): 'value_type': ('django.db.models.fields.CharField', [], {'default': "'text'", 'max_length': '10'}) }, 'exhibit.patternlistproperty': { - 'Meta': {'object_name': 'PatternListProperty'}, + 'Meta': {'object_name': 'PatternListProperty', '_ormbases': ['exhibit.ExhibitProperty']}, 'exhibitproperty_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['exhibit.ExhibitProperty']", 'unique': 'True', 'primary_key': 'True'}), 'pattern': ('django.db.models.fields.TextField', [], {}), 'source': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'+'", 'to': "orm['exhibit.ExhibitProperty']"}) diff --git a/freemix/exhibit/migrations/0015_drop_dataset_reference.py b/freemix/exhibit/migrations/0015_drop_dataset_reference.py index f11b179a..165aef0a 100644 --- a/freemix/exhibit/migrations/0015_drop_dataset_reference.py +++ b/freemix/exhibit/migrations/0015_drop_dataset_reference.py @@ -81,7 +81,7 @@ def backwards(self, orm): 'json': ('django.db.models.fields.TextField', [], {'default': "'{}'"}) }, u'exhibit.delimitedlistproperty': { - 'Meta': {'object_name': 'DelimitedListProperty'}, + 'Meta': {'object_name': 'DelimitedListProperty', '_ormbases': ['exhibit.ExhibitProperty']}, 'delimiter': ('django.db.models.fields.TextField', [], {}), u'exhibitproperty_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['exhibit.ExhibitProperty']", 'unique': 'True', 'primary_key': 'True'}), 'source': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'+'", 'to': u"orm['exhibit.ExhibitProperty']"}) @@ -111,7 +111,7 @@ def backwards(self, orm): 'value_type': ('django.db.models.fields.CharField', [], {'default': "'text'", 'max_length': '10'}) }, u'exhibit.patternlistproperty': { - 'Meta': {'object_name': 'PatternListProperty'}, + 'Meta': {'object_name': 'PatternListProperty', '_ormbases': ['exhibit.ExhibitProperty']}, u'exhibitproperty_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['exhibit.ExhibitProperty']", 'unique': 'True', 'primary_key': 'True'}), 'pattern': ('django.db.models.fields.TextField', [], {}), 'source': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'+'", 'to': u"orm['exhibit.ExhibitProperty']"}) diff --git a/viewshare/apps/upload/migrations/0006_create_reference_datasources.py b/viewshare/apps/upload/migrations/0006_create_reference_datasources.py index 8fec7c07..aa91f92d 100644 --- a/viewshare/apps/upload/migrations/0006_create_reference_datasources.py +++ b/viewshare/apps/upload/migrations/0006_create_reference_datasources.py @@ -3,7 +3,7 @@ from south.db import db from south.v2 import DataMigration from django.db import models - +from django.db.models.base import ObjectDoesNotExist class Migration(DataMigration): depends_on = ( @@ -19,17 +19,20 @@ def forwards(self, orm): ds = e.dataset if ds is None: continue - ref = ds.source - if ref is None: - continue - source = orm['upload.ReferenceDataSource']( - referenced=ref.exhibit, - classname="ReferenceDataSource", - exhibit=e, - created=e.created, - modified=e.modified - ) - source.save() + try: + ref = ds.source + if ref is None: + continue + source = orm['upload.ReferenceDataSource']( + referenced=ref.exhibit, + classname="ReferenceDataSource", + exhibit=e, + created=e.created, + modified=e.modified + ) + source.save() + except ObjectDoesNotExist: + pass def backwards(self, orm): diff --git a/viewshare/apps/upload/migrations/0008_migrate_datasources.py b/viewshare/apps/upload/migrations/0008_migrate_datasources.py index 3650c39e..226d0124 100644 --- a/viewshare/apps/upload/migrations/0008_migrate_datasources.py +++ b/viewshare/apps/upload/migrations/0008_migrate_datasources.py @@ -17,17 +17,6 @@ ) -def migrate_datasource(ds): - source = orm["upload.DataSource"]( - classname=ds.classname, - created=ds.created, - exhibit=ds.exhibit, - modified=ds.modified - ) - source.save() - ds.new_ds_ptr=source - ds.save() - class Migration(DataMigration): def forwards(self, orm): diff --git a/viewshare/apps/upload/migrations/0009_drop_dataset_datasource_refs.py b/viewshare/apps/upload/migrations/0009_drop_dataset_datasource_refs.py index 7247ad84..8d73f2c9 100644 --- a/viewshare/apps/upload/migrations/0009_drop_dataset_datasource_refs.py +++ b/viewshare/apps/upload/migrations/0009_drop_dataset_datasource_refs.py @@ -13,66 +13,63 @@ def forwards(self, orm): # Changing field 'ModsURLDataSource.new_ds_ptr' - db.alter_column(u'upload_modsurldatasource', 'new_ds_ptr_id', self.gf('django.db.models.fields.related.OneToOneField')(default=0, to=orm['upload.DataSource'], unique=True, primary_key=True)) + db.alter_column(u'upload_modsurldatasource', 'new_ds_ptr_id', self.gf('django.db.models.fields.related.OneToOneField')(to=orm['upload.DataSource'], unique=True, primary_key=True)) # Deleting field 'OAIDataSource.datasource_ptr' db.delete_column(u'upload_oaidatasource', u'datasource_ptr_id') # Changing field 'OAIDataSource.new_ds_ptr' - db.alter_column(u'upload_oaidatasource', 'new_ds_ptr_id', self.gf('django.db.models.fields.related.OneToOneField')(default=0, to=orm['upload.DataSource'], unique=True, primary_key=True)) + db.alter_column(u'upload_oaidatasource', 'new_ds_ptr_id', self.gf('django.db.models.fields.related.OneToOneField')(to=orm['upload.DataSource'], unique=True, primary_key=True)) # Deleting field 'URLDataSource.datasource_ptr' db.delete_column(u'upload_urldatasource', u'datasource_ptr_id') # Changing field 'URLDataSource.new_ds_ptr' - db.alter_column(u'upload_urldatasource', 'new_ds_ptr_id', self.gf('django.db.models.fields.related.OneToOneField')(default=0, to=orm['upload.DataSource'], unique=True, primary_key=True)) + db.alter_column(u'upload_urldatasource', 'new_ds_ptr_id', self.gf('django.db.models.fields.related.OneToOneField')(to=orm['upload.DataSource'], unique=True, primary_key=True)) # Deleting field 'JSONFileDataSource.datasource_ptr' db.delete_column(u'upload_jsonfiledatasource', u'datasource_ptr_id') # Changing field 'JSONFileDataSource.new_ds_ptr' - db.alter_column(u'upload_jsonfiledatasource', 'new_ds_ptr_id', self.gf('django.db.models.fields.related.OneToOneField')(default=0, to=orm['upload.DataSource'], unique=True, primary_key=True)) + db.alter_column(u'upload_jsonfiledatasource', 'new_ds_ptr_id', self.gf('django.db.models.fields.related.OneToOneField')(to=orm['upload.DataSource'], unique=True, primary_key=True)) # Deleting field 'ContentDMDataSource.datasource_ptr' db.delete_column(u'upload_contentdmdatasource', u'datasource_ptr_id') # Changing field 'ContentDMDataSource.new_ds_ptr' - db.alter_column(u'upload_contentdmdatasource', 'new_ds_ptr_id', self.gf('django.db.models.fields.related.OneToOneField')(default=0, to=orm['upload.DataSource'], unique=True, primary_key=True)) + db.alter_column(u'upload_contentdmdatasource', 'new_ds_ptr_id', self.gf('django.db.models.fields.related.OneToOneField')(to=orm['upload.DataSource'], unique=True, primary_key=True)) # Deleting field 'JSONURLDataSource.datasource_ptr' db.delete_column(u'upload_jsonurldatasource', u'datasource_ptr_id') # Changing field 'JSONURLDataSource.new_ds_ptr' - db.alter_column(u'upload_jsonurldatasource', 'new_ds_ptr_id', self.gf('django.db.models.fields.related.OneToOneField')(default=0, to=orm['upload.DataSource'], unique=True, primary_key=True)) + db.alter_column(u'upload_jsonurldatasource', 'new_ds_ptr_id', self.gf('django.db.models.fields.related.OneToOneField')(to=orm['upload.DataSource'], unique=True, primary_key=True)) # Deleting field 'FileDataSource.datasource_ptr' db.delete_column(u'upload_filedatasource', u'datasource_ptr_id') # Changing field 'FileDataSource.new_ds_ptr' - db.alter_column(u'upload_filedatasource', 'new_ds_ptr_id', self.gf('django.db.models.fields.related.OneToOneField')(default=0, to=orm['upload.DataSource'], unique=True, primary_key=True)) + db.alter_column(u'upload_filedatasource', 'new_ds_ptr_id', self.gf('django.db.models.fields.related.OneToOneField')(to=orm['upload.DataSource'], unique=True, primary_key=True)) # Deleting field 'ModsFileDataSource.datasource_ptr' db.delete_column(u'upload_modsfiledatasource', u'datasource_ptr_id') # Changing field 'ModsFileDataSource.new_ds_ptr' - db.alter_column(u'upload_modsfiledatasource', 'new_ds_ptr_id', self.gf('django.db.models.fields.related.OneToOneField')(default=0, to=orm['upload.DataSource'], unique=True, primary_key=True)) + db.alter_column(u'upload_modsfiledatasource', 'new_ds_ptr_id', self.gf('django.db.models.fields.related.OneToOneField')(to=orm['upload.DataSource'], unique=True, primary_key=True)) # Deleting field 'ReferenceDataSource.datasource_ptr' db.delete_column(u'upload_referencedatasource', u'datasource_ptr_id') # Changing field 'ReferenceDataSource.new_ds_ptr' - db.alter_column(u'upload_referencedatasource', 'new_ds_ptr_id', self.gf('django.db.models.fields.related.OneToOneField')(default=0, to=orm['upload.DataSource'], unique=True, primary_key=True)) + db.alter_column(u'upload_referencedatasource', 'new_ds_ptr_id', self.gf('django.db.models.fields.related.OneToOneField')(to=orm['upload.DataSource'], unique=True, primary_key=True)) def backwards(self, orm): - # User chose to not deal with backwards NULL issues for 'ModsURLDataSource.datasource_ptr' - raise RuntimeError("Cannot reverse this migration. 'ModsURLDataSource.datasource_ptr' and its values cannot be restored.") - # Changing field 'ModsURLDataSource.new_ds_ptr' db.alter_column(u'upload_modsurldatasource', u'new_ds_ptr_id', self.gf('django.db.models.fields.related.OneToOneField')(to=orm['upload.DataSource'], unique=True, null=True)) # Adding field 'OAIDataSource.datasource_ptr' db.add_column(u'upload_oaidatasource', u'datasource_ptr', - self.gf('django.db.models.fields.related.OneToOneField')(default=0, to=orm['dataset.DataSource'], unique=True, primary_key=True), + self.gf('django.db.models.fields.related.OneToOneField')(to=orm['dataset.DataSource'], unique=True, primary_key=True), keep_default=False) @@ -80,7 +77,7 @@ def backwards(self, orm): db.alter_column(u'upload_oaidatasource', u'new_ds_ptr_id', self.gf('django.db.models.fields.related.OneToOneField')(to=orm['upload.DataSource'], unique=True, null=True)) # Adding field 'URLDataSource.datasource_ptr' db.add_column(u'upload_urldatasource', u'datasource_ptr', - self.gf('django.db.models.fields.related.OneToOneField')(default=0, to=orm['dataset.DataSource'], unique=True, primary_key=True), + self.gf('django.db.models.fields.related.OneToOneField')(to=orm['dataset.DataSource'], unique=True, primary_key=True), keep_default=False) @@ -88,7 +85,7 @@ def backwards(self, orm): db.alter_column(u'upload_urldatasource', u'new_ds_ptr_id', self.gf('django.db.models.fields.related.OneToOneField')(to=orm['upload.DataSource'], unique=True, null=True)) # Adding field 'JSONFileDataSource.datasource_ptr' db.add_column(u'upload_jsonfiledatasource', u'datasource_ptr', - self.gf('django.db.models.fields.related.OneToOneField')(default=0, to=orm['dataset.DataSource'], unique=True, primary_key=True), + self.gf('django.db.models.fields.related.OneToOneField')(to=orm['dataset.DataSource'], unique=True, primary_key=True), keep_default=False) @@ -96,7 +93,7 @@ def backwards(self, orm): db.alter_column(u'upload_jsonfiledatasource', u'new_ds_ptr_id', self.gf('django.db.models.fields.related.OneToOneField')(to=orm['upload.DataSource'], unique=True, null=True)) # Adding field 'ContentDMDataSource.datasource_ptr' db.add_column(u'upload_contentdmdatasource', u'datasource_ptr', - self.gf('django.db.models.fields.related.OneToOneField')(default=0, to=orm['dataset.DataSource'], unique=True, primary_key=True), + self.gf('django.db.models.fields.related.OneToOneField')(to=orm['dataset.DataSource'], unique=True, primary_key=True), keep_default=False) @@ -104,7 +101,7 @@ def backwards(self, orm): db.alter_column(u'upload_contentdmdatasource', u'new_ds_ptr_id', self.gf('django.db.models.fields.related.OneToOneField')(to=orm['upload.DataSource'], unique=True, null=True)) # Adding field 'JSONURLDataSource.datasource_ptr' db.add_column(u'upload_jsonurldatasource', u'datasource_ptr', - self.gf('django.db.models.fields.related.OneToOneField')(default=0, to=orm['dataset.DataSource'], unique=True, primary_key=True), + self.gf('django.db.models.fields.related.OneToOneField')(to=orm['dataset.DataSource'], unique=True, primary_key=True), keep_default=False) @@ -112,7 +109,7 @@ def backwards(self, orm): db.alter_column(u'upload_jsonurldatasource', u'new_ds_ptr_id', self.gf('django.db.models.fields.related.OneToOneField')(to=orm['upload.DataSource'], unique=True, null=True)) # Adding field 'FileDataSource.datasource_ptr' db.add_column(u'upload_filedatasource', u'datasource_ptr', - self.gf('django.db.models.fields.related.OneToOneField')(default=0, to=orm['dataset.DataSource'], unique=True, primary_key=True), + self.gf('django.db.models.fields.related.OneToOneField')(to=orm['dataset.DataSource'], unique=True, primary_key=True), keep_default=False) @@ -120,7 +117,7 @@ def backwards(self, orm): db.alter_column(u'upload_filedatasource', u'new_ds_ptr_id', self.gf('django.db.models.fields.related.OneToOneField')(to=orm['upload.DataSource'], unique=True, null=True)) # Adding field 'ModsFileDataSource.datasource_ptr' db.add_column(u'upload_modsfiledatasource', u'datasource_ptr', - self.gf('django.db.models.fields.related.OneToOneField')(default=0, to=orm['dataset.DataSource'], unique=True, primary_key=True), + self.gf('django.db.models.fields.related.OneToOneField')(to=orm['dataset.DataSource'], unique=True, primary_key=True), keep_default=False) @@ -128,7 +125,7 @@ def backwards(self, orm): db.alter_column(u'upload_modsfiledatasource', u'new_ds_ptr_id', self.gf('django.db.models.fields.related.OneToOneField')(to=orm['upload.DataSource'], unique=True, null=True)) # Adding field 'ReferenceDataSource.datasource_ptr' db.add_column(u'upload_referencedatasource', u'datasource_ptr', - self.gf('django.db.models.fields.related.OneToOneField')(default=0, to=orm['dataset.DataSource'], unique=True, primary_key=True), + self.gf('django.db.models.fields.related.OneToOneField')(to=orm['dataset.DataSource'], unique=True, primary_key=True), keep_default=False) From fa135c14893ad17b056dabf0ed702bb1e9d15be1 Mon Sep 17 00:00:00 2001 From: David Feeney Date: Tue, 13 Aug 2013 01:07:08 -0400 Subject: [PATCH 135/515] move exhibit owner and slug into base class --- .../0016_exhibit_base_owner_slug.py | 152 +++++++++++++++++ .../0017_migrate_owner_slug_to_base.py | 150 +++++++++++++++++ .../migrations/0018_drop_owner_slug.py | 155 ++++++++++++++++++ .../migrations/0019_rename_temp_fields.py | 150 +++++++++++++++++ freemix/exhibit/models.py | 30 ++-- freemix/exhibit/views.py | 3 - freemix/permissions.py | 50 +----- 7 files changed, 629 insertions(+), 61 deletions(-) create mode 100644 freemix/exhibit/migrations/0016_exhibit_base_owner_slug.py create mode 100644 freemix/exhibit/migrations/0017_migrate_owner_slug_to_base.py create mode 100644 freemix/exhibit/migrations/0018_drop_owner_slug.py create mode 100644 freemix/exhibit/migrations/0019_rename_temp_fields.py diff --git a/freemix/exhibit/migrations/0016_exhibit_base_owner_slug.py b/freemix/exhibit/migrations/0016_exhibit_base_owner_slug.py new file mode 100644 index 00000000..2fc50301 --- /dev/null +++ b/freemix/exhibit/migrations/0016_exhibit_base_owner_slug.py @@ -0,0 +1,152 @@ +# -*- coding: 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 field 'Exhibit.o' + db.add_column(u'exhibit_exhibit', 'o', + self.gf('django.db.models.fields.related.ForeignKey')(to=orm['auth.User'], null=True), + keep_default=False) + + # Adding field 'Exhibit.s' + db.add_column(u'exhibit_exhibit', 's', + self.gf('django.db.models.fields.SlugField')(default='-', max_length=50, blank=True), + keep_default=False) + + # Adding field 'Exhibit.is_draft' + db.add_column(u'exhibit_exhibit', 'is_draft', + self.gf('django.db.models.fields.BooleanField')(default=True), + keep_default=False) + + def backwards(self, orm): + + # Deleting field 'Exhibit.o' + db.delete_column(u'exhibit_exhibit', 'o_id') + + # Deleting field 'Exhibit.s' + db.delete_column(u'exhibit_exhibit', 's') + + # Deleting field 'Exhibit.is_draft' + db.delete_column(u'exhibit_exhibit', 'is_draft') + + + models = { + u'auth.group': { + 'Meta': {'object_name': 'Group'}, + u'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': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}) + }, + u'auth.permission': { + 'Meta': {'ordering': "(u'content_type__app_label', u'content_type__model', u'codename')", 'unique_together': "((u'content_type', u'codename'),)", 'object_name': 'Permission'}, + 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['contenttypes.ContentType']"}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}) + }, + u'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': u"orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + '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': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}), + 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'}) + }, + u'contenttypes.contenttype': { + 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"}, + 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + u'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'}) + }, + u'exhibit.canvas': { + 'Meta': {'object_name': 'Canvas'}, + 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'enabled': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'location': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '100'}), + 'slug': ('django_extensions.db.fields.AutoSlugField', [], {'allow_duplicates': 'False', 'max_length': '50', 'separator': "u'-'", 'blank': 'True', 'populate_from': "'title'", 'overwrite': 'False'}), + 'thumbnail': ('django.db.models.fields.URLField', [], {'max_length': '200'}), + 'title': ('django.db.models.fields.CharField', [], {'max_length': '255'}) + }, + u'exhibit.compositeproperty': { + 'Meta': {'object_name': 'CompositeProperty', '_ormbases': [u'exhibit.ExhibitProperty']}, + u'exhibitproperty_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['exhibit.ExhibitProperty']", 'unique': 'True', 'primary_key': 'True'}) + }, + u'exhibit.datajsonfile': { + 'Meta': {'object_name': 'DataJSONFile'}, + 'exhibit': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'data'", 'unique': 'True', 'to': u"orm['exhibit.Exhibit']"}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'json': ('django.db.models.fields.TextField', [], {'default': "'{}'"}) + }, + u'exhibit.delimitedlistproperty': { + 'Meta': {'object_name': 'DelimitedListProperty', '_ormbases': ['exhibit.ExhibitProperty']}, + 'delimiter': ('django.db.models.fields.TextField', [], {}), + u'exhibitproperty_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['exhibit.ExhibitProperty']", 'unique': 'True', 'primary_key': 'True'}), + 'source': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'+'", 'to': u"orm['exhibit.ExhibitProperty']"}) + }, + u'exhibit.draftexhibit': { + 'Meta': {'ordering': "('-modified',)", 'object_name': 'DraftExhibit', '_ormbases': [u'exhibit.Exhibit']}, + u'exhibit_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['exhibit.Exhibit']", 'unique': 'True', 'primary_key': 'True'}), + 'owner': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'draft_exhibits'", 'null': 'True', 'to': u"orm['auth.User']"}), + 'parent': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['exhibit.PublishedExhibit']", 'null': 'True', 'blank': 'True'}), + 'uuid': ('django.db.models.fields.CharField', [], {'max_length': '36', 'blank': 'True'}) + }, + u'exhibit.exhibit': { + 'Meta': {'object_name': 'Exhibit'}, + 'canvas': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['exhibit.Canvas']"}), + 'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'is_draft': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'modified': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + 'o': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['auth.User']", 'null': 'True'}), + 'profile': ('django.db.models.fields.TextField', [], {'default': "'{}'"}), + 's': ('django.db.models.fields.SlugField', [], {'max_length': '50', 'blank': 'True'}) + }, + u'exhibit.exhibitproperty': { + 'Meta': {'unique_together': "(('exhibit', 'name'),)", 'object_name': 'ExhibitProperty'}, + 'classname': ('django.db.models.fields.CharField', [], {'max_length': '32', 'null': 'True'}), + 'exhibit': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'properties'", 'to': u"orm['exhibit.Exhibit']"}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'label': ('django.db.models.fields.CharField', [], {'max_length': '255'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '255'}), + 'value_type': ('django.db.models.fields.CharField', [], {'default': "'text'", 'max_length': '10'}) + }, + u'exhibit.patternlistproperty': { + 'Meta': {'object_name': 'PatternListProperty', '_ormbases': ['exhibit.ExhibitProperty']}, + u'exhibitproperty_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['exhibit.ExhibitProperty']", 'unique': 'True', 'primary_key': 'True'}), + 'pattern': ('django.db.models.fields.TextField', [], {}), + 'source': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'+'", 'to': u"orm['exhibit.ExhibitProperty']"}) + }, + u'exhibit.propertyreference': { + 'Meta': {'ordering': "('order',)", 'unique_together': "(('derived', 'source'),)", 'object_name': 'PropertyReference'}, + 'derived': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'properties'", 'to': u"orm['exhibit.CompositeProperty']"}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'order': ('django.db.models.fields.PositiveSmallIntegerField', [], {}), + 'source': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['exhibit.ExhibitProperty']"}) + }, + u'exhibit.publishedexhibit': { + 'Meta': {'ordering': "('-modified',)", 'unique_together': "(('slug', 'owner'),)", 'object_name': 'PublishedExhibit', '_ormbases': [u'exhibit.Exhibit']}, + 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + u'exhibit_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['exhibit.Exhibit']", 'unique': 'True', 'primary_key': 'True'}), + 'is_public': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'owner': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'published_exhibits'", 'null': 'True', 'to': u"orm['auth.User']"}), + 'slug': ('django_extensions.db.fields.AutoSlugField', [], {'allow_duplicates': 'False', 'max_length': '50', 'separator': "u'-'", 'blank': 'True', 'populate_from': "'title'", 'overwrite': 'False'}), + 'title': ('django.db.models.fields.CharField', [], {'max_length': '255'}) + } + } + + complete_apps = ['exhibit'] \ No newline at end of file diff --git a/freemix/exhibit/migrations/0017_migrate_owner_slug_to_base.py b/freemix/exhibit/migrations/0017_migrate_owner_slug_to_base.py new file mode 100644 index 00000000..74a93ad6 --- /dev/null +++ b/freemix/exhibit/migrations/0017_migrate_owner_slug_to_base.py @@ -0,0 +1,150 @@ +# -*- coding: utf-8 -*- +import datetime +from south.db import db +from south.v2 import DataMigration +from django.db import models + +class Migration(DataMigration): + + def forwards(self, orm): + + for exhibit in orm.PublishedExhibit.objects.all(): + exhibit.o = exhibit.owner + exhibit.s = exhibit.slug + exhibit.is_draft=False + exhibit.save() + + for exhibit in orm.DraftExhibit.objects.all(): + exhibit.o = exhibit.owner + exhibit.s = exhibit.uuid + exhibit.is_draft=True + exhibit.save() + + def backwards(self, orm): + + for exhibit in orm.PublishedExhibit.objects.all(): + exhibit.owner = exhibit.o + exhibit.slug = exhibit.s + exhibit.save() + + for exhibit in orm.DraftExhibit.objects.all(): + exhibit.owner = exhibit.o + exhibit.uuid = exhibit.s + exhibit.save() + + models = { + u'auth.group': { + 'Meta': {'object_name': 'Group'}, + u'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': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}) + }, + u'auth.permission': { + 'Meta': {'ordering': "(u'content_type__app_label', u'content_type__model', u'codename')", 'unique_together': "((u'content_type', u'codename'),)", 'object_name': 'Permission'}, + 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['contenttypes.ContentType']"}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}) + }, + u'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': u"orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + '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': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}), + 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'}) + }, + u'contenttypes.contenttype': { + 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"}, + 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + u'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'}) + }, + u'exhibit.canvas': { + 'Meta': {'object_name': 'Canvas'}, + 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'enabled': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'location': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '100'}), + 'slug': ('django_extensions.db.fields.AutoSlugField', [], {'allow_duplicates': 'False', 'max_length': '50', 'separator': "u'-'", 'blank': 'True', 'populate_from': "'title'", 'overwrite': 'False'}), + 'thumbnail': ('django.db.models.fields.URLField', [], {'max_length': '200'}), + 'title': ('django.db.models.fields.CharField', [], {'max_length': '255'}) + }, + u'exhibit.compositeproperty': { + 'Meta': {'object_name': 'CompositeProperty', '_ormbases': [u'exhibit.ExhibitProperty']}, + u'exhibitproperty_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['exhibit.ExhibitProperty']", 'unique': 'True', 'primary_key': 'True'}) + }, + u'exhibit.datajsonfile': { + 'Meta': {'object_name': 'DataJSONFile'}, + 'exhibit': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'data'", 'unique': 'True', 'to': u"orm['exhibit.Exhibit']"}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'json': ('django.db.models.fields.TextField', [], {'default': "'{}'"}) + }, + u'exhibit.delimitedlistproperty': { + 'Meta': {'object_name': 'DelimitedListProperty', '_ormbases': ['exhibit.ExhibitProperty']}, + 'delimiter': ('django.db.models.fields.TextField', [], {}), + u'exhibitproperty_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['exhibit.ExhibitProperty']", 'unique': 'True', 'primary_key': 'True'}), + 'source': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'+'", 'to': u"orm['exhibit.ExhibitProperty']"}) + }, + u'exhibit.draftexhibit': { + 'Meta': {'ordering': "('-modified',)", 'object_name': 'DraftExhibit', '_ormbases': [u'exhibit.Exhibit']}, + u'exhibit_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['exhibit.Exhibit']", 'unique': 'True', 'primary_key': 'True'}), + 'owner': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'draft_exhibits'", 'null': 'True', 'to': u"orm['auth.User']"}), + 'parent': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['exhibit.PublishedExhibit']", 'null': 'True', 'blank': 'True'}), + 'uuid': ('django.db.models.fields.CharField', [], {'max_length': '36', 'blank': 'True'}) + }, + u'exhibit.exhibit': { + 'Meta': {'object_name': 'Exhibit'}, + 'canvas': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['exhibit.Canvas']"}), + 'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'is_draft': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'modified': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + 'o': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['auth.User']", 'null': 'True'}), + 'profile': ('django.db.models.fields.TextField', [], {'default': "'{}'"}), + 's': ('django.db.models.fields.SlugField', [], {'max_length': '50', 'blank': 'True'}) + }, + u'exhibit.exhibitproperty': { + 'Meta': {'unique_together': "(('exhibit', 'name'),)", 'object_name': 'ExhibitProperty'}, + 'classname': ('django.db.models.fields.CharField', [], {'max_length': '32', 'null': 'True'}), + 'exhibit': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'properties'", 'to': u"orm['exhibit.Exhibit']"}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'label': ('django.db.models.fields.CharField', [], {'max_length': '255'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '255'}), + 'value_type': ('django.db.models.fields.CharField', [], {'default': "'text'", 'max_length': '10'}) + }, + u'exhibit.patternlistproperty': { + 'Meta': {'object_name': 'PatternListProperty', '_ormbases': ['exhibit.ExhibitProperty']}, + u'exhibitproperty_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['exhibit.ExhibitProperty']", 'unique': 'True', 'primary_key': 'True'}), + 'pattern': ('django.db.models.fields.TextField', [], {}), + 'source': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'+'", 'to': u"orm['exhibit.ExhibitProperty']"}) + }, + u'exhibit.propertyreference': { + 'Meta': {'ordering': "('order',)", 'unique_together': "(('derived', 'source'),)", 'object_name': 'PropertyReference'}, + 'derived': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'properties'", 'to': u"orm['exhibit.CompositeProperty']"}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'order': ('django.db.models.fields.PositiveSmallIntegerField', [], {}), + 'source': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['exhibit.ExhibitProperty']"}) + }, + u'exhibit.publishedexhibit': { + 'Meta': {'ordering': "('-modified',)", 'unique_together': "(('slug', 'owner'),)", 'object_name': 'PublishedExhibit', '_ormbases': [u'exhibit.Exhibit']}, + 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + u'exhibit_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['exhibit.Exhibit']", 'unique': 'True', 'primary_key': 'True'}), + 'is_public': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'owner': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'published_exhibits'", 'null': 'True', 'to': u"orm['auth.User']"}), + 'slug': ('django_extensions.db.fields.AutoSlugField', [], {'allow_duplicates': 'False', 'max_length': '50', 'separator': "u'-'", 'blank': 'True', 'populate_from': "'title'", 'overwrite': 'False'}), + 'title': ('django.db.models.fields.CharField', [], {'max_length': '255'}) + } + } + + complete_apps = ['exhibit'] + symmetrical = True diff --git a/freemix/exhibit/migrations/0018_drop_owner_slug.py b/freemix/exhibit/migrations/0018_drop_owner_slug.py new file mode 100644 index 00000000..fe32d17b --- /dev/null +++ b/freemix/exhibit/migrations/0018_drop_owner_slug.py @@ -0,0 +1,155 @@ +# -*- coding: 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): + # Removing unique constraint on 'PublishedExhibit', fields ['owner', 'slug'] + db.delete_unique(u'exhibit_publishedexhibit', ['owner_id', 'slug']) + + # Deleting field 'PublishedExhibit.owner' + db.delete_column(u'exhibit_publishedexhibit', 'owner_id') + + # Deleting field 'PublishedExhibit.slug' + db.delete_column(u'exhibit_publishedexhibit', 'slug') + + # Deleting field 'DraftExhibit.owner' + db.delete_column(u'exhibit_draftexhibit', 'owner_id') + + + def backwards(self, orm): + # Adding field 'PublishedExhibit.owner' + db.add_column(u'exhibit_publishedexhibit', 'owner', + self.gf('django.db.models.fields.related.ForeignKey')(related_name='published_exhibits', null=True, to=orm['auth.User'], blank=True), + keep_default=False) + + # Adding field 'PublishedExhibit.slug' + db.add_column(u'exhibit_publishedexhibit', 'slug', + self.gf('django_extensions.db.fields.AutoSlugField')(default='', populate_from='title', allow_duplicates=False, max_length=50, separator=u'-', blank=True, overwrite=False), + keep_default=False) + + # Adding unique constraint on 'PublishedExhibit', fields ['owner', 'slug'] + db.create_unique(u'exhibit_publishedexhibit', ['owner_id', 'slug']) + + # Adding field 'DraftExhibit.owner' + db.add_column(u'exhibit_draftexhibit', 'owner', + self.gf('django.db.models.fields.related.ForeignKey')(related_name='draft_exhibits', null=True, to=orm['auth.User'], blank=True), + keep_default=False) + + + models = { + u'auth.group': { + 'Meta': {'object_name': 'Group'}, + u'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': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}) + }, + u'auth.permission': { + 'Meta': {'ordering': "(u'content_type__app_label', u'content_type__model', u'codename')", 'unique_together': "((u'content_type', u'codename'),)", 'object_name': 'Permission'}, + 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['contenttypes.ContentType']"}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}) + }, + u'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': u"orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + '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': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}), + 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'}) + }, + u'contenttypes.contenttype': { + 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"}, + 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + u'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'}) + }, + u'exhibit.canvas': { + 'Meta': {'object_name': 'Canvas'}, + 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'enabled': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'location': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '100'}), + 'slug': ('django_extensions.db.fields.AutoSlugField', [], {'allow_duplicates': 'False', 'max_length': '50', 'separator': "u'-'", 'blank': 'True', 'populate_from': "'title'", 'overwrite': 'False'}), + 'thumbnail': ('django.db.models.fields.URLField', [], {'max_length': '200'}), + 'title': ('django.db.models.fields.CharField', [], {'max_length': '255'}) + }, + u'exhibit.compositeproperty': { + 'Meta': {'object_name': 'CompositeProperty', '_ormbases': [u'exhibit.ExhibitProperty']}, + u'exhibitproperty_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['exhibit.ExhibitProperty']", 'unique': 'True', 'primary_key': 'True'}) + }, + u'exhibit.datajsonfile': { + 'Meta': {'object_name': 'DataJSONFile'}, + 'exhibit': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'data'", 'unique': 'True', 'to': u"orm['exhibit.Exhibit']"}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'json': ('django.db.models.fields.TextField', [], {'default': "'{}'"}) + }, + u'exhibit.delimitedlistproperty': { + 'Meta': {'object_name': 'DelimitedListProperty', '_ormbases': ['exhibit.ExhibitProperty']}, + 'delimiter': ('django.db.models.fields.TextField', [], {}), + u'exhibitproperty_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['exhibit.ExhibitProperty']", 'unique': 'True', 'primary_key': 'True'}), + 'source': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'+'", 'to': u"orm['exhibit.ExhibitProperty']"}) + }, + u'exhibit.draftexhibit': { + 'Meta': {'ordering': "('-modified',)", 'object_name': 'DraftExhibit', '_ormbases': [u'exhibit.Exhibit']}, + u'exhibit_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['exhibit.Exhibit']", 'unique': 'True', 'primary_key': 'True'}), + 'parent': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['exhibit.PublishedExhibit']", 'null': 'True', 'blank': 'True'}), + 'uuid': ('django.db.models.fields.CharField', [], {'max_length': '36', 'blank': 'True'}) + }, + u'exhibit.exhibit': { + 'Meta': {'object_name': 'Exhibit'}, + 'canvas': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['exhibit.Canvas']"}), + 'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'is_draft': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'modified': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + 'o': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['auth.User']", 'null': 'True'}), + 'profile': ('django.db.models.fields.TextField', [], {'default': "'{}'"}), + 's': ('django.db.models.fields.SlugField', [], {'max_length': '50', 'blank': 'True'}) + }, + u'exhibit.exhibitproperty': { + 'Meta': {'unique_together': "(('exhibit', 'name'),)", 'object_name': 'ExhibitProperty'}, + 'classname': ('django.db.models.fields.CharField', [], {'max_length': '32', 'null': 'True'}), + 'exhibit': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'properties'", 'to': u"orm['exhibit.Exhibit']"}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'label': ('django.db.models.fields.CharField', [], {'max_length': '255'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '255'}), + 'value_type': ('django.db.models.fields.CharField', [], {'default': "'text'", 'max_length': '10'}) + }, + u'exhibit.patternlistproperty': { + 'Meta': {'object_name': 'PatternListProperty', '_ormbases': ['exhibit.ExhibitProperty']}, + u'exhibitproperty_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['exhibit.ExhibitProperty']", 'unique': 'True', 'primary_key': 'True'}), + 'pattern': ('django.db.models.fields.TextField', [], {}), + 'source': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'+'", 'to': u"orm['exhibit.ExhibitProperty']"}) + }, + u'exhibit.propertyreference': { + 'Meta': {'ordering': "('order',)", 'unique_together': "(('derived', 'source'),)", 'object_name': 'PropertyReference'}, + 'derived': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'properties'", 'to': u"orm['exhibit.CompositeProperty']"}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'order': ('django.db.models.fields.PositiveSmallIntegerField', [], {}), + 'source': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['exhibit.ExhibitProperty']"}) + }, + u'exhibit.publishedexhibit': { + 'Meta': {'ordering': "('-modified',)", 'object_name': 'PublishedExhibit', '_ormbases': [u'exhibit.Exhibit']}, + 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + u'exhibit_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['exhibit.Exhibit']", 'unique': 'True', 'primary_key': 'True'}), + 'is_public': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'title': ('django.db.models.fields.CharField', [], {'max_length': '255'}) + } + } + + complete_apps = ['exhibit'] \ No newline at end of file diff --git a/freemix/exhibit/migrations/0019_rename_temp_fields.py b/freemix/exhibit/migrations/0019_rename_temp_fields.py new file mode 100644 index 00000000..61fb489d --- /dev/null +++ b/freemix/exhibit/migrations/0019_rename_temp_fields.py @@ -0,0 +1,150 @@ +# -*- coding: 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): + # Deleting field 'DraftExhibit.uuid' + db.delete_column(u'exhibit_draftexhibit', 'uuid') + + # Rename field 'Exhibit.s' to 'Exhibit.slug' + db.rename_column(u'exhibit_exhibit', 's', 'slug') + + # Rename field 'Exhibit.o' to 'Exhibit.owner' + db.rename_column(u'exhibit_exhibit', 'o_id', 'owner_id') + + # Adding unique constraint on 'Exhibit', fields ['owner', 'is_draft', 'slug'] + db.create_unique(u'exhibit_exhibit', ['owner_id', 'is_draft', 'slug']) + + + def backwards(self, orm): + # Removing unique constraint on 'Exhibit', fields ['owner', 'is_draft', 'slug'] + db.delete_unique(u'exhibit_exhibit', ['owner_id', 'is_draft', 'slug']) + + # Adding field 'DraftExhibit.uuid' + db.add_column(u'exhibit_draftexhibit', 'uuid', + self.gf('django.db.models.fields.CharField')(default='', max_length=36, blank=True), + keep_default=False) + + # Rename field 'Exhibit.owner' + db.rename_column(u'exhibit_exhibit', 'owner_id', 'o_id') + + # Rename field 'Exhibit.slug' + db.rename_column(u'exhibit_exhibit', 'slug', 's') + + + models = { + u'auth.group': { + 'Meta': {'object_name': 'Group'}, + u'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': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}) + }, + u'auth.permission': { + 'Meta': {'ordering': "(u'content_type__app_label', u'content_type__model', u'codename')", 'unique_together': "((u'content_type', u'codename'),)", 'object_name': 'Permission'}, + 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['contenttypes.ContentType']"}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}) + }, + u'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': u"orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + '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': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}), + 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'}) + }, + u'contenttypes.contenttype': { + 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"}, + 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + u'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'}) + }, + u'exhibit.canvas': { + 'Meta': {'object_name': 'Canvas'}, + 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'enabled': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'location': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '100'}), + 'slug': ('django_extensions.db.fields.AutoSlugField', [], {'allow_duplicates': 'False', 'max_length': '50', 'separator': "u'-'", 'blank': 'True', 'populate_from': "'title'", 'overwrite': 'False'}), + 'thumbnail': ('django.db.models.fields.URLField', [], {'max_length': '200'}), + 'title': ('django.db.models.fields.CharField', [], {'max_length': '255'}) + }, + u'exhibit.compositeproperty': { + 'Meta': {'object_name': 'CompositeProperty', '_ormbases': [u'exhibit.ExhibitProperty']}, + u'exhibitproperty_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['exhibit.ExhibitProperty']", 'unique': 'True', 'primary_key': 'True'}) + }, + u'exhibit.datajsonfile': { + 'Meta': {'object_name': 'DataJSONFile'}, + 'exhibit': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'data'", 'unique': 'True', 'to': u"orm['exhibit.Exhibit']"}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'json': ('django.db.models.fields.TextField', [], {'default': "'{}'"}) + }, + u'exhibit.delimitedlistproperty': { + 'Meta': {'object_name': 'DelimitedListProperty', '_ormbases': ['exhibit.ExhibitProperty']}, + 'delimiter': ('django.db.models.fields.TextField', [], {}), + u'exhibitproperty_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['exhibit.ExhibitProperty']", 'unique': 'True', 'primary_key': 'True'}), + 'source': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'+'", 'to': u"orm['exhibit.ExhibitProperty']"}) + }, + u'exhibit.draftexhibit': { + 'Meta': {'ordering': "('-modified',)", 'object_name': 'DraftExhibit', '_ormbases': [u'exhibit.Exhibit']}, + u'exhibit_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['exhibit.Exhibit']", 'unique': 'True', 'primary_key': 'True'}), + 'parent': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['exhibit.PublishedExhibit']", 'null': 'True', 'blank': 'True'}) + }, + u'exhibit.exhibit': { + 'Meta': {'unique_together': "(('owner', 'slug', 'is_draft'),)", 'object_name': 'Exhibit'}, + 'canvas': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['exhibit.Canvas']"}), + 'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'is_draft': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'modified': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + 'owner': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['auth.User']", 'null': 'True'}), + 'profile': ('django.db.models.fields.TextField', [], {'default': "'{}'"}), + 'slug': ('django.db.models.fields.SlugField', [], {'max_length': '50', 'blank': 'True'}) + }, + u'exhibit.exhibitproperty': { + 'Meta': {'unique_together': "(('exhibit', 'name'),)", 'object_name': 'ExhibitProperty'}, + 'classname': ('django.db.models.fields.CharField', [], {'max_length': '32', 'null': 'True'}), + 'exhibit': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'properties'", 'to': u"orm['exhibit.Exhibit']"}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'label': ('django.db.models.fields.CharField', [], {'max_length': '255'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '255'}), + 'value_type': ('django.db.models.fields.CharField', [], {'default': "'text'", 'max_length': '10'}) + }, + u'exhibit.patternlistproperty': { + 'Meta': {'object_name': 'PatternListProperty', '_ormbases': ['exhibit.ExhibitProperty']}, + u'exhibitproperty_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['exhibit.ExhibitProperty']", 'unique': 'True', 'primary_key': 'True'}), + 'pattern': ('django.db.models.fields.TextField', [], {}), + 'source': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'+'", 'to': u"orm['exhibit.ExhibitProperty']"}) + }, + u'exhibit.propertyreference': { + 'Meta': {'ordering': "('order',)", 'unique_together': "(('derived', 'source'),)", 'object_name': 'PropertyReference'}, + 'derived': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'properties'", 'to': u"orm['exhibit.CompositeProperty']"}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'order': ('django.db.models.fields.PositiveSmallIntegerField', [], {}), + 'source': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['exhibit.ExhibitProperty']"}) + }, + u'exhibit.publishedexhibit': { + 'Meta': {'ordering': "('-modified',)", 'object_name': 'PublishedExhibit', '_ormbases': [u'exhibit.Exhibit']}, + 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + u'exhibit_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['exhibit.Exhibit']", 'unique': 'True', 'primary_key': 'True'}), + 'is_public': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'title': ('django.db.models.fields.CharField', [], {'max_length': '255'}) + } + } + + complete_apps = ['exhibit'] \ No newline at end of file diff --git a/freemix/exhibit/models.py b/freemix/exhibit/models.py index 83567158..98090896 100644 --- a/freemix/exhibit/models.py +++ b/freemix/exhibit/models.py @@ -2,7 +2,6 @@ from django.db import models from django.utils.translation import ugettext_lazy as _ from django.template.loader import render_to_string -from django_extensions.db.fields import AutoSlugField, UUIDField from django_extensions.db.fields.json import JSONField from django_extensions.db.models import (TitleSlugDescriptionModel, TimeStampedModel) @@ -38,29 +37,33 @@ class Exhibit(TimeStampedModel): canvas = models.ForeignKey(Canvas) + owner = models.ForeignKey(User, null=True) + + slug = models.SlugField(editable=False, blank=True) + + is_draft = models.BooleanField(default=True) + + class Meta: + unique_together = ('owner', 'slug', 'is_draft') + def update_from_profile(self, profile): self.profile = profile self.save() + def natural_key(self): + return self.owner, self.slug, self.is_draft + + class PublishedExhibit(Exhibit): """ A published exhibit with a title and slug for display to end users """ is_public = models.BooleanField(default=True) - owner = models.ForeignKey(User, - null=True, - blank=True, - related_name="published_exhibits") - title = models.CharField(_('title'), max_length=255) - slug = AutoSlugField(_('slug'), populate_from='title') description = models.TextField(_('description'), blank=True, null=True) - def natural_key(self): - return self.owner, self.slug - @models.permalink def get_absolute_url(self): return ('exhibit_display', (), { @@ -71,7 +74,6 @@ def __unicode__(self): return self.title class Meta: - unique_together = ("slug", "owner") ordering = ('-modified', ) @@ -84,12 +86,6 @@ class DraftExhibit(Exhibit): draft will be deleted. If `parent` is null, a new `PublishedExhibit` will be created on publication. """ - owner = models.ForeignKey(User, - null=True, - blank=True, - related_name="draft_exhibits") - - uuid = UUIDField(version=4) parent = models.ForeignKey(PublishedExhibit, null=True, diff --git a/freemix/exhibit/views.py b/freemix/exhibit/views.py index 8be7d0b6..ea55d446 100644 --- a/freemix/exhibit/views.py +++ b/freemix/exhibit/views.py @@ -169,8 +169,6 @@ def get(self, request, *args, **kwargs): user = self.request.user exhibit = self.exhibit - context["dataset_available"] = exhibit.dataset_available(user) - context["can_edit_dataset"] = user.has_perm("dataset.can_edit", self.dataset) context["can_view"] = user.has_perm("exhibit.can_view", exhibit) context["can_inspect"] = user.has_perm("exhibit.can_inspect", exhibit) @@ -212,7 +210,6 @@ def get_context_data(self, **kwargs): exhibit = self.get_object() context["exhibit"] = exhibit - context["dataset_available"] = exhibit.dataset_available(user) context["can_view"] = user.has_perm("exhibit.can_view", exhibit) context["can_inspect"] = user.has_perm("exhibit.can_inspect", exhibit) diff --git a/freemix/permissions.py b/freemix/permissions.py index c7689fe0..bc984716 100644 --- a/freemix/permissions.py +++ b/freemix/permissions.py @@ -1,4 +1,3 @@ -from django.core.exceptions import ObjectDoesNotExist from django.db.models.expressions import F from django.db.models.query_utils import Q @@ -79,25 +78,6 @@ def check_published(user_obj, obj): return True return check_owner(user_obj, obj) -def published_query_filter(user, context=""): - _c = generate_context_filter(context) - p = _c("published", True) - if user.is_authenticated(): - return p|owner_filter(user, context) - return p - -def dataset_can_build(user, obj): - if user.is_authenticated(): - return check_published(user, obj) - return False - - -PermissionsRegistry.register('dataset.can_view', check_published, published_query_filter) -PermissionsRegistry.register('dataset.can_inspect', check_published, published_query_filter) -PermissionsRegistry.register('dataset.can_edit', check_owner, owner_filter) - -PermissionsRegistry.register('dataset.can_delete', check_owner, owner_filter) -PermissionsRegistry.register('dataset.can_build', dataset_can_build, published_query_filter) PermissionsRegistry.register('datasource.can_view', check_owner, owner_filter) PermissionsRegistry.register('datasource.can_edit', check_owner, owner_filter) PermissionsRegistry.register('datasource.can_delete', check_owner, owner_filter) @@ -106,22 +86,17 @@ def exhibit_can_view(user, obj): if user.is_authenticated() and check_owner(user,obj): return True else: - return obj.dataset_available(obj.owner) and check_published(user,obj) - + return obj.is_public def exhibit_can_edit(user, obj): - if user.is_authenticated() and user.id==obj.owner.id: - return obj.dataset_available(user) - return False - - + return user.is_authenticated() and user.id==obj.owner.id def exhibit_can_embed(user,obj): - return obj.published + return obj.is_public def exhibit_embed_filter(user, context=""): _q = generate_context_filter(context) - return _q("published", True) + return _q("is_public", True) def exhibit_view_filter(user, context=""): @@ -129,26 +104,19 @@ def exhibit_view_filter(user, context=""): _f = generate_context_field(context) owner = owner_filter(user, context) - published = _q("published", True) - - dataset_owner = _q("dataset__owner", _f("owner")) - dataset_published = _q("dataset__published", True) + published = _q("is_public", True) if user.is_authenticated(): - # The user is the owner of the exhibit, or has access to the dataset and the exhibit is published - return owner|((dataset_owner|dataset_published)&published) - return dataset_published&published + # The user is the owner of the exhibit, or the exhibit is published + return owner|published + return published def exhibit_edit_filter(user, context=""): _q = generate_context_filter(context) owner = owner_filter(user, context) - dataset_owner = _q("dataset__owner", user) - dataset_published = _q("dataset__published", True) - - if user.is_authenticated(): - return owner&(dataset_owner|dataset_published) + return owner return _q("owner", None) PermissionsRegistry.register('exhibit.can_view', exhibit_can_view, exhibit_view_filter) From 5f7790f9ca829f7c011ab7a836bc7a8dff632b49 Mon Sep 17 00:00:00 2001 From: David Feeney Date: Tue, 13 Aug 2013 13:38:09 -0400 Subject: [PATCH 136/515] property data broken out --- .../migrations/0020_property_data_model.py | 145 +++++++++++++++ .../migrations/0021_migrate_property_data.py | 169 ++++++++++++++++++ .../migrations/0022_remove_full_data_file.py | 137 ++++++++++++++ freemix/exhibit/models.py | 35 ++-- 4 files changed, 476 insertions(+), 10 deletions(-) create mode 100644 freemix/exhibit/migrations/0020_property_data_model.py create mode 100644 freemix/exhibit/migrations/0021_migrate_property_data.py create mode 100644 freemix/exhibit/migrations/0022_remove_full_data_file.py diff --git a/freemix/exhibit/migrations/0020_property_data_model.py b/freemix/exhibit/migrations/0020_property_data_model.py new file mode 100644 index 00000000..7d784149 --- /dev/null +++ b/freemix/exhibit/migrations/0020_property_data_model.py @@ -0,0 +1,145 @@ +# -*- coding: 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 'PropertyData' + db.create_table(u'exhibit_propertydata', ( + (u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), + ('created', self.gf('django.db.models.fields.DateTimeField')(default=datetime.datetime.now, blank=True)), + ('modified', self.gf('django.db.models.fields.DateTimeField')(default=datetime.datetime.now, blank=True)), + ('exhibit_property', self.gf('django.db.models.fields.related.OneToOneField')(related_name='data', unique=True, to=orm['exhibit.ExhibitProperty'])), + ('json', self.gf('django.db.models.fields.TextField')(default='{}')), + )) + db.send_create_signal(u'exhibit', ['PropertyData']) + + + def backwards(self, orm): + # Deleting model 'PropertyData' + db.delete_table(u'exhibit_propertydata') + + + models = { + u'auth.group': { + 'Meta': {'object_name': 'Group'}, + u'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': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}) + }, + u'auth.permission': { + 'Meta': {'ordering': "(u'content_type__app_label', u'content_type__model', u'codename')", 'unique_together': "((u'content_type', u'codename'),)", 'object_name': 'Permission'}, + 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['contenttypes.ContentType']"}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}) + }, + u'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': u"orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + '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': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}), + 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'}) + }, + u'contenttypes.contenttype': { + 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"}, + 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + u'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'}) + }, + u'exhibit.canvas': { + 'Meta': {'object_name': 'Canvas'}, + 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'enabled': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'location': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '100'}), + 'slug': ('django_extensions.db.fields.AutoSlugField', [], {'allow_duplicates': 'False', 'max_length': '50', 'separator': "u'-'", 'blank': 'True', 'populate_from': "'title'", 'overwrite': 'False'}), + 'thumbnail': ('django.db.models.fields.URLField', [], {'max_length': '200'}), + 'title': ('django.db.models.fields.CharField', [], {'max_length': '255'}) + }, + u'exhibit.compositeproperty': { + 'Meta': {'object_name': 'CompositeProperty', '_ormbases': [u'exhibit.ExhibitProperty']}, + u'exhibitproperty_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['exhibit.ExhibitProperty']", 'unique': 'True', 'primary_key': 'True'}) + }, + u'exhibit.datajsonfile': { + 'Meta': {'object_name': 'DataJSONFile'}, + 'exhibit': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'data'", 'unique': 'True', 'to': u"orm['exhibit.Exhibit']"}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'json': ('django.db.models.fields.TextField', [], {'default': "'{}'"}) + }, + u'exhibit.delimitedlistproperty': { + 'Meta': {'object_name': 'DelimitedListProperty', '_ormbases': ['exhibit.ExhibitProperty']}, + 'delimiter': ('django.db.models.fields.TextField', [], {}), + u'exhibitproperty_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['exhibit.ExhibitProperty']", 'unique': 'True', 'primary_key': 'True'}), + 'source': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'+'", 'to': u"orm['exhibit.ExhibitProperty']"}) + }, + u'exhibit.draftexhibit': { + 'Meta': {'ordering': "('-modified',)", 'object_name': 'DraftExhibit', '_ormbases': [u'exhibit.Exhibit']}, + u'exhibit_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['exhibit.Exhibit']", 'unique': 'True', 'primary_key': 'True'}), + 'parent': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['exhibit.PublishedExhibit']", 'null': 'True', 'blank': 'True'}) + }, + u'exhibit.exhibit': { + 'Meta': {'unique_together': "(('owner', 'slug', 'is_draft'),)", 'object_name': 'Exhibit'}, + 'canvas': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['exhibit.Canvas']"}), + 'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'is_draft': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'modified': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + 'owner': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['auth.User']", 'null': 'True'}), + 'profile': ('django.db.models.fields.TextField', [], {'default': "'{}'"}), + 'slug': ('django.db.models.fields.SlugField', [], {'max_length': '50', 'blank': 'True'}) + }, + u'exhibit.exhibitproperty': { + 'Meta': {'unique_together': "(('exhibit', 'name'),)", 'object_name': 'ExhibitProperty'}, + 'classname': ('django.db.models.fields.CharField', [], {'max_length': '32', 'null': 'True'}), + 'exhibit': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'properties'", 'to': u"orm['exhibit.Exhibit']"}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'label': ('django.db.models.fields.CharField', [], {'max_length': '255'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '255'}), + 'value_type': ('django.db.models.fields.CharField', [], {'default': "'text'", 'max_length': '10'}) + }, + u'exhibit.patternlistproperty': { + 'Meta': {'object_name': 'PatternListProperty', '_ormbases': ['exhibit.ExhibitProperty']}, + u'exhibitproperty_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['exhibit.ExhibitProperty']", 'unique': 'True', 'primary_key': 'True'}), + 'pattern': ('django.db.models.fields.TextField', [], {}), + 'source': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'+'", 'to': u"orm['exhibit.ExhibitProperty']"}) + }, + u'exhibit.propertydata': { + 'Meta': {'ordering': "('-modified', '-created')", 'object_name': 'PropertyData'}, + 'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + 'exhibit_property': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'data'", 'unique': 'True', 'to': u"orm['exhibit.ExhibitProperty']"}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'json': ('django.db.models.fields.TextField', [], {'default': "'{}'"}), + 'modified': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}) + }, + u'exhibit.propertyreference': { + 'Meta': {'ordering': "('order',)", 'unique_together': "(('derived', 'source'),)", 'object_name': 'PropertyReference'}, + 'derived': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'properties'", 'to': u"orm['exhibit.CompositeProperty']"}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'order': ('django.db.models.fields.PositiveSmallIntegerField', [], {}), + 'source': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['exhibit.ExhibitProperty']"}) + }, + u'exhibit.publishedexhibit': { + 'Meta': {'ordering': "('-modified',)", 'object_name': 'PublishedExhibit', '_ormbases': [u'exhibit.Exhibit']}, + 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + u'exhibit_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['exhibit.Exhibit']", 'unique': 'True', 'primary_key': 'True'}), + 'is_public': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'title': ('django.db.models.fields.CharField', [], {'max_length': '255'}) + } + } + + complete_apps = ['exhibit'] \ No newline at end of file diff --git a/freemix/exhibit/migrations/0021_migrate_property_data.py b/freemix/exhibit/migrations/0021_migrate_property_data.py new file mode 100644 index 00000000..d6651206 --- /dev/null +++ b/freemix/exhibit/migrations/0021_migrate_property_data.py @@ -0,0 +1,169 @@ +# -*- coding: utf-8 -*- +import datetime +from south.db import db +from south.v2 import DataMigration +from django.db import models +import json + +def create_property(orm, exhibit, name): + prop = orm.ExhibitProperty(classname="ExhibitProperty", + name=name, + label=name, + value_type="text", + exhibit=exhibit) + prop.save() + return prop + + +class Migration(DataMigration): + + def forwards(self, orm): + + for exhibit in orm.Exhibit.objects.all(): + properties = {} + + data = json.loads(exhibit.data.json) + for record in data["items"]: + ex_id = record["id"] + label = record["label"] + for key in record.keys(): + if key == "id" or key == "label": + continue + + arr = properties.get(key, []) + arr.append({"id": ex_id, "label": label, key: record[key]}) + properties[key] = arr + for key in properties.keys(): + try: + prop = orm.ExhibitProperty.objects.get(name=key,exhibit=exhibit) + except orm.ExhibitProperty.DoesNotExist: + prop = create_property(orm, exhibit, key) + orm.PropertyData(exhibit_property=prop, + json=json.dumps(properties[key]), + modified=exhibit.modified, + created=exhibit.created).save() + + + def backwards(self, orm): + "Write your backwards methods here." + + models = { + u'auth.group': { + 'Meta': {'object_name': 'Group'}, + u'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': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}) + }, + u'auth.permission': { + 'Meta': {'ordering': "(u'content_type__app_label', u'content_type__model', u'codename')", 'unique_together': "((u'content_type', u'codename'),)", 'object_name': 'Permission'}, + 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['contenttypes.ContentType']"}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}) + }, + u'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': u"orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + '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': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}), + 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'}) + }, + u'contenttypes.contenttype': { + 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"}, + 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + u'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'}) + }, + u'exhibit.canvas': { + 'Meta': {'object_name': 'Canvas'}, + 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'enabled': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'location': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '100'}), + 'slug': ('django_extensions.db.fields.AutoSlugField', [], {'allow_duplicates': 'False', 'max_length': '50', 'separator': "u'-'", 'blank': 'True', 'populate_from': "'title'", 'overwrite': 'False'}), + 'thumbnail': ('django.db.models.fields.URLField', [], {'max_length': '200'}), + 'title': ('django.db.models.fields.CharField', [], {'max_length': '255'}) + }, + u'exhibit.compositeproperty': { + 'Meta': {'object_name': 'CompositeProperty', '_ormbases': [u'exhibit.ExhibitProperty']}, + u'exhibitproperty_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['exhibit.ExhibitProperty']", 'unique': 'True', 'primary_key': 'True'}) + }, + u'exhibit.datajsonfile': { + 'Meta': {'object_name': 'DataJSONFile'}, + 'exhibit': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'data'", 'unique': 'True', 'to': u"orm['exhibit.Exhibit']"}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'json': ('django.db.models.fields.TextField', [], {'default': "'{}'"}) + }, + u'exhibit.delimitedlistproperty': { + 'Meta': {'object_name': 'DelimitedListProperty', '_ormbases': ['exhibit.ExhibitProperty']}, + 'delimiter': ('django.db.models.fields.TextField', [], {}), + u'exhibitproperty_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['exhibit.ExhibitProperty']", 'unique': 'True', 'primary_key': 'True'}), + 'source': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'+'", 'to': u"orm['exhibit.ExhibitProperty']"}) + }, + u'exhibit.draftexhibit': { + 'Meta': {'ordering': "('-modified',)", 'object_name': 'DraftExhibit', '_ormbases': [u'exhibit.Exhibit']}, + u'exhibit_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['exhibit.Exhibit']", 'unique': 'True', 'primary_key': 'True'}), + 'parent': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['exhibit.PublishedExhibit']", 'null': 'True', 'blank': 'True'}) + }, + u'exhibit.exhibit': { + 'Meta': {'unique_together': "(('owner', 'slug', 'is_draft'),)", 'object_name': 'Exhibit'}, + 'canvas': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['exhibit.Canvas']"}), + 'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'is_draft': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'modified': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + 'owner': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['auth.User']", 'null': 'True'}), + 'profile': ('django.db.models.fields.TextField', [], {'default': "'{}'"}), + 'slug': ('django.db.models.fields.SlugField', [], {'max_length': '50', 'blank': 'True'}) + }, + u'exhibit.exhibitproperty': { + 'Meta': {'unique_together': "(('exhibit', 'name'),)", 'object_name': 'ExhibitProperty'}, + 'classname': ('django.db.models.fields.CharField', [], {'max_length': '32', 'null': 'True'}), + 'exhibit': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'properties'", 'to': u"orm['exhibit.Exhibit']"}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'label': ('django.db.models.fields.CharField', [], {'max_length': '255'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '255'}), + 'value_type': ('django.db.models.fields.CharField', [], {'default': "'text'", 'max_length': '10'}) + }, + u'exhibit.patternlistproperty': { + 'Meta': {'object_name': 'PatternListProperty', '_ormbases': ['exhibit.ExhibitProperty']}, + u'exhibitproperty_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['exhibit.ExhibitProperty']", 'unique': 'True', 'primary_key': 'True'}), + 'pattern': ('django.db.models.fields.TextField', [], {}), + 'source': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'+'", 'to': u"orm['exhibit.ExhibitProperty']"}) + }, + u'exhibit.propertydata': { + 'Meta': {'ordering': "('-modified', '-created')", 'object_name': 'PropertyData'}, + 'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + 'exhibit_property': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'data'", 'unique': 'True', 'to': u"orm['exhibit.ExhibitProperty']"}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'json': ('django.db.models.fields.TextField', [], {'default': "'{}'"}), + 'modified': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}) + }, + u'exhibit.propertyreference': { + 'Meta': {'ordering': "('order',)", 'unique_together': "(('derived', 'source'),)", 'object_name': 'PropertyReference'}, + 'derived': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'properties'", 'to': u"orm['exhibit.CompositeProperty']"}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'order': ('django.db.models.fields.PositiveSmallIntegerField', [], {}), + 'source': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['exhibit.ExhibitProperty']"}) + }, + u'exhibit.publishedexhibit': { + 'Meta': {'ordering': "('-modified',)", 'object_name': 'PublishedExhibit', '_ormbases': [u'exhibit.Exhibit']}, + 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + u'exhibit_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['exhibit.Exhibit']", 'unique': 'True', 'primary_key': 'True'}), + 'is_public': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'title': ('django.db.models.fields.CharField', [], {'max_length': '255'}) + } + } + + complete_apps = ['exhibit'] + symmetrical = True diff --git a/freemix/exhibit/migrations/0022_remove_full_data_file.py b/freemix/exhibit/migrations/0022_remove_full_data_file.py new file mode 100644 index 00000000..c28134e7 --- /dev/null +++ b/freemix/exhibit/migrations/0022_remove_full_data_file.py @@ -0,0 +1,137 @@ +# -*- coding: 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): + # Deleting model 'DataJSONFile' + db.delete_table(u'exhibit_datajsonfile') + + + def backwards(self, orm): + # Adding model 'DataJSONFile' + db.create_table(u'exhibit_datajsonfile', ( + ('exhibit', self.gf('django.db.models.fields.related.OneToOneField')(related_name='data', unique=True, to=orm['exhibit.Exhibit'])), + ('json', self.gf('django.db.models.fields.TextField')(default='{}')), + (u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), + )) + db.send_create_signal(u'exhibit', ['DataJSONFile']) + + + models = { + u'auth.group': { + 'Meta': {'object_name': 'Group'}, + u'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': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}) + }, + u'auth.permission': { + 'Meta': {'ordering': "(u'content_type__app_label', u'content_type__model', u'codename')", 'unique_together': "((u'content_type', u'codename'),)", 'object_name': 'Permission'}, + 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['contenttypes.ContentType']"}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}) + }, + u'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': u"orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + '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': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}), + 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'}) + }, + u'contenttypes.contenttype': { + 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"}, + 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + u'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'}) + }, + u'exhibit.canvas': { + 'Meta': {'object_name': 'Canvas'}, + 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'enabled': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'location': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '100'}), + 'slug': ('django_extensions.db.fields.AutoSlugField', [], {'allow_duplicates': 'False', 'max_length': '50', 'separator': "u'-'", 'blank': 'True', 'populate_from': "'title'", 'overwrite': 'False'}), + 'thumbnail': ('django.db.models.fields.URLField', [], {'max_length': '200'}), + 'title': ('django.db.models.fields.CharField', [], {'max_length': '255'}) + }, + u'exhibit.compositeproperty': { + 'Meta': {'object_name': 'CompositeProperty', '_ormbases': [u'exhibit.ExhibitProperty']}, + u'exhibitproperty_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['exhibit.ExhibitProperty']", 'unique': 'True', 'primary_key': 'True'}) + }, + u'exhibit.delimitedlistproperty': { + 'Meta': {'object_name': 'DelimitedListProperty'}, + 'delimiter': ('django.db.models.fields.TextField', [], {}), + u'exhibitproperty_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['exhibit.ExhibitProperty']", 'unique': 'True', 'primary_key': 'True'}), + 'source': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'+'", 'to': u"orm['exhibit.ExhibitProperty']"}) + }, + u'exhibit.draftexhibit': { + 'Meta': {'ordering': "('-modified',)", 'object_name': 'DraftExhibit', '_ormbases': [u'exhibit.Exhibit']}, + u'exhibit_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['exhibit.Exhibit']", 'unique': 'True', 'primary_key': 'True'}), + 'parent': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['exhibit.PublishedExhibit']", 'null': 'True', 'blank': 'True'}) + }, + u'exhibit.exhibit': { + 'Meta': {'unique_together': "(('owner', 'slug', 'is_draft'),)", 'object_name': 'Exhibit'}, + 'canvas': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['exhibit.Canvas']"}), + 'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'is_draft': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'modified': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + 'owner': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['auth.User']", 'null': 'True'}), + 'profile': ('django.db.models.fields.TextField', [], {'default': "'{}'"}), + 'slug': ('django.db.models.fields.SlugField', [], {'max_length': '50', 'blank': 'True'}) + }, + u'exhibit.exhibitproperty': { + 'Meta': {'unique_together': "(('exhibit', 'name'),)", 'object_name': 'ExhibitProperty'}, + 'classname': ('django.db.models.fields.CharField', [], {'max_length': '32', 'null': 'True'}), + 'exhibit': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'properties'", 'to': u"orm['exhibit.Exhibit']"}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'label': ('django.db.models.fields.CharField', [], {'max_length': '255'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '255'}), + 'value_type': ('django.db.models.fields.CharField', [], {'default': "'text'", 'max_length': '10'}) + }, + u'exhibit.patternlistproperty': { + 'Meta': {'object_name': 'PatternListProperty'}, + u'exhibitproperty_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['exhibit.ExhibitProperty']", 'unique': 'True', 'primary_key': 'True'}), + 'pattern': ('django.db.models.fields.TextField', [], {}), + 'source': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'+'", 'to': u"orm['exhibit.ExhibitProperty']"}) + }, + u'exhibit.propertydata': { + 'Meta': {'ordering': "('-modified', '-created')", 'object_name': 'PropertyData'}, + 'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + 'exhibit_property': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'data'", 'unique': 'True', 'to': u"orm['exhibit.ExhibitProperty']"}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'json': ('django.db.models.fields.TextField', [], {'default': "'{}'"}), + 'modified': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}) + }, + u'exhibit.propertyreference': { + 'Meta': {'ordering': "('order',)", 'unique_together': "(('derived', 'source'),)", 'object_name': 'PropertyReference'}, + 'derived': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'properties'", 'to': u"orm['exhibit.CompositeProperty']"}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'order': ('django.db.models.fields.PositiveSmallIntegerField', [], {}), + 'source': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['exhibit.ExhibitProperty']"}) + }, + u'exhibit.publishedexhibit': { + 'Meta': {'ordering': "('-modified',)", 'object_name': 'PublishedExhibit', '_ormbases': [u'exhibit.Exhibit']}, + 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + u'exhibit_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['exhibit.Exhibit']", 'unique': 'True', 'primary_key': 'True'}), + 'is_public': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'title': ('django.db.models.fields.CharField', [], {'max_length': '255'}) + } + } + + complete_apps = ['exhibit'] \ No newline at end of file diff --git a/freemix/exhibit/models.py b/freemix/exhibit/models.py index 98090896..e69df890 100644 --- a/freemix/exhibit/models.py +++ b/freemix/exhibit/models.py @@ -96,16 +96,6 @@ class Meta: verbose_name = "Exhibit" ordering = ('-modified', ) - -class DataJSONFile(models.Model): - """ - The data associated with this exhibit in the Exhibit JSON format - """ - exhibit = models.OneToOneField(Exhibit, related_name="data") - - json = JSONField() - - #-----------------------------------------------------------------------------# # Exhibit Property Types #-----------------------------------------------------------------------------# @@ -217,6 +207,7 @@ class CompositeProperty(ExhibitProperty): def to_dict(self): d = super(CompositeProperty, self).to_dict() d[self.name]["composite"] = self.properties.to_array() + d[self.name]["augmentation"] = "composite" return d def to_profile_dict(self): @@ -289,6 +280,8 @@ class DelimitedListProperty(ShreddedListProperty): def to_dict(self): d = super(DelimitedListProperty, self).to_dict() d[self.name]["delimiter"] = self.delimiter + d[self.name]["augmentation"] = "delimited-list" + return d def to_profile_dict(self): @@ -307,9 +300,31 @@ class PatternListProperty(ShreddedListProperty): def to_dict(self): d = super(PatternListProperty, self).to_dict() d[self.name]["pattern"] = self.pattern + d[self.name]["augmentation"] = "pattern-list" + return d def to_profile_dict(self): d = super(PatternListProperty, self).to_profile_dict() d["pattern"] = self.pattern return d + + +class PropertyData(TimeStampedModel): + """ + The data for a particular property in the format: + ``` + [ + { + "id": , + "label":