diff --git a/pandora/annotation/models.py b/pandora/annotation/models.py index 470af358..333aaf0f 100644 --- a/pandora/annotation/models.py +++ b/pandora/annotation/models.py @@ -270,7 +270,10 @@ class Annotation(models.Model): from translation.models import Translation layer = self.get_layer() if layer.get('translate'): - Translation.objects.get_or_create(lang=lang, key=self.value, defaults={'type': Translation.CONTENT}) + t, created = Translation.objects.get_or_create(lang=lang, key=self.value) + if created: + t.type = Translation.CONTENT + t.save() def delete(self, *args, **kwargs): with transaction.atomic(): diff --git a/pandora/app/views.py b/pandora/app/views.py index 8bd0fbfa..c0da9ede 100644 --- a/pandora/app/views.py +++ b/pandora/app/views.py @@ -118,7 +118,10 @@ def getPage(request, data): name = data else: name = data['name'] - page, created = models.Page.objects.get_or_create(name=name, defaults={'text': ''}) + page, created = models.Page.objects.get_or_create(name=name) + if created: + page.text = '' + page.save() response = json_response({'name': page.name, 'text': page.text}) return render_to_json_response(response) actions.register(getPage) diff --git a/pandora/document/models.py b/pandora/document/models.py index 268302b5..1a824734 100644 --- a/pandora/document/models.py +++ b/pandora/document/models.py @@ -235,8 +235,6 @@ class Document(models.Model): value = self.get_value(source, u'') if isinstance(value, list): value = u','.join(value) - if not isinstance(value, str): - value = str(value) value = utils.sort_string(value)[:955] set_value(s, name, value) elif sort_type == 'words': diff --git a/static/js/collection.js b/static/js/collection.js index d8296de4..60185906 100644 --- a/static/js/collection.js +++ b/static/js/collection.js @@ -137,10 +137,8 @@ pandora.ui.collection = function() { that.bindEvent({ closepreview: function(data) { - if (pandora.$ui.documentDialog) { - pandora.$ui.documentDialog.close(); - delete pandora.$ui.documentDialog; - } + pandora.$ui.previewDialog.close(); + delete pandora.$ui.previewDialog; }, copy: function(data) { pandora.clipboard.copy(data.ids, 'document'); @@ -229,25 +227,20 @@ pandora.ui.collection = function() { pandora.UI.set(set); }, openpreview: function(data) { - if (!pandora.$ui.documentDialog) { - pandora.$ui.documentDialog = pandora.openDocumentDialog({ - documents: that.options('selected').map(function(id) { - return that.value(id); - }) - }).bindEvent({ - close: function() { - that.closePreview(); - delete pandora.$ui.documentDialog; - } - }); + /* + if (!pandora.$ui.previewDialog) { + pandora.$ui.previewDialog = pandora.ui.previewDialog() + .open() + .bindEvent({ + close: function() { + that.closePreview(); + delete pandora.$ui.previewDialog; + } + }); } else { - pandora.$ui.documentDialog.update({ - index: 0, - items: that.options('selected').map(function(id) { - return that.value(id); - }) - }); + pandora.$ui.previewDialog.update(); } + */ }, paste: function(data) { var items = pandora.clipboard.paste();