Add from __future__ import unicode_literals, issue #37
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, unicode_literals
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
@@ -10,24 +10,21 @@ from project_setup.api import register_setup
|
||||
from rest_api.classes import APIEndPoint
|
||||
|
||||
from .classes import StagingFile
|
||||
from .links import (document_create_multiple, document_create_siblings,
|
||||
setup_sources, setup_source_create_imap_email,
|
||||
setup_source_create_pop3_email,
|
||||
setup_source_create_watch_folder,
|
||||
setup_source_create_webform,
|
||||
setup_source_create_staging_folder,
|
||||
setup_source_delete, setup_source_edit,
|
||||
setup_source_transformation_create,
|
||||
setup_source_transformation_delete,
|
||||
setup_source_transformation_edit,
|
||||
setup_source_transformation_list,
|
||||
staging_file_delete, upload_version)
|
||||
from .links import (
|
||||
document_create_multiple, document_create_siblings, setup_sources,
|
||||
setup_source_create_imap_email, setup_source_create_pop3_email,
|
||||
setup_source_create_watch_folder, setup_source_create_webform,
|
||||
setup_source_create_staging_folder, setup_source_delete, setup_source_edit,
|
||||
setup_source_transformation_create, setup_source_transformation_delete,
|
||||
setup_source_transformation_edit, setup_source_transformation_list,
|
||||
staging_file_delete, upload_version
|
||||
)
|
||||
from .models import Source, SourceTransformation
|
||||
from .widgets import staging_file_thumbnail
|
||||
|
||||
register_model_list_columns(StagingFile, [
|
||||
{
|
||||
'name': _(u'Thumbnail'), 'attribute':
|
||||
'name': _('Thumbnail'), 'attribute':
|
||||
encapsulate(lambda x: staging_file_thumbnail(x, gallery_name='sources:staging_list', title=x.filename, size='100'))
|
||||
},
|
||||
])
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
from __future__ import absolute_import
|
||||
|
||||
from django.contrib import admin
|
||||
|
||||
from .models import (SourceTransformation, StagingFolderSource,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from __future__ import absolute_import
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.shortcuts import get_object_or_404
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from __future__ import absolute_import
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import base64
|
||||
import os
|
||||
@@ -69,7 +69,7 @@ class StagingFile(object):
|
||||
image = open(converted_file_path, 'r')
|
||||
base64_data = base64.b64encode(image.read())
|
||||
image.close()
|
||||
return u'data:%s;base64,%s' % (mimetype, base64_data)
|
||||
return 'data:%s;base64,%s' % (mimetype, base64_data)
|
||||
else:
|
||||
return converted_file_path
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from __future__ import absolute_import
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import logging
|
||||
|
||||
@@ -26,7 +26,7 @@ class NewVersionForm(forms.Form):
|
||||
super(NewVersionForm, self).__init__(*args, **kwargs)
|
||||
|
||||
self.fields['comment'] = forms.CharField(
|
||||
label=_(u'Comment'),
|
||||
label=_('Comment'),
|
||||
required=False,
|
||||
widget=forms.widgets.Textarea(attrs={'rows': 4}),
|
||||
)
|
||||
@@ -41,8 +41,8 @@ class UploadBaseForm(forms.Form):
|
||||
|
||||
if show_expand:
|
||||
self.fields['expand'] = forms.BooleanField(
|
||||
label=_(u'Expand compressed files'), required=False,
|
||||
help_text=ugettext(u'Upload a compressed file\'s contained files as individual documents')
|
||||
label=_('Expand compressed files'), required=False,
|
||||
help_text=ugettext('Upload a compressed file\'s contained files as individual documents')
|
||||
)
|
||||
|
||||
|
||||
@@ -67,11 +67,11 @@ class StagingUploadForm(UploadBaseForm):
|
||||
staging_list = self.fields.keyOrder.pop(staging_list_index)
|
||||
self.fields.keyOrder.insert(0, staging_list)
|
||||
|
||||
staging_file_id = forms.ChoiceField(label=_(u'Staging file'))
|
||||
staging_file_id = forms.ChoiceField(label=_('Staging file'))
|
||||
|
||||
|
||||
class WebFormUploadForm(UploadBaseForm):
|
||||
file = forms.FileField(label=_(u'File'))
|
||||
file = forms.FileField(label=_('File'))
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(WebFormUploadForm, self).__init__(*args, **kwargs)
|
||||
|
||||
+29
-27
@@ -1,37 +1,39 @@
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, unicode_literals
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from documents.permissions import (PERMISSION_DOCUMENT_CREATE,
|
||||
PERMISSION_DOCUMENT_NEW_VERSION)
|
||||
from documents.permissions import (
|
||||
PERMISSION_DOCUMENT_CREATE, PERMISSION_DOCUMENT_NEW_VERSION
|
||||
)
|
||||
|
||||
from .literals import (SOURCE_CHOICE_WEB_FORM, SOURCE_CHOICE_EMAIL_IMAP,
|
||||
SOURCE_CHOICE_EMAIL_POP3, SOURCE_CHOICE_STAGING,
|
||||
SOURCE_CHOICE_WATCH)
|
||||
from .permissions import (PERMISSION_SOURCES_SETUP_CREATE,
|
||||
PERMISSION_SOURCES_SETUP_DELETE,
|
||||
PERMISSION_SOURCES_SETUP_EDIT,
|
||||
PERMISSION_SOURCES_SETUP_VIEW)
|
||||
from .literals import (
|
||||
SOURCE_CHOICE_WEB_FORM, SOURCE_CHOICE_EMAIL_IMAP, SOURCE_CHOICE_EMAIL_POP3,
|
||||
SOURCE_CHOICE_STAGING, SOURCE_CHOICE_WATCH
|
||||
)
|
||||
from .permissions import (
|
||||
PERMISSION_SOURCES_SETUP_CREATE, PERMISSION_SOURCES_SETUP_DELETE,
|
||||
PERMISSION_SOURCES_SETUP_EDIT, PERMISSION_SOURCES_SETUP_VIEW
|
||||
)
|
||||
|
||||
document_create_multiple = {'text': _(u'Upload new documents'), 'view': 'sources:document_create_multiple', 'famfam': 'page_add', 'permissions': [PERMISSION_DOCUMENT_CREATE]}
|
||||
document_create_siblings = {'text': _(u'Clone'), 'view': 'sources:document_create_siblings', 'args': 'object.id', 'famfam': 'page_copy', 'permissions': [PERMISSION_DOCUMENT_CREATE]}
|
||||
document_create_multiple = {'text': _('Upload new documents'), 'view': 'sources:document_create_multiple', 'famfam': 'page_add', 'permissions': [PERMISSION_DOCUMENT_CREATE]}
|
||||
document_create_siblings = {'text': _('Clone'), 'view': 'sources:document_create_siblings', 'args': 'object.id', 'famfam': 'page_copy', 'permissions': [PERMISSION_DOCUMENT_CREATE]}
|
||||
|
||||
staging_file_delete = {'text': _(u'Delete'), 'view': 'sources:staging_file_delete', 'args': ['source.pk', 'object.encoded_filename'], 'famfam': 'delete', 'keep_query': True, 'permissions': [PERMISSION_DOCUMENT_NEW_VERSION, PERMISSION_DOCUMENT_CREATE]}
|
||||
staging_file_delete = {'text': _('Delete'), 'view': 'sources:staging_file_delete', 'args': ['source.pk', 'object.encoded_filename'], 'famfam': 'delete', 'keep_query': True, 'permissions': [PERMISSION_DOCUMENT_NEW_VERSION, PERMISSION_DOCUMENT_CREATE]}
|
||||
|
||||
setup_sources = {'text': _(u'Sources'), 'view': 'sources:setup_source_list', 'famfam': 'application_form', 'icon': 'application_form.png', 'permissions': [PERMISSION_SOURCES_SETUP_VIEW]}
|
||||
setup_source_create_webform = {'text': _(u'Add new webform source'), 'view': 'sources:setup_source_create', 'args': '"%s"' % SOURCE_CHOICE_WEB_FORM, 'famfam': 'application_form_add', 'permissions': [PERMISSION_SOURCES_SETUP_CREATE], 'conditional_highlight': lambda context: context.get('source_type') == SOURCE_CHOICE_WEB_FORM and 'source' not in context}
|
||||
setup_source_create_staging_folder = {'text': _(u'Add new staging folder'), 'view': 'sources:setup_source_create', 'args': '"%s"' % SOURCE_CHOICE_STAGING, 'famfam': 'folder_camera', 'permissions': [PERMISSION_SOURCES_SETUP_CREATE], 'conditional_highlight': lambda context: context.get('source_type') == SOURCE_CHOICE_STAGING and 'source' not in context}
|
||||
setup_source_create_watch_folder = {'text': _(u'Add new watch folder'), 'view': 'sources:setup_source_create', 'args': '"%s"' % SOURCE_CHOICE_WATCH, 'famfam': 'folder_magnify', 'permissions': [PERMISSION_SOURCES_SETUP_CREATE], 'conditional_highlight': lambda context: context.get('source_type') == SOURCE_CHOICE_WATCH and 'source' not in context}
|
||||
setup_source_create_pop3_email = {'text': _(u'Add new POP3 email'), 'view': 'sources:setup_source_create', 'args': '"%s"' % SOURCE_CHOICE_EMAIL_POP3, 'famfam': 'email', 'permissions': [PERMISSION_SOURCES_SETUP_CREATE], 'conditional_highlight': lambda context: context.get('source_type') == SOURCE_CHOICE_EMAIL_POP3 and 'source' not in context}
|
||||
setup_source_create_imap_email = {'text': _(u'Add new IMAP email'), 'view': 'sources:setup_source_create', 'args': '"%s"' % SOURCE_CHOICE_EMAIL_IMAP, 'famfam': 'email', 'permissions': [PERMISSION_SOURCES_SETUP_CREATE], 'conditional_highlight': lambda context: context.get('source_type') == SOURCE_CHOICE_EMAIL_IMAP and 'source' not in context}
|
||||
setup_source_delete = {'text': _(u'Delete'), 'view': 'sources:setup_source_delete', 'args': ['source.pk'], 'famfam': 'application_form_delete', 'permissions': [PERMISSION_SOURCES_SETUP_DELETE]}
|
||||
setup_source_edit = {'text': _(u'Edit'), 'view': 'sources:setup_source_edit', 'args': ['source.pk'], 'famfam': 'application_form_edit', 'permissions': [PERMISSION_SOURCES_SETUP_EDIT]}
|
||||
setup_sources = {'text': _('Sources'), 'view': 'sources:setup_source_list', 'famfam': 'application_form', 'icon': 'application_form.png', 'permissions': [PERMISSION_SOURCES_SETUP_VIEW]}
|
||||
setup_source_create_webform = {'text': _('Add new webform source'), 'view': 'sources:setup_source_create', 'args': '"%s"' % SOURCE_CHOICE_WEB_FORM, 'famfam': 'application_form_add', 'permissions': [PERMISSION_SOURCES_SETUP_CREATE], 'conditional_highlight': lambda context: context.get('source_type') == SOURCE_CHOICE_WEB_FORM and 'source' not in context}
|
||||
setup_source_create_staging_folder = {'text': _('Add new staging folder'), 'view': 'sources:setup_source_create', 'args': '"%s"' % SOURCE_CHOICE_STAGING, 'famfam': 'folder_camera', 'permissions': [PERMISSION_SOURCES_SETUP_CREATE], 'conditional_highlight': lambda context: context.get('source_type') == SOURCE_CHOICE_STAGING and 'source' not in context}
|
||||
setup_source_create_watch_folder = {'text': _('Add new watch folder'), 'view': 'sources:setup_source_create', 'args': '"%s"' % SOURCE_CHOICE_WATCH, 'famfam': 'folder_magnify', 'permissions': [PERMISSION_SOURCES_SETUP_CREATE], 'conditional_highlight': lambda context: context.get('source_type') == SOURCE_CHOICE_WATCH and 'source' not in context}
|
||||
setup_source_create_pop3_email = {'text': _('Add new POP3 email'), 'view': 'sources:setup_source_create', 'args': '"%s"' % SOURCE_CHOICE_EMAIL_POP3, 'famfam': 'email', 'permissions': [PERMISSION_SOURCES_SETUP_CREATE], 'conditional_highlight': lambda context: context.get('source_type') == SOURCE_CHOICE_EMAIL_POP3 and 'source' not in context}
|
||||
setup_source_create_imap_email = {'text': _('Add new IMAP email'), 'view': 'sources:setup_source_create', 'args': '"%s"' % SOURCE_CHOICE_EMAIL_IMAP, 'famfam': 'email', 'permissions': [PERMISSION_SOURCES_SETUP_CREATE], 'conditional_highlight': lambda context: context.get('source_type') == SOURCE_CHOICE_EMAIL_IMAP and 'source' not in context}
|
||||
setup_source_delete = {'text': _('Delete'), 'view': 'sources:setup_source_delete', 'args': ['source.pk'], 'famfam': 'application_form_delete', 'permissions': [PERMISSION_SOURCES_SETUP_DELETE]}
|
||||
setup_source_edit = {'text': _('Edit'), 'view': 'sources:setup_source_edit', 'args': ['source.pk'], 'famfam': 'application_form_edit', 'permissions': [PERMISSION_SOURCES_SETUP_EDIT]}
|
||||
|
||||
setup_source_transformation_list = {'text': _(u'Transformations'), 'view': 'sources:setup_source_transformation_list', 'args': ['source.pk'], 'famfam': 'shape_move_front', 'permissions': [PERMISSION_SOURCES_SETUP_EDIT]}
|
||||
setup_source_transformation_create = {'text': _(u'Add transformation'), 'view': 'sources:setup_source_transformation_create', 'args': ['source.pk'], 'famfam': 'shape_square_add', 'permissions': [PERMISSION_SOURCES_SETUP_EDIT]}
|
||||
setup_source_transformation_edit = {'text': _(u'Edit'), 'view': 'sources:setup_source_transformation_edit', 'args': 'transformation.pk', 'famfam': 'shape_square_edit', 'permissions': [PERMISSION_SOURCES_SETUP_EDIT]}
|
||||
setup_source_transformation_delete = {'text': _(u'Delete'), 'view': 'sources:setup_source_transformation_delete', 'args': 'transformation.pk', 'famfam': 'shape_square_delete', 'permissions': [PERMISSION_SOURCES_SETUP_EDIT]}
|
||||
setup_source_transformation_list = {'text': _('Transformations'), 'view': 'sources:setup_source_transformation_list', 'args': ['source.pk'], 'famfam': 'shape_move_front', 'permissions': [PERMISSION_SOURCES_SETUP_EDIT]}
|
||||
setup_source_transformation_create = {'text': _('Add transformation'), 'view': 'sources:setup_source_transformation_create', 'args': ['source.pk'], 'famfam': 'shape_square_add', 'permissions': [PERMISSION_SOURCES_SETUP_EDIT]}
|
||||
setup_source_transformation_edit = {'text': _('Edit'), 'view': 'sources:setup_source_transformation_edit', 'args': 'transformation.pk', 'famfam': 'shape_square_edit', 'permissions': [PERMISSION_SOURCES_SETUP_EDIT]}
|
||||
setup_source_transformation_delete = {'text': _('Delete'), 'view': 'sources:setup_source_transformation_delete', 'args': 'transformation.pk', 'famfam': 'shape_square_delete', 'permissions': [PERMISSION_SOURCES_SETUP_EDIT]}
|
||||
|
||||
source_list = {'text': _(u'Document sources'), 'view': 'sources:setup_web_form_list', 'famfam': 'page_add', 'permissions': [PERMISSION_SOURCES_SETUP_VIEW]}
|
||||
source_list = {'text': _('Document sources'), 'view': 'sources:setup_web_form_list', 'famfam': 'page_add', 'permissions': [PERMISSION_SOURCES_SETUP_VIEW]}
|
||||
|
||||
upload_version = {'text': _(u'Upload new version'), 'view': 'sources:upload_version', 'args': 'object.pk', 'famfam': 'page_add', 'permissions': [PERMISSION_DOCUMENT_NEW_VERSION]}
|
||||
upload_version = {'text': _('Upload new version'), 'view': 'sources:upload_version', 'args': 'object.pk', 'famfam': 'page_add', 'permissions': [PERMISSION_DOCUMENT_NEW_VERSION]}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
SOURCE_UNCOMPRESS_CHOICE_Y = 'y'
|
||||
@@ -5,14 +7,14 @@ SOURCE_UNCOMPRESS_CHOICE_N = 'n'
|
||||
SOURCE_UNCOMPRESS_CHOICE_ASK = 'a'
|
||||
|
||||
SOURCE_UNCOMPRESS_CHOICES = (
|
||||
(SOURCE_UNCOMPRESS_CHOICE_Y, _(u'Always')),
|
||||
(SOURCE_UNCOMPRESS_CHOICE_N, _(u'Never')),
|
||||
(SOURCE_UNCOMPRESS_CHOICE_Y, _('Always')),
|
||||
(SOURCE_UNCOMPRESS_CHOICE_N, _('Never')),
|
||||
)
|
||||
|
||||
SOURCE_INTERACTIVE_UNCOMPRESS_CHOICES = (
|
||||
(SOURCE_UNCOMPRESS_CHOICE_Y, _(u'Always')),
|
||||
(SOURCE_UNCOMPRESS_CHOICE_N, _(u'Never')),
|
||||
(SOURCE_UNCOMPRESS_CHOICE_ASK, _(u'Ask user'))
|
||||
(SOURCE_UNCOMPRESS_CHOICE_Y, _('Always')),
|
||||
(SOURCE_UNCOMPRESS_CHOICE_N, _('Never')),
|
||||
(SOURCE_UNCOMPRESS_CHOICE_ASK, _('Ask user'))
|
||||
)
|
||||
|
||||
SOURCE_CHOICE_WEB_FORM = 'webform'
|
||||
@@ -22,11 +24,11 @@ SOURCE_CHOICE_EMAIL_POP3 = 'pop3'
|
||||
SOURCE_CHOICE_EMAIL_IMAP = 'imap'
|
||||
|
||||
SOURCE_CHOICES = (
|
||||
(SOURCE_CHOICE_WEB_FORM, _(u'Web form')),
|
||||
(SOURCE_CHOICE_STAGING, _(u'Staging folder')),
|
||||
(SOURCE_CHOICE_WATCH, _(u'Watch folder')),
|
||||
(SOURCE_CHOICE_EMAIL_POP3, _(u'POP3 email')),
|
||||
(SOURCE_CHOICE_EMAIL_IMAP, _(u'IMAP email')),
|
||||
(SOURCE_CHOICE_WEB_FORM, _('Web form')),
|
||||
(SOURCE_CHOICE_STAGING, _('Staging folder')),
|
||||
(SOURCE_CHOICE_WATCH, _('Watch folder')),
|
||||
(SOURCE_CHOICE_EMAIL_POP3, _('POP3 email')),
|
||||
(SOURCE_CHOICE_EMAIL_IMAP, _('IMAP email')),
|
||||
)
|
||||
|
||||
DEFAULT_INTERVAL = 60
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from ast import literal_eval
|
||||
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from __future__ import absolute_import
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from ast import literal_eval
|
||||
from email.Utils import collapse_rfc2231_value
|
||||
@@ -25,21 +25,21 @@ from documents.models import Document, DocumentType
|
||||
from metadata.api import save_metadata_list
|
||||
|
||||
from .classes import Attachment, SourceUploadedFile, StagingFile
|
||||
from .literals import (DEFAULT_INTERVAL, DEFAULT_POP3_TIMEOUT,
|
||||
DEFAULT_IMAP_MAILBOX, SOURCE_CHOICES,
|
||||
SOURCE_CHOICE_STAGING, SOURCE_CHOICE_WATCH,
|
||||
SOURCE_CHOICE_WEB_FORM,
|
||||
SOURCE_INTERACTIVE_UNCOMPRESS_CHOICES,
|
||||
SOURCE_UNCOMPRESS_CHOICES, SOURCE_UNCOMPRESS_CHOICE_Y,
|
||||
SOURCE_CHOICE_EMAIL_IMAP, SOURCE_CHOICE_EMAIL_POP3)
|
||||
from .literals import (
|
||||
DEFAULT_INTERVAL, DEFAULT_POP3_TIMEOUT, DEFAULT_IMAP_MAILBOX,
|
||||
SOURCE_CHOICES, SOURCE_CHOICE_STAGING, SOURCE_CHOICE_WATCH,
|
||||
SOURCE_CHOICE_WEB_FORM, SOURCE_INTERACTIVE_UNCOMPRESS_CHOICES,
|
||||
SOURCE_UNCOMPRESS_CHOICES, SOURCE_UNCOMPRESS_CHOICE_Y,
|
||||
SOURCE_CHOICE_EMAIL_IMAP, SOURCE_CHOICE_EMAIL_POP3
|
||||
)
|
||||
from .managers import SourceTransformationManager
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class Source(models.Model):
|
||||
title = models.CharField(max_length=64, verbose_name=_(u'Title'))
|
||||
enabled = models.BooleanField(default=True, verbose_name=_(u'Enabled'))
|
||||
title = models.CharField(max_length=64, verbose_name=_('Title'))
|
||||
enabled = models.BooleanField(default=True, verbose_name=_('Enabled'))
|
||||
|
||||
objects = InheritanceManager()
|
||||
|
||||
@@ -48,10 +48,10 @@ class Source(models.Model):
|
||||
return unicode(dict(SOURCE_CHOICES).get(cls.source_type))
|
||||
|
||||
def __unicode__(self):
|
||||
return u'%s' % self.title
|
||||
return '%s' % self.title
|
||||
|
||||
def fullname(self):
|
||||
return u' '.join([self.class_fullname(), '"%s"' % self.title])
|
||||
return ' '.join([self.class_fullname(), '"%s"' % self.title])
|
||||
|
||||
def get_transformation_list(self):
|
||||
return SourceTransformation.transformations.get_for_object_as_list(self)
|
||||
@@ -82,27 +82,27 @@ class Source(models.Model):
|
||||
|
||||
class Meta:
|
||||
ordering = ('title',)
|
||||
verbose_name = _(u'Source')
|
||||
verbose_name_plural = _(u'Sources')
|
||||
verbose_name = _('Source')
|
||||
verbose_name_plural = _('Sources')
|
||||
|
||||
|
||||
class InteractiveSource(Source):
|
||||
objects = InheritanceManager()
|
||||
|
||||
class Meta:
|
||||
verbose_name = _(u'Interactive source')
|
||||
verbose_name_plural = _(u'Interactive sources')
|
||||
verbose_name = _('Interactive source')
|
||||
verbose_name_plural = _('Interactive sources')
|
||||
|
||||
|
||||
class StagingFolderSource(InteractiveSource):
|
||||
is_interactive = True
|
||||
source_type = SOURCE_CHOICE_STAGING
|
||||
|
||||
folder_path = models.CharField(max_length=255, verbose_name=_(u'Folder path'), help_text=_(u'Server side filesystem path.'))
|
||||
preview_width = models.IntegerField(verbose_name=_(u'Preview width'), help_text=_(u'Width value to be passed to the converter backend.'))
|
||||
preview_height = models.IntegerField(blank=True, null=True, verbose_name=_(u'Preview height'), help_text=_(u'Height value to be passed to the converter backend.'))
|
||||
uncompress = models.CharField(max_length=1, choices=SOURCE_INTERACTIVE_UNCOMPRESS_CHOICES, verbose_name=_(u'Uncompress'), help_text=_(u'Whether to expand or not compressed archives.'))
|
||||
delete_after_upload = models.BooleanField(default=True, verbose_name=_(u'Delete after upload'), help_text=_(u'Delete the file after is has been successfully uploaded.'))
|
||||
folder_path = models.CharField(max_length=255, verbose_name=_('Folder path'), help_text=_('Server side filesystem path.'))
|
||||
preview_width = models.IntegerField(verbose_name=_('Preview width'), help_text=_('Width value to be passed to the converter backend.'))
|
||||
preview_height = models.IntegerField(blank=True, null=True, verbose_name=_('Preview height'), help_text=_('Height value to be passed to the converter backend.'))
|
||||
uncompress = models.CharField(max_length=1, choices=SOURCE_INTERACTIVE_UNCOMPRESS_CHOICES, verbose_name=_('Uncompress'), help_text=_('Whether to expand or not compressed archives.'))
|
||||
delete_after_upload = models.BooleanField(default=True, verbose_name=_('Delete after upload'), help_text=_('Delete the file after is has been successfully uploaded.'))
|
||||
|
||||
def get_preview_size(self):
|
||||
dimensions = []
|
||||
@@ -120,7 +120,7 @@ class StagingFolderSource(InteractiveSource):
|
||||
for entry in sorted([os.path.normcase(f) for f in os.listdir(self.folder_path) if os.path.isfile(os.path.join(self.folder_path, f))]):
|
||||
yield self.get_file(filename=entry)
|
||||
except OSError as exception:
|
||||
raise Exception(_(u'Unable get list of staging files: %s') % exception)
|
||||
raise Exception(_('Unable get list of staging files: %s') % exception)
|
||||
|
||||
def get_upload_file_object(self, form_data):
|
||||
staging_file = self.get_file(encoded_filename=form_data['staging_file_id'])
|
||||
@@ -131,11 +131,11 @@ class StagingFolderSource(InteractiveSource):
|
||||
try:
|
||||
upload_file_object.extra_data.delete()
|
||||
except Exception as exception:
|
||||
raise Exception(_(u'Error deleting staging file; %s') % exception)
|
||||
raise Exception(_('Error deleting staging file; %s') % exception)
|
||||
|
||||
class Meta:
|
||||
verbose_name = _(u'Staging folder')
|
||||
verbose_name_plural = _(u'Staging folders')
|
||||
verbose_name = _('Staging folder')
|
||||
verbose_name_plural = _('Staging folders')
|
||||
|
||||
|
||||
class WebFormSource(InteractiveSource):
|
||||
@@ -143,23 +143,23 @@ class WebFormSource(InteractiveSource):
|
||||
source_type = SOURCE_CHOICE_WEB_FORM
|
||||
|
||||
# TODO: unify uncompress as an InteractiveSource field
|
||||
uncompress = models.CharField(max_length=1, choices=SOURCE_INTERACTIVE_UNCOMPRESS_CHOICES, verbose_name=_(u'Uncompress'), help_text=_(u'Whether to expand or not compressed archives.'))
|
||||
uncompress = models.CharField(max_length=1, choices=SOURCE_INTERACTIVE_UNCOMPRESS_CHOICES, verbose_name=_('Uncompress'), help_text=_('Whether to expand or not compressed archives.'))
|
||||
# Default path
|
||||
|
||||
def get_upload_file_object(self, form_data):
|
||||
return SourceUploadedFile(source=self, file=form_data['file'])
|
||||
|
||||
class Meta:
|
||||
verbose_name = _(u'Web form')
|
||||
verbose_name_plural = _(u'Web forms')
|
||||
verbose_name = _('Web form')
|
||||
verbose_name_plural = _('Web forms')
|
||||
|
||||
|
||||
class OutOfProcessSource(Source):
|
||||
is_interactive = False
|
||||
|
||||
class Meta:
|
||||
verbose_name = _(u'Out of process')
|
||||
verbose_name_plural = _(u'Out of process')
|
||||
verbose_name = _('Out of process')
|
||||
verbose_name_plural = _('Out of process')
|
||||
|
||||
|
||||
class IntervalBaseModel(OutOfProcessSource):
|
||||
@@ -337,7 +337,7 @@ class IMAPEmail(EmailBaseModel):
|
||||
class WatchFolderSource(IntervalBaseModel):
|
||||
source_type = SOURCE_CHOICE_WATCH
|
||||
|
||||
folder_path = models.CharField(max_length=255, verbose_name=_(u'Folder path'), help_text=_(u'Server side filesystem path.'))
|
||||
folder_path = models.CharField(max_length=255, verbose_name=_('Folder path'), help_text=_('Server side filesystem path.'))
|
||||
|
||||
def check_source(self):
|
||||
for file_name in os.listdir(self.folder_path):
|
||||
@@ -349,12 +349,12 @@ class WatchFolderSource(IntervalBaseModel):
|
||||
os.unlink(full_path)
|
||||
|
||||
class Meta:
|
||||
verbose_name = _(u'Watch folder')
|
||||
verbose_name_plural = _(u'Watch folders')
|
||||
verbose_name = _('Watch folder')
|
||||
verbose_name_plural = _('Watch folders')
|
||||
|
||||
|
||||
class ArgumentsValidator(object):
|
||||
message = _(u'Enter a valid value.')
|
||||
message = _('Enter a valid value.')
|
||||
code = 'invalid'
|
||||
|
||||
def __init__(self, message=None, code=None):
|
||||
@@ -382,9 +382,9 @@ class SourceTransformation(models.Model):
|
||||
content_type = models.ForeignKey(ContentType)
|
||||
object_id = models.PositiveIntegerField()
|
||||
content_object = generic.GenericForeignKey('content_type', 'object_id')
|
||||
order = models.PositiveIntegerField(default=0, blank=True, null=True, verbose_name=_(u'Order'), db_index=True)
|
||||
transformation = models.CharField(choices=get_available_transformations_choices(), max_length=128, verbose_name=_(u'Transformation'))
|
||||
arguments = models.TextField(blank=True, null=True, verbose_name=_(u'Arguments'), help_text=_(u'Use dictionaries to indentify arguments, example: %s') % u'{\'degrees\':90}', validators=[ArgumentsValidator()])
|
||||
order = models.PositiveIntegerField(default=0, blank=True, null=True, verbose_name=_('Order'), db_index=True)
|
||||
transformation = models.CharField(choices=get_available_transformations_choices(), max_length=128, verbose_name=_('Transformation'))
|
||||
arguments = models.TextField(blank=True, null=True, verbose_name=_('Arguments'), help_text=_('Use dictionaries to indentify arguments, example: %s') % '{\'degrees\':90}', validators=[ArgumentsValidator()])
|
||||
|
||||
objects = models.Manager()
|
||||
transformations = SourceTransformationManager()
|
||||
@@ -394,5 +394,5 @@ class SourceTransformation(models.Model):
|
||||
|
||||
class Meta:
|
||||
ordering = ('order',)
|
||||
verbose_name = _(u'Document source transformation')
|
||||
verbose_name_plural = _(u'Document source transformations')
|
||||
verbose_name = _('Document source transformation')
|
||||
verbose_name_plural = _('Document source transformations')
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, unicode_literals
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from permissions.models import Permission, PermissionNamespace
|
||||
|
||||
sources_setup_namespace = PermissionNamespace('sources_setup', _(u'Sources setup'))
|
||||
PERMISSION_SOURCES_SETUP_CREATE = Permission.objects.register(sources_setup_namespace, 'sources_setup_create', _(u'Create new document sources'))
|
||||
PERMISSION_SOURCES_SETUP_DELETE = Permission.objects.register(sources_setup_namespace, 'sources_setup_delete', _(u'Delete document sources'))
|
||||
PERMISSION_SOURCES_SETUP_EDIT = Permission.objects.register(sources_setup_namespace, 'sources_setup_edit', _(u'Edit document sources'))
|
||||
PERMISSION_SOURCES_SETUP_VIEW = Permission.objects.register(sources_setup_namespace, 'sources_setup_view', _(u'View existing document sources'))
|
||||
sources_setup_namespace = PermissionNamespace('sources_setup', _('Sources setup'))
|
||||
PERMISSION_SOURCES_SETUP_CREATE = Permission.objects.register(sources_setup_namespace, 'sources_setup_create', _('Create new document sources'))
|
||||
PERMISSION_SOURCES_SETUP_DELETE = Permission.objects.register(sources_setup_namespace, 'sources_setup_delete', _('Delete document sources'))
|
||||
PERMISSION_SOURCES_SETUP_EDIT = Permission.objects.register(sources_setup_namespace, 'sources_setup_edit', _('Edit document sources'))
|
||||
PERMISSION_SOURCES_SETUP_VIEW = Permission.objects.register(sources_setup_namespace, 'sources_setup_view', _('View existing document sources'))
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from __future__ import absolute_import
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import logging
|
||||
|
||||
|
||||
@@ -38,10 +38,10 @@ def task_source_upload_document(label, document_type_id, shared_uploaded_file_id
|
||||
|
||||
# TODO: Report/record how was file uploaded
|
||||
# if result['is_compressed'] is None:
|
||||
# messages.success(request, _(u'File uploaded successfully.'))
|
||||
# messages.success(request, _('File uploaded successfully.'))
|
||||
|
||||
# if result['is_compressed'] is True:
|
||||
# messages.success(request, _(u'File uncompressed successfully and uploaded as individual files.'))
|
||||
# messages.success(request, _('File uncompressed successfully and uploaded as individual files.'))
|
||||
|
||||
# if result['is_compressed'] is False:
|
||||
# messages.warning(request, _(u'File was not a compressed file, uploaded as it was.'))
|
||||
# messages.warning(request, _('File was not a compressed file, uploaded as it was.'))
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from json import loads
|
||||
|
||||
from django.conf import settings
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
from __future__ import absolute_import
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.conf.urls import patterns, url
|
||||
|
||||
from .api_views import (APIStagingSourceFileView, APIStagingSourceFileImageView,
|
||||
APIStagingSourceListView, APIStagingSourceView)
|
||||
from .api_views import (
|
||||
APIStagingSourceFileView, APIStagingSourceFileImageView,
|
||||
APIStagingSourceListView, APIStagingSourceView
|
||||
)
|
||||
from .views import UploadInteractiveVersionView, UploadInteractiveView
|
||||
from .wizards import DocumentCreateWizard
|
||||
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
from .forms import (POP3EmailSetupForm, IMAPEmailSetupForm,
|
||||
StagingFolderSetupForm, StagingUploadForm,
|
||||
WatchFolderSetupForm, WebFormSetupForm, WebFormUploadForm)
|
||||
from .literals import (SOURCE_CHOICE_EMAIL_IMAP, SOURCE_CHOICE_EMAIL_POP3,
|
||||
SOURCE_CHOICE_STAGING, SOURCE_CHOICE_WATCH,
|
||||
SOURCE_CHOICE_WEB_FORM)
|
||||
from .models import (IMAPEmail, POP3Email, StagingFolderSource,
|
||||
WatchFolderSource, WebFormSource)
|
||||
from .forms import (
|
||||
POP3EmailSetupForm, IMAPEmailSetupForm,
|
||||
StagingFolderSetupForm, StagingUploadForm, WatchFolderSetupForm,
|
||||
WebFormSetupForm, WebFormUploadForm
|
||||
)
|
||||
from .literals import (
|
||||
SOURCE_CHOICE_EMAIL_IMAP, SOURCE_CHOICE_EMAIL_POP3, SOURCE_CHOICE_STAGING,
|
||||
SOURCE_CHOICE_WATCH, SOURCE_CHOICE_WEB_FORM
|
||||
)
|
||||
from .models import (
|
||||
IMAPEmail, POP3Email, StagingFolderSource, WatchFolderSource, WebFormSource
|
||||
)
|
||||
|
||||
|
||||
def get_class(source_type):
|
||||
|
||||
+59
-52
@@ -1,4 +1,4 @@
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, unicode_literals
|
||||
|
||||
from django.conf import settings
|
||||
from django.contrib import messages
|
||||
@@ -15,22 +15,29 @@ from common.models import SharedUploadedFile
|
||||
from common.utils import encapsulate
|
||||
from common.views import MultiFormView
|
||||
from documents.models import DocumentType, Document
|
||||
from documents.permissions import (PERMISSION_DOCUMENT_CREATE,
|
||||
PERMISSION_DOCUMENT_NEW_VERSION)
|
||||
from documents.permissions import (
|
||||
PERMISSION_DOCUMENT_CREATE, PERMISSION_DOCUMENT_NEW_VERSION
|
||||
)
|
||||
from documents.tasks import task_upload_new_version
|
||||
from metadata.api import decode_metadata_from_url, metadata_repr_as_list
|
||||
from permissions.models import Permission
|
||||
|
||||
from .forms import (NewDocumentForm, NewVersionForm, SourceTransformationForm,
|
||||
SourceTransformationForm_create)
|
||||
from .literals import (SOURCE_CHOICE_STAGING, SOURCE_CHOICE_WEB_FORM,
|
||||
SOURCE_UNCOMPRESS_CHOICE_ASK, SOURCE_UNCOMPRESS_CHOICE_Y)
|
||||
from .models import (InteractiveSource, Source, StagingFolderSource,
|
||||
SourceTransformation, WebFormSource)
|
||||
from .permissions import (PERMISSION_SOURCES_SETUP_CREATE,
|
||||
PERMISSION_SOURCES_SETUP_DELETE,
|
||||
PERMISSION_SOURCES_SETUP_EDIT,
|
||||
PERMISSION_SOURCES_SETUP_VIEW)
|
||||
from .forms import (
|
||||
NewDocumentForm, NewVersionForm, SourceTransformationForm,
|
||||
SourceTransformationForm_create
|
||||
)
|
||||
from .literals import (
|
||||
SOURCE_CHOICE_STAGING, SOURCE_CHOICE_WEB_FORM, SOURCE_UNCOMPRESS_CHOICE_ASK,
|
||||
SOURCE_UNCOMPRESS_CHOICE_Y
|
||||
)
|
||||
from .models import (
|
||||
InteractiveSource, Source, StagingFolderSource, SourceTransformation,
|
||||
WebFormSource
|
||||
)
|
||||
from .permissions import (
|
||||
PERMISSION_SOURCES_SETUP_CREATE, PERMISSION_SOURCES_SETUP_DELETE,
|
||||
PERMISSION_SOURCES_SETUP_EDIT, PERMISSION_SOURCES_SETUP_VIEW
|
||||
)
|
||||
from .tasks import task_source_upload_document
|
||||
from .utils import get_class, get_form_class, get_upload_form_class
|
||||
|
||||
@@ -56,10 +63,10 @@ def conditional_highlight_factory(obj):
|
||||
|
||||
def get_tab_link_for_source(source, document=None):
|
||||
if document:
|
||||
view = u'sources:upload_version'
|
||||
view = 'sources:upload_version'
|
||||
args = [document.pk, source.pk]
|
||||
else:
|
||||
view = u'sources:upload_interactive'
|
||||
view = 'sources:upload_interactive'
|
||||
args = [source.pk]
|
||||
|
||||
return {
|
||||
@@ -102,7 +109,7 @@ class UploadBaseView(MultiFormView):
|
||||
self.source = InteractiveSource.objects.filter(enabled=True).select_subclasses().first()
|
||||
|
||||
if InteractiveSource.objects.filter(enabled=True).count() == 0:
|
||||
messages.error(request, _(u'No interactive document sources have been defined or none have been enabled, create one before proceeding.'))
|
||||
messages.error(request, _('No interactive document sources have been defined or none have been enabled, create one before proceeding.'))
|
||||
return HttpResponseRedirect(reverse('sources:setup_source_list'))
|
||||
|
||||
return super(UploadBaseView, self).dispatch(request, *args, **kwargs)
|
||||
@@ -130,7 +137,7 @@ class UploadBaseView(MultiFormView):
|
||||
{
|
||||
'name': 'main/generic_list_subtemplate.html',
|
||||
'context': {
|
||||
'title': _(u'Files in staging path'),
|
||||
'title': _('Files in staging path'),
|
||||
'object_list': staging_filelist,
|
||||
'hide_link': True,
|
||||
}
|
||||
@@ -214,7 +221,7 @@ class UploadInteractiveView(UploadBaseView):
|
||||
source_id=self.source.pk,
|
||||
user_id=user_id,
|
||||
), queue='uploads')
|
||||
messages.success(self.request, _(u'New document queued for uploaded and will be available shortly.'))
|
||||
messages.success(self.request, _('New document queued for uploaded and will be available shortly.'))
|
||||
return HttpResponseRedirect(self.request.get_full_path())
|
||||
|
||||
def create_source_form_form(self, **kwargs):
|
||||
@@ -239,7 +246,7 @@ class UploadInteractiveView(UploadBaseView):
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(UploadInteractiveView, self).get_context_data(**kwargs)
|
||||
context['title'] = _(u'Upload a local document from source: %s') % self.source.title
|
||||
context['title'] = _('Upload a local document from source: %s') % self.source.title
|
||||
|
||||
context.update(
|
||||
{
|
||||
@@ -247,15 +254,15 @@ class UploadInteractiveView(UploadBaseView):
|
||||
{
|
||||
'name': 'main/generic_subtemplate.html',
|
||||
'context': {
|
||||
'title': _(u'Current document type'),
|
||||
'paragraphs': [self.document_type if self.document_type else _(u'None')],
|
||||
'title': _('Current document type'),
|
||||
'paragraphs': [self.document_type if self.document_type else _('None')],
|
||||
'side_bar': True,
|
||||
}
|
||||
},
|
||||
{
|
||||
'name': 'main/generic_subtemplate.html',
|
||||
'context': {
|
||||
'title': _(u'Current metadata'),
|
||||
'title': _('Current metadata'),
|
||||
'paragraphs': metadata_repr_as_list(decode_metadata_from_url(self.request.GET)),
|
||||
'side_bar': True,
|
||||
}
|
||||
@@ -303,7 +310,7 @@ class UploadInteractiveVersionView(UploadBaseView):
|
||||
comment=forms['document_form'].cleaned_data.get('comment')
|
||||
), queue='uploads')
|
||||
|
||||
messages.success(self.request, _(u'New document version queued for uploaded and will be available shortly.'))
|
||||
messages.success(self.request, _('New document version queued for uploaded and will be available shortly.'))
|
||||
return HttpResponseRedirect(reverse('documents:document_version_list', args=[self.document.pk]))
|
||||
|
||||
def create_source_form_form(self, **kwargs):
|
||||
@@ -329,7 +336,7 @@ class UploadInteractiveVersionView(UploadBaseView):
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(UploadInteractiveVersionView, self).get_context_data(**kwargs)
|
||||
context['object'] = self.document
|
||||
context['title'] = _(u'Upload a new version from source: %s') % self.source.title
|
||||
context['title'] = _('Upload a new version from source: %s') % self.source.title
|
||||
|
||||
return context
|
||||
|
||||
@@ -345,9 +352,9 @@ def staging_file_delete(request, staging_folder_pk, encoded_filename):
|
||||
if request.method == 'POST':
|
||||
try:
|
||||
staging_file.delete()
|
||||
messages.success(request, _(u'Staging file delete successfully.'))
|
||||
messages.success(request, _('Staging file delete successfully.'))
|
||||
except Exception as exception:
|
||||
messages.error(request, _(u'Staging file delete error; %s.') % exception)
|
||||
messages.error(request, _('Staging file delete error; %s.') % exception)
|
||||
return HttpResponseRedirect(next)
|
||||
|
||||
results = get_active_tab_links()
|
||||
@@ -400,15 +407,15 @@ def setup_source_edit(request, source_id):
|
||||
if form.is_valid():
|
||||
try:
|
||||
form.save()
|
||||
messages.success(request, _(u'Source edited successfully'))
|
||||
messages.success(request, _('Source edited successfully'))
|
||||
return HttpResponseRedirect(next)
|
||||
except Exception as exception:
|
||||
messages.error(request, _(u'Error editing source; %s') % exception)
|
||||
messages.error(request, _('Error editing source; %s') % exception)
|
||||
else:
|
||||
form = form_class(instance=source)
|
||||
|
||||
return render_to_response('main/generic_form.html', {
|
||||
'title': _(u'Edit source: %s') % source,
|
||||
'title': _('Edit source: %s') % source,
|
||||
'form': form,
|
||||
'source': source,
|
||||
'navigation_object_name': 'source',
|
||||
@@ -427,15 +434,15 @@ def setup_source_delete(request, source_id):
|
||||
if request.method == 'POST':
|
||||
try:
|
||||
source.delete()
|
||||
messages.success(request, _(u'Source "%s" deleted successfully.') % source)
|
||||
messages.success(request, _('Source "%s" deleted successfully.') % source)
|
||||
except Exception as exception:
|
||||
messages.error(request, _(u'Error deleting source "%(source)s": %(error)s') % {
|
||||
messages.error(request, _('Error deleting source "%(source)s": %(error)s') % {
|
||||
'source': source, 'error': exception
|
||||
})
|
||||
return HttpResponseRedirect(redirect_view)
|
||||
|
||||
context = {
|
||||
'title': _(u'Are you sure you wish to delete the source: %s?') % source,
|
||||
'title': _('Are you sure you wish to delete the source: %s?') % source,
|
||||
'source': source,
|
||||
'navigation_object_name': 'source',
|
||||
'delete_view': True,
|
||||
@@ -458,15 +465,15 @@ def setup_source_create(request, source_type):
|
||||
if form.is_valid():
|
||||
try:
|
||||
form.save()
|
||||
messages.success(request, _(u'Source created successfully'))
|
||||
messages.success(request, _('Source created successfully'))
|
||||
return HttpResponseRedirect(reverse('sources:setup_source_list'))
|
||||
except Exception as exception:
|
||||
messages.error(request, _(u'Error creating source; %s') % exception)
|
||||
messages.error(request, _('Error creating source; %s') % exception)
|
||||
else:
|
||||
form = form_class()
|
||||
|
||||
return render_to_response('main/generic_form.html', {
|
||||
'title': _(u'Create new source of type: %s') % cls.class_fullname(),
|
||||
'title': _('Create new source of type: %s') % cls.class_fullname(),
|
||||
'form': form,
|
||||
'source_type': source_type,
|
||||
'navigation_object_name': 'source',
|
||||
@@ -480,14 +487,14 @@ def setup_source_transformation_list(request, source_id):
|
||||
|
||||
context = {
|
||||
'object_list': SourceTransformation.transformations.get_for_object(source),
|
||||
'title': _(u'Transformations for: %s') % source.fullname(),
|
||||
'title': _('Transformations for: %s') % source.fullname(),
|
||||
'source': source,
|
||||
'navigation_object_name': 'source',
|
||||
'list_object_variable_name': 'transformation',
|
||||
'extra_columns': [
|
||||
{'name': _(u'Order'), 'attribute': 'order'},
|
||||
{'name': _(u'Transformation'), 'attribute': encapsulate(lambda x: x.get_transformation_display())},
|
||||
{'name': _(u'Arguments'), 'attribute': 'arguments'}
|
||||
{'name': _('Order'), 'attribute': 'order'},
|
||||
{'name': _('Transformation'), 'attribute': encapsulate(lambda x: x.get_transformation_display())},
|
||||
{'name': _('Arguments'), 'attribute': 'arguments'}
|
||||
],
|
||||
'hide_link': True,
|
||||
'hide_object': True,
|
||||
@@ -509,21 +516,21 @@ def setup_source_transformation_edit(request, transformation_id):
|
||||
if form.is_valid():
|
||||
try:
|
||||
form.save()
|
||||
messages.success(request, _(u'Source transformation edited successfully'))
|
||||
messages.success(request, _('Source transformation edited successfully'))
|
||||
return HttpResponseRedirect(next)
|
||||
except Exception as exception:
|
||||
messages.error(request, _(u'Error editing source transformation; %s') % exception)
|
||||
messages.error(request, _('Error editing source transformation; %s') % exception)
|
||||
else:
|
||||
form = SourceTransformationForm(instance=source_transformation)
|
||||
|
||||
return render_to_response('main/generic_form.html', {
|
||||
'title': _(u'Edit transformation: %s') % source_transformation,
|
||||
'title': _('Edit transformation: %s') % source_transformation,
|
||||
'form': form,
|
||||
'source': source_transformation.content_object,
|
||||
'transformation': source_transformation,
|
||||
'navigation_object_list': [
|
||||
{'object': 'source', 'name': _(u'Source')},
|
||||
{'object': 'transformation', 'name': _(u'Transformation')}
|
||||
{'object': 'source', 'name': _('Source')},
|
||||
{'object': 'transformation', 'name': _('Transformation')}
|
||||
],
|
||||
'next': next,
|
||||
}, context_instance=RequestContext(request))
|
||||
@@ -539,9 +546,9 @@ def setup_source_transformation_delete(request, transformation_id):
|
||||
if request.method == 'POST':
|
||||
try:
|
||||
source_transformation.delete()
|
||||
messages.success(request, _(u'Source transformation deleted successfully.'))
|
||||
messages.success(request, _('Source transformation deleted successfully.'))
|
||||
except Exception as exception:
|
||||
messages.error(request, _(u'Error deleting source transformation; %(error)s') % {
|
||||
messages.error(request, _('Error deleting source transformation; %(error)s') % {
|
||||
'error': exception}
|
||||
)
|
||||
return HttpResponseRedirect(redirect_view)
|
||||
@@ -551,10 +558,10 @@ def setup_source_transformation_delete(request, transformation_id):
|
||||
'transformation': source_transformation,
|
||||
'source': source_transformation.content_object,
|
||||
'navigation_object_list': [
|
||||
{'object': 'source', 'name': _(u'Source')},
|
||||
{'object': 'transformation', 'name': _(u'Transformation')}
|
||||
{'object': 'source', 'name': _('Source')},
|
||||
{'object': 'transformation', 'name': _('Transformation')}
|
||||
],
|
||||
'title': _(u'Are you sure you wish to delete source transformation "%(transformation)s"') % {
|
||||
'title': _('Are you sure you wish to delete source transformation "%(transformation)s"') % {
|
||||
'transformation': source_transformation.get_transformation_display(),
|
||||
},
|
||||
'previous': previous,
|
||||
@@ -575,10 +582,10 @@ def setup_source_transformation_create(request, source_id):
|
||||
source_tranformation = form.save(commit=False)
|
||||
source_tranformation.content_object = source
|
||||
source_tranformation.save()
|
||||
messages.success(request, _(u'Source transformation created successfully'))
|
||||
messages.success(request, _('Source transformation created successfully'))
|
||||
return HttpResponseRedirect(redirect_view)
|
||||
except Exception as exception:
|
||||
messages.error(request, _(u'Error creating source transformation; %s') % exception)
|
||||
messages.error(request, _('Error creating source transformation; %s') % exception)
|
||||
else:
|
||||
form = SourceTransformationForm_create()
|
||||
|
||||
@@ -586,5 +593,5 @@ def setup_source_transformation_create(request, source_id):
|
||||
'form': form,
|
||||
'source': source,
|
||||
'navigation_object_name': 'source',
|
||||
'title': _(u'Create new transformation for source: %s') % source,
|
||||
'title': _('Create new transformation for source: %s') % source,
|
||||
}, context_instance=RequestContext(request))
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.conf import settings
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.utils.html import strip_tags
|
||||
@@ -17,7 +19,7 @@ def staging_file_thumbnail(staging_file, **kwargs):
|
||||
def staging_file_html_widget(staging_file, click_view=None, page=DEFAULT_PAGE_NUMBER, zoom=DEFAULT_ZOOM_LEVEL, rotation=DEFAULT_ROTATION, gallery_name=None, fancybox_class='fancybox-staging', image_class='lazy-load', title=None, size=THUMBNAIL_SIZE, nolazyload=False):
|
||||
result = []
|
||||
|
||||
alt_text = _(u'Staging file page image')
|
||||
alt_text = _('Staging file page image')
|
||||
|
||||
query_dict = {
|
||||
'page': page,
|
||||
@@ -27,37 +29,37 @@ def staging_file_html_widget(staging_file, click_view=None, page=DEFAULT_PAGE_NU
|
||||
}
|
||||
|
||||
if gallery_name:
|
||||
gallery_template = u'rel="%s"' % gallery_name
|
||||
gallery_template = 'rel="%s"' % gallery_name
|
||||
else:
|
||||
gallery_template = u''
|
||||
gallery_template = ''
|
||||
|
||||
query_string = urlencode(query_dict)
|
||||
|
||||
preview_view = u'%s?%s' % (reverse('stagingfolderfile-image-view', args=[staging_file.staging_folder.pk, staging_file.encoded_filename]), query_string)
|
||||
preview_view = '%s?%s' % (reverse('stagingfolderfile-image-view', args=[staging_file.staging_folder.pk, staging_file.encoded_filename]), query_string)
|
||||
|
||||
plain_template = []
|
||||
plain_template.append(u'<img src="%s" alt="%s" />' % (preview_view, alt_text))
|
||||
plain_template.append('<img src="%s" alt="%s" />' % (preview_view, alt_text))
|
||||
|
||||
result.append(u'<div class="tc" id="staging_file-%s-%d">' % (staging_file.filename, page if page else DEFAULT_PAGE_NUMBER))
|
||||
result.append('<div class="tc" id="staging_file-%s-%d">' % (staging_file.filename, page if page else DEFAULT_PAGE_NUMBER))
|
||||
|
||||
if title:
|
||||
title_template = u'title="%s"' % strip_tags(title)
|
||||
title_template = 'title="%s"' % strip_tags(title)
|
||||
else:
|
||||
title_template = u''
|
||||
title_template = ''
|
||||
|
||||
if click_view:
|
||||
# TODO: fix this hack
|
||||
query_dict['size'] = PREVIEW_SIZE
|
||||
query_string = urlencode(query_dict)
|
||||
result.append(u'<a %s class="%s" href="%s" %s>' % (gallery_template, fancybox_class, u'%s?%s' % (reverse(click_view, args=[staging_file.staging_folder.pk, staging_file.encoded_filename]), query_string), title_template))
|
||||
result.append('<a %s class="%s" href="%s" %s>' % (gallery_template, fancybox_class, '%s?%s' % (reverse(click_view, args=[staging_file.staging_folder.pk, staging_file.encoded_filename]), query_string), title_template))
|
||||
|
||||
if nolazyload:
|
||||
result.append(u'<img style="border: 1px solid black;" src="%s" alt="%s" />' % (preview_view, alt_text))
|
||||
result.append('<img style="border: 1px solid black;" src="%s" alt="%s" />' % (preview_view, alt_text))
|
||||
else:
|
||||
result.append(u'<img class="thin_border %s" data-src="%s" src="%smain/icons/hourglass.png" alt="%s" />' % (image_class, preview_view, settings.STATIC_URL, alt_text))
|
||||
result.append('<img class="thin_border %s" data-src="%s" src="%smain/icons/hourglass.png" alt="%s" />' % (image_class, preview_view, settings.STATIC_URL, alt_text))
|
||||
|
||||
if click_view:
|
||||
result.append(u'</a>')
|
||||
result.append(u'</div>')
|
||||
result.append('</a>')
|
||||
result.append('</div>')
|
||||
|
||||
return mark_safe(u''.join(result))
|
||||
return mark_safe(''.join(result))
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from __future__ import absolute_import
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.contrib import messages
|
||||
from django.contrib.formtools.wizard.views import SessionWizardView
|
||||
@@ -31,7 +31,7 @@ class DocumentCreateWizard(ViewPermissionCheckMixin, SessionWizardView):
|
||||
|
||||
def dispatch(self, request, *args, **kwargs):
|
||||
if InteractiveSource.objects.filter(enabled=True).count() == 0:
|
||||
messages.error(request, _(u'No interactive document sources have been defined or none have been enabled, create one before proceeding.'))
|
||||
messages.error(request, _('No interactive document sources have been defined or none have been enabled, create one before proceeding.'))
|
||||
return HttpResponseRedirect(reverse('sources:setup_source_list'))
|
||||
return super(DocumentCreateWizard, self).dispatch(request, *args, **kwargs)
|
||||
|
||||
@@ -41,8 +41,8 @@ class DocumentCreateWizard(ViewPermissionCheckMixin, SessionWizardView):
|
||||
self.condition_dict = {'1': DocumentCreateWizard._has_metadata_types}
|
||||
|
||||
self.step_titles = [
|
||||
_(u'Step 1 of 2: Select document type'),
|
||||
_(u'Step 2 of 2: Enter document metadata'),
|
||||
_('Step 1 of 2: Select document type'),
|
||||
_('Step 2 of 2: Enter document metadata'),
|
||||
]
|
||||
|
||||
def get_form_initial(self, step):
|
||||
@@ -62,7 +62,7 @@ class DocumentCreateWizard(ViewPermissionCheckMixin, SessionWizardView):
|
||||
context = super(DocumentCreateWizard, self).get_context_data(form=form, **kwargs)
|
||||
context.update({
|
||||
'step_title': self.step_titles[self.steps.step0],
|
||||
'submit_label': _(u'Next step'),
|
||||
'submit_label': _('Next step'),
|
||||
'submit_icon_famfam': 'arrow_right',
|
||||
})
|
||||
return context
|
||||
|
||||
Reference in New Issue
Block a user