Compare commits

...

3 commits

Author SHA1 Message Date
j
9730b046ce document preview 2018-12-05 10:10:14 +01:00
j
708a5b1b33 don't fail for int 2018-12-04 19:14:24 +01:00
j
55b86bdac8 use get_or_create(defaults...) 2018-11-20 16:15:08 +01:00
4 changed files with 25 additions and 22 deletions

View file

@ -270,10 +270,7 @@ class Annotation(models.Model):
from translation.models import Translation
layer = self.get_layer()
if layer.get('translate'):
t, created = Translation.objects.get_or_create(lang=lang, key=self.value)
if created:
t.type = Translation.CONTENT
t.save()
Translation.objects.get_or_create(lang=lang, key=self.value, defaults={'type': Translation.CONTENT})
def delete(self, *args, **kwargs):
with transaction.atomic():

View file

@ -118,10 +118,7 @@ def getPage(request, data):
name = data
else:
name = data['name']
page, created = models.Page.objects.get_or_create(name=name)
if created:
page.text = ''
page.save()
page, created = models.Page.objects.get_or_create(name=name, defaults={'text': ''})
response = json_response({'name': page.name, 'text': page.text})
return render_to_json_response(response)
actions.register(getPage)

View file

@ -235,6 +235,8 @@ 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':

View file

@ -137,8 +137,10 @@ pandora.ui.collection = function() {
that.bindEvent({
closepreview: function(data) {
pandora.$ui.previewDialog.close();
delete pandora.$ui.previewDialog;
if (pandora.$ui.documentDialog) {
pandora.$ui.documentDialog.close();
delete pandora.$ui.documentDialog;
}
},
copy: function(data) {
pandora.clipboard.copy(data.ids, 'document');
@ -227,20 +229,25 @@ pandora.ui.collection = function() {
pandora.UI.set(set);
},
openpreview: function(data) {
/*
if (!pandora.$ui.previewDialog) {
pandora.$ui.previewDialog = pandora.ui.previewDialog()
.open()
.bindEvent({
close: function() {
that.closePreview();
delete pandora.$ui.previewDialog;
}
});
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;
}
});
} else {
pandora.$ui.previewDialog.update();
pandora.$ui.documentDialog.update({
index: 0,
items: that.options('selected').map(function(id) {
return that.value(id);
})
});
}
*/
},
paste: function(data) {
var items = pandora.clipboard.paste();