Gitlab CSE Unil

Commit fe27cc43 authored by Julien Furrer's avatar Julien Furrer
Browse files

Added field allow_public_publishing on AnObj

Added the possibility to allow or not the members
of an AnObj to publish their annotations for
the other members. Read/write support from
AnObjMgr
parent 7fed54c1
# -*- coding: utf-8 -*-
from south.utils import datetime_utils as datetime
from south.db import db
from south.v2 import SchemaMigration
from django.db import models
class Migration(SchemaMigration):
def forwards(self, orm):
# Adding field 'AnObj.allow_public_publishing'
db.add_column(u'adim_anobj', 'allow_public_publishing',
self.gf('django.db.models.fields.BooleanField')(default=False),
keep_default=False)
def backwards(self, orm):
# Deleting field 'AnObj.allow_public_publishing'
db.delete_column(u'adim_anobj', 'allow_public_publishing')
models = {
u'adim.annotation': {
'Meta': {'ordering': "(u'owner__id', u'-order', u'modification_date')", 'object_name': 'Annotation'},
'annotable': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "u'annotations'", 'to': u"orm['adim.AnObj']"}),
'comment': ('django.db.models.fields.CharField', [], {'default': "u''", 'max_length': '512', 'blank': 'True'}),
'creation_date': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'item': ('django.db.models.fields.TextField', [], {}),
'modification_date': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
'order': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
'owner': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['auth.User']"})
},
u'adim.anobj': {
'Meta': {'ordering': "[u'-id']", 'object_name': 'AnObj'},
'_thumb_url': ('django.db.models.fields.CharField', [], {'max_length': '512', 'null': 'True', 'blank': 'True'}),
'allow_public_publishing': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'ao_type': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['adim.AOType']", 'null': 'True', 'blank': 'True'}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'image': ('django.db.models.fields.files.ImageField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'}),
'image_url': ('django.db.models.fields.CharField', [], {'default': "u''", 'max_length': '512', 'null': 'True', 'blank': 'True'}),
'locked': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'members': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "u'shared_anobjs'", 'to': u"orm['auth.User']", 'through': u"orm['adim.AnObjMembership']", 'blank': 'True', 'symmetrical': 'False', 'null': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '125'}),
'owner': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "u'anobjs'", 'to': u"orm['auth.User']"}),
'sharing_mode': ('django.db.models.fields.IntegerField', [], {'default': '0', 'blank': 'True'}),
'sharing_opts': ('jsonfield.fields.JSONField', [], {'default': "u'{}'", 'blank': 'True'}),
'uuid': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '32', 'blank': 'True'})
},
u'adim.anobjmembership': {
'Meta': {'object_name': 'AnObjMembership'},
'anobj': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['adim.AnObj']"}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'publish_mode': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
'user': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['auth.User']"})
},
u'adim.aoattribute': {
'Meta': {'object_name': 'AOAttribute'},
'choice': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['adim.AOChoice']", 'null': 'True', 'blank': 'True'}),
'entity_id': ('django.db.models.fields.IntegerField', [], {}),
'entity_type': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['contenttypes.ContentType']"}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'schema': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "u'attrs'", 'to': u"orm['adim.AOSchema']"}),
'value_bool': ('django.db.models.fields.NullBooleanField', [], {'null': 'True', 'blank': 'True'}),
'value_date': ('django.db.models.fields.DateField', [], {'null': 'True', 'blank': 'True'}),
'value_float': ('django.db.models.fields.FloatField', [], {'null': 'True', 'blank': 'True'}),
'value_image': ('django.db.models.fields.files.ImageField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'}),
'value_range_max': ('django.db.models.fields.FloatField', [], {'null': 'True', 'blank': 'True'}),
'value_range_min': ('django.db.models.fields.FloatField', [], {'null': 'True', 'blank': 'True'}),
'value_text': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'})
},
u'adim.aochoice': {
'Meta': {'object_name': 'AOChoice'},
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'schema': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "u'choices'", 'to': u"orm['adim.AOSchema']"}),
'title': ('django.db.models.fields.CharField', [], {'max_length': '100'})
},
u'adim.aoschema': {
'Meta': {'object_name': 'AOSchema'},
'ao_types': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'to': u"orm['adim.AOType']", 'null': 'True', 'blank': 'True'}),
'datatype': ('django.db.models.fields.CharField', [], {'max_length': '5'}),
'filtered': ('django.db.models.fields.BooleanField', [], {}),
'help_text': ('django.db.models.fields.CharField', [], {'max_length': '250', 'blank': 'True'}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('autoslug.fields.AutoSlugField', [], {'unique_with': '()', 'max_length': '250', 'populate_from': "'title'", 'blank': 'True'}),
'required': ('django.db.models.fields.BooleanField', [], {}),
'searched': ('django.db.models.fields.BooleanField', [], {}),
'sortable': ('django.db.models.fields.BooleanField', [], {}),
'title': ('django.db.models.fields.CharField', [], {'max_length': '250'})
},
u'adim.aotype': {
'Meta': {'object_name': 'AOType'},
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
'title': ('django.db.models.fields.CharField', [], {'default': "u''", 'max_length': '512', 'blank': 'True'})
},
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', [], {'symmetrical': 'False', 'related_name': "u'user_set'", 'blank': 'True', 'to': u"orm['auth.Group']"}),
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', [], {'symmetrical': 'False', 'related_name': "u'user_set'", 'blank': 'True', 'to': u"orm['auth.Permission']"}),
'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'})
}
}
complete_apps = ['adim']
\ No newline at end of file
......@@ -81,8 +81,8 @@ class AnObj(BaseEntity):
locked = models.BooleanField(verbose_name=_("locked"), default=False)
sharing_mode = models.IntegerField(verbose_name=_("sharing mode"), default=0, blank=True)
# sharing_opts = models.TextField(verbose_name=_("sharing options"), default="", blank=True)
sharing_opts = JSONField(verbose_name=_("sharing options"), default="{}", blank=True)
allow_public_publishing = models.BooleanField(verbose_name=_("allow public publishing"), default=False)
members = models.ManyToManyField(User, verbose_name=_("members"), through='AnObjMembership',
related_name='shared_anobjs', blank=True, null=True)
......
......@@ -104,14 +104,15 @@ class AnObjSerializer(BaseAnObjSerializer):
class Meta:
model = AnObj
fields = ('id', 'uuid', 'name', 'owner', 'owner_name', 'ao_type', 'annotations', 'members',
'sharing_mode', 'sharing_opts', 'locked')
'sharing_mode', 'sharing_opts', 'locked', 'allow_public_publishing')
class SharedAnObjSerializer(BaseAnObjSerializer):
class Meta:
model = AnObj
fields = ('id', 'uuid', 'name', 'owner', 'owner_name', 'ao_type', 'annotations', 'locked', 'sharing_mode')
fields = ('id', 'uuid', 'name', 'owner', 'owner_name', 'ao_type', 'annotations', 'locked',
'sharing_mode', 'allow_public_publishing')
class AnObjListSerializer(BaseAnObjSerializer):
......
......@@ -371,19 +371,24 @@ function($, Signal, paper, config, view, io, tools, attributes, exporter, AnObjM
// Image Manager
// ----------------------------------
// init and attach handlers to button
this._anObjMgr = new AnObjMgr({
el: "#aom-modal",
aomListCtner: $("#aom-user-images-list .aom-list-container"),
sharedAomListCtner: $("#aom-shared-images-list .aom-list-container")
$(".aom-show-but").on("click", function(event){
_showAnObjMgr.call(me, event);
});
this._anObjMgrModal = $("#aom-modal")
.data('loaded', false)
.modal({'show':false});
$(".aom-show-but").on("click", {
anObjMgr: this._anObjMgr,
anObjMgrModal: this._anObjMgrModal
}, _showAnObjMgr);
//this._anObjMgr = new AnObjMgr({
// el: "#aom-modal",
// aomListCtner: $("#aom-user-images-list .aom-list-container"),
// sharedAomListCtner: $("#aom-shared-images-list .aom-list-container")
//});
//this._anObjMgrModal = $("#aom-modal")
// .data('loaded', false)
// .modal({'show':false});
//
//$(".aom-show-but").on("click", {
// anObjMgr: this._anObjMgr,
// anObjMgrModal: this._anObjMgrModal
//}, _showAnObjMgr);
//
......@@ -1342,16 +1347,30 @@ function($, Signal, paper, config, view, io, tools, attributes, exporter, AnObjM
* @private
*/
function _showAnObjMgr(event) {
var me = this;
event.preventDefault();
event.data.anObjMgrModal.modal('show');
if (! event.data.anObjMgrModal.data('loaded')) {
event.data.anObjMgr.loadAnObjs({success: function(anobjs){
if (event.data && event.data.anObjMgrModal) {
event.data.anObjMgrModal.find(".aom-loader").remove();
event.data.anObjMgrModal.data('loaded', true);
if (!me._anObjMgr) {
me._anObjMgr = new AnObjMgr({
el: "#aom-modal",
aomListCtner: $("#aom-user-images-list .aom-list-container"),
sharedAomListCtner: $("#aom-shared-images-list .aom-list-container")
});
}
if (!me._anObjMgrModal) {
me._anObjMgrModal = $("#aom-modal")
.data('loaded', false)
.modal({'show': false});
}
me._anObjMgrModal.modal('show');
if (! me._anObjMgrModal.data('loaded')) {
me._anObjMgr.loadAnObjs({success: function(anobjs){
if (me._anObjMgrModal) {
me._anObjMgrModal.find(".aom-loader").remove();
me._anObjMgrModal.data('loaded', true);
}
event.data.anObjMgr.selectCurrent();
// event.data.anObjMgr.
me._anObjMgr.selectCurrent();
}})
}
}
......
......@@ -138,7 +138,6 @@ function($, _, Backbone, Config, AnObjCollection, AnObjListItemView, AnObjProper
}
this.anobjPropertyPanel.setMode( tabPane.is("#aom-shared-images-list") ? 'shared': 'user' );
},
......
......@@ -43,6 +43,7 @@ define([
this.thumbEl = this.$el.find(".panel-body .aom-image-thumb");
this.propListEl = this.$el.find(".panel-body .aom-info-prop");
this.sharingPropEl = this.$el.find(".panel-body .aom-info-share");
this.publicPublishEl = this.$("#aom-prop-publishall");
this.propOwnerEl = this.$el.find(".aom-prop-owner").prev('dt').andSelf();
......@@ -94,6 +95,7 @@ define([
events: {
"click .aom-prop-lock-but": 'lockButClick',
"change #aom-prop-shared-id": 'setSharingMode',
"change #aom-prop-publishall": 'setPublishMode',
"click .aom-shm-ctrl-members-list": 'memberListClick',
"keyup .aom-shm-ctrl-member-input": 'inputMemberKeyup',
......@@ -114,13 +116,15 @@ define([
// Update sharing properties
var sharingMode = itemModel.get('sharing_mode'),
locked = itemModel.get('locked');
locked = itemModel.get('locked'),
publicPublish = itemModel.get('allow_public_publishing');
this.sharingPropEl
.toggleClass("aom-prop-locked", locked)
.toggleClass("aom-prop-unlocked", !locked);
this.sharingPropEl.find("[name=aom-prop-shared]").val([sharingMode]);
this.publicPublishEl.val([publicPublish]);
this.propShMdParamsAll.addClass("hidden");
if (sharingMode) {
// Show controls specific to the sharing mode
......@@ -268,7 +272,6 @@ define([
// Sharing Mode
// ------------
setSharingMode: function(event) {
var me = this,
$elem = $(event.target),
......@@ -285,10 +288,30 @@ define([
}
},
//
// Public Publish Authorization
setPublishMode: function(event) {
var me = this,
$elem = $(event.target),
isPublic = $elem.is(":checked");
if (! me.currentModel) {
$elem.val([!isPublic]);
} else {
me.currentModel.save({
'allow_public_publishing': isPublic
}, {
patch: true,
fail: function() {
$elem.val([!isPublic]);
}
})
}
},
// Registration Kes handling
// -------------------------
showRegkeyValue: (function(){
var $but, $el;
return function(event) {
......
......@@ -1840,24 +1840,36 @@ fieldset[disabled] .btn-cimaf-layer.active {
#aom-modal .aom-list-container {
max-height: 220px;
height: auto;
transition-property: max-height, min-height;
transition-duration: 0.4s;
transition-timing-function: linear;
}
}
@media (min-height: 590px) {
#aom-modal .aom-list-container {
max-height: 440px;
height: auto;
transition-property: max-height, min-height;
transition-duration: 0.4s;
transition-timing-function: linear;
}
}
@media (min-height: 810px) {
#aom-modal .aom-list-container {
max-height: 660px;
height: auto;
transition-property: max-height, min-height;
transition-duration: 0.4s;
transition-timing-function: linear;
}
}
@media (min-height: 1030px) {
#aom-modal .aom-list-container {
max-height: 880px;
height: auto;
transition-property: max-height, min-height;
transition-duration: 0.4s;
transition-timing-function: linear;
}
}
@media (min-width: 500px) {
......@@ -1943,9 +1955,47 @@ fieldset[disabled] .btn-cimaf-layer.active {
font-size: 12px;
}
.aom-info-panel .panel-body {
overflow-x: hidden;
overflow-y: auto;
font-size: 12px;
padding: 0;
}
@media (min-height: 370px) {
.aom-info-panel .panel-body {
max-height: 196px;
height: auto;
transition-property: max-height, min-height;
transition-duration: 0.4s;
transition-timing-function: linear;
}
}
@media (min-height: 590px) {
.aom-info-panel .panel-body {
max-height: 416px;
height: auto;
transition-property: max-height, min-height;
transition-duration: 0.4s;
transition-timing-function: linear;
}
}
@media (min-height: 810px) {
.aom-info-panel .panel-body {
max-height: 636px;
height: auto;
transition-property: max-height, min-height;
transition-duration: 0.4s;
transition-timing-function: linear;
}
}
@media (min-height: 1030px) {
.aom-info-panel .panel-body {
max-height: 856px;
height: auto;
transition-property: max-height, min-height;
transition-duration: 0.4s;
transition-timing-function: linear;
}
}
.aom-info-panel .panel-body .aom-image-thumb {
width: 180px;
height: 180px;
......@@ -1988,6 +2038,15 @@ fieldset[disabled] .btn-cimaf-layer.active {
.aom-info-panel .panel-body .aom-info-share h5 {
margin: 10px 15px;
}
.aom-info-panel .panel-body .aom-info-share .control-label {
text-align: left;
}
.aom-info-panel .panel-body .aom-info-share .checkbox {
padding-top: 0;
}
.aom-info-panel .panel-body .aom-info-share .checkbox input[type=checkbox] {
top: -2px;
}
.aom-info-panel .panel-body .aom-info-share .form-horizontal .form-group {
margin-left: 0;
margin-right: 0;
......@@ -2036,6 +2095,9 @@ fieldset[disabled] .btn-cimaf-layer.active {
font-size: 12px;
font-weight: bold;
}
.aom-info-panel .panel-body .aom-info-share.aom-prop-locked .help-block {
display: none;
}
.aom-info-panel .panel-body .aom-info-share form {
position: relative;
overflow: hidden;
......
......@@ -11,24 +11,36 @@
#aom-modal .aom-list-container {
max-height: 220px;
height: auto;
transition-property: max-height, min-height;
transition-duration: 0.4s;
transition-timing-function: linear;
}
}
@media (min-height: 590px) {
#aom-modal .aom-list-container {
max-height: 440px;
height: auto;
transition-property: max-height, min-height;
transition-duration: 0.4s;
transition-timing-function: linear;
}
}
@media (min-height: 810px) {
#aom-modal .aom-list-container {
max-height: 660px;
height: auto;
transition-property: max-height, min-height;
transition-duration: 0.4s;
transition-timing-function: linear;
}
}
@media (min-height: 1030px) {
#aom-modal .aom-list-container {
max-height: 880px;
height: auto;
transition-property: max-height, min-height;
transition-duration: 0.4s;
transition-timing-function: linear;
}
}
@media (min-width: 500px) {
......@@ -114,9 +126,47 @@
font-size: 12px;
}
.aom-info-panel .panel-body {
overflow-x: hidden;
overflow-y: auto;
font-size: 12px;
padding: 0;
}
@media (min-height: 370px) {
.aom-info-panel .panel-body {
max-height: 196px;
height: auto;
transition-property: max-height, min-height;
transition-duration: 0.4s;
transition-timing-function: linear;
}
}
@media (min-height: 590px) {
.aom-info-panel .panel-body {
max-height: 416px;
height: auto;
transition-property: max-height, min-height;
transition-duration: 0.4s;
transition-timing-function: linear;
}
}
@media (min-height: 810px) {
.aom-info-panel .panel-body {
max-height: 636px;
height: auto;
transition-property: max-height, min-height;
transition-duration: 0.4s;
transition-timing-function: linear;
}
}
@media (min-height: 1030px) {
.aom-info-panel .panel-body {
max-height: 856px;
height: auto;
transition-property: max-height, min-height;
transition-duration: 0.4s;
transition-timing-function: linear;
}
}
.aom-info-panel .panel-body .aom-image-thumb {
width: 180px;
height: 180px;
......@@ -159,6 +209,15 @@
.aom-info-panel .panel-body .aom-info-share h5 {
margin: 10px 15px;
}
.aom-info-panel .panel-body .aom-info-share .control-label {
text-align: left;
}
.aom-info-panel .panel-body .aom-info-share .checkbox {
padding-top: 0;
}
.aom-info-panel .panel-body .aom-info-share .checkbox input[type=checkbox] {
top: -2px;
}
.aom-info-panel .panel-body .aom-info-share .form-horizontal .form-group {
margin-left: 0;
margin-right: 0;
......@@ -207,6 +266,9 @@
font-size: 12px;
font-weight: bold;
}
.aom-info-panel .panel-body .aom-info-share.aom-prop-locked .help-block {
display: none;
}
.aom-info-panel .panel-body .aom-info-share form {
position: relative;
overflow: hidden;
......
......@@ -43,14 +43,16 @@
}
.gen-lst-height(@n, @i: 2) when (@i =< @n) {
.gen-lst-height(@n, @i: 2, @dH: 0) when (@i =< @n) {
@lst-h: ((@aom-list-item-height + @aom-list-item-margin-v*2) * @i);
@media (min-height: (@lst-h + 150)) {
max-height: @lst-h;
max-height: @lst-h - @dH;
height: auto;
// transition: height 0.5s ease 0s;
transition-property: max-height, min-height;
transition-duration: 0.4s;
transition-timing-function: linear;
}
.gen-lst-height(@n, (@i + 1));
.gen-lst-height(@n, (@i + 1), @dH);
}
#aom-modal {
......@@ -95,6 +97,10 @@
}
.panel-body {
overflow-x: hidden;
overflow-y: auto;
.gen-lst-height(4, 1, 24);
font-size: 12px;
padding: 0;
.aom-image-thumb {
......@@ -142,6 +148,12 @@
margin: 10px 15px;
}
.control-label { text-align: left; }
.checkbox {
padding-top: 0;
input[type=checkbox] { top: -2px; }
}
.form-horizontal .form-group {
margin-left: 0;
......@@ -185,6 +197,7 @@