Removed unused import, PEP8 cleanups
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
# From: http://www.micahcarrick.com/django-email-authentication.html
|
||||
from django.contrib.auth.models import User, check_password
|
||||
from django.contrib.auth.models import User
|
||||
from django.contrib.auth.backends import ModelBackend
|
||||
|
||||
|
||||
|
||||
@@ -165,4 +165,3 @@ class ChangelogForm(forms.Form):
|
||||
fd = open(changelog_path)
|
||||
self.fields['text'].initial = fd.read()
|
||||
fd.close()
|
||||
|
||||
|
||||
@@ -358,12 +358,6 @@ def validate_path(path):
|
||||
|
||||
return True
|
||||
|
||||
|
||||
#def encapsulate(function):
|
||||
# def wrapper():
|
||||
# return function
|
||||
# return wrapper
|
||||
|
||||
def encapsulate(function):
|
||||
# Workaround Django ticket 15791
|
||||
# Changeset 16045
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
import os
|
||||
|
||||
from django.shortcuts import redirect
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.http import HttpResponseRedirect
|
||||
@@ -10,10 +8,8 @@ from django.contrib.contenttypes.models import ContentType
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.utils.http import urlencode
|
||||
from django.contrib.auth.views import login
|
||||
from django.conf import settings
|
||||
from django.utils.safestring import mark_safe
|
||||
|
||||
from common.forms import ChoiceForm, UserForm, UserForm_view
|
||||
from common.forms import ChoiceForm, UserForm, UserForm_view, ChangelogForm
|
||||
from common.forms import EmailAuthenticationForm
|
||||
from common.conf.settings import LOGIN_METHOD
|
||||
|
||||
@@ -184,11 +180,8 @@ def login_view(request):
|
||||
|
||||
return login(request, **kwargs)
|
||||
|
||||
from common.forms import ChangelogForm
|
||||
|
||||
def changelog(request):
|
||||
|
||||
|
||||
#changelog_widget = mark_safe(u'<form class="form"><div class="group"><textarea rows="10" cols="40" class="text_area">%s</textarea></div></form>' % changelog)
|
||||
form = ChangelogForm()
|
||||
return render_to_response(
|
||||
'generic_detail.html', {
|
||||
|
||||
@@ -4,8 +4,8 @@ from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.safestring import mark_safe
|
||||
from django import forms
|
||||
from django.forms.util import flatatt
|
||||
from django.utils.html import escape, conditional_escape
|
||||
from django.utils.encoding import StrAndUnicode, force_unicode
|
||||
from django.utils.html import conditional_escape
|
||||
from django.utils.encoding import force_unicode
|
||||
|
||||
|
||||
class PlainWidget(forms.widgets.Widget):
|
||||
@@ -77,7 +77,8 @@ class TextAreaDiv(forms.widgets.Widget):
|
||||
super(TextAreaDiv, self).__init__(default_attrs)
|
||||
|
||||
def render(self, name, value, attrs=None):
|
||||
if value is None: value = ''
|
||||
if value is None:
|
||||
value = ''
|
||||
final_attrs = self.build_attrs(attrs, name=name)
|
||||
result = mark_safe(u'<div%s>%s</div>' % (flatatt(final_attrs),
|
||||
conditional_escape(force_unicode(value))))
|
||||
|
||||
@@ -5,15 +5,14 @@ import hashlib
|
||||
from common.conf.settings import TEMPORARY_DIRECTORY
|
||||
|
||||
from converter.conf.settings import UNOCONV_PATH
|
||||
from converter.exceptions import OfficeConversionError, UnknownFileFormat
|
||||
from converter.exceptions import OfficeConversionError
|
||||
from converter.literals import DEFAULT_PAGE_NUMBER, \
|
||||
DEFAULT_ZOOM_LEVEL, DEFAULT_ROTATION, DEFAULT_FILE_FORMAT
|
||||
|
||||
from converter import backend
|
||||
from converter.literals import TRANSFORMATION_CHOICES
|
||||
from converter.literals import TRANSFORMATION_RESIZE, \
|
||||
TRANSFORMATION_ROTATE, TRANSFORMATION_DENSITY, \
|
||||
TRANSFORMATION_ZOOM
|
||||
TRANSFORMATION_ROTATE, TRANSFORMATION_ZOOM
|
||||
from converter.literals import DIMENSION_SEPARATOR
|
||||
from converter.utils import cleanup
|
||||
|
||||
|
||||
@@ -7,8 +7,7 @@ from converter.exceptions import ConvertError, UnknownFileFormat, \
|
||||
IdentifyError
|
||||
from converter.backends import ConverterBase
|
||||
from converter.literals import TRANSFORMATION_RESIZE, \
|
||||
TRANSFORMATION_ROTATE, TRANSFORMATION_DENSITY, \
|
||||
TRANSFORMATION_ZOOM
|
||||
TRANSFORMATION_ROTATE, TRANSFORMATION_ZOOM
|
||||
from converter.literals import DIMENSION_SEPARATOR, DEFAULT_PAGE_NUMBER, \
|
||||
DEFAULT_FILE_FORMAT
|
||||
|
||||
|
||||
@@ -10,11 +10,9 @@ try:
|
||||
except RuntimeError:
|
||||
USE_GHOSTSCRIPT = False
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from mimetype.api import get_mimetype
|
||||
|
||||
from converter.exceptions import ConvertError, UnknownFileFormat, IdentifyError
|
||||
from converter.exceptions import UnknownFileFormat
|
||||
from converter.backends import ConverterBase
|
||||
from converter.literals import TRANSFORMATION_RESIZE, \
|
||||
TRANSFORMATION_ROTATE, TRANSFORMATION_ZOOM
|
||||
@@ -37,7 +35,7 @@ class ConverterClass(ConverterBase):
|
||||
|
||||
try:
|
||||
im = Image.open(input_filepath)
|
||||
except IOError: #cannot identify image file
|
||||
except IOError: # cannot identify image file
|
||||
raise UnknownFileFormat
|
||||
|
||||
try:
|
||||
@@ -84,7 +82,8 @@ class ConverterClass(ConverterBase):
|
||||
|
||||
try:
|
||||
im = Image.open(input_filepath)
|
||||
except Exception: # Python Imaging Library doesn't recognize it as an image
|
||||
except Exception:
|
||||
# Python Imaging Library doesn't recognize it as an image
|
||||
raise UnknownFileFormat
|
||||
finally:
|
||||
if tmpfile:
|
||||
@@ -97,7 +96,8 @@ class ConverterClass(ConverterBase):
|
||||
current_page += 1
|
||||
# do something to im
|
||||
except EOFError:
|
||||
pass # end of sequence
|
||||
# end of sequence
|
||||
pass
|
||||
|
||||
try:
|
||||
if transformations:
|
||||
|
||||
@@ -71,7 +71,8 @@ def load_backend():
|
||||
(backend_name, ", ".join(map(repr, available_backends)), e_user)
|
||||
raise ImproperlyConfigured(error_msg)
|
||||
else:
|
||||
raise # If there's some other error, this must be an error in Mayan itself.
|
||||
# If there's some other error, this must be an error in Mayan itself.
|
||||
raise
|
||||
|
||||
|
||||
def cleanup(filename):
|
||||
|
||||
@@ -7,6 +7,7 @@ from common.utils import encapsulate
|
||||
from converter import backend
|
||||
from converter.conf.settings import GRAPHICS_BACKEND
|
||||
|
||||
|
||||
def formats_list(request):
|
||||
#check_permissions(request.user, [PERMISSION_DOCUMENT_VIEW])
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ def index_instance_list(request, index_id=None):
|
||||
request,
|
||||
title=title,
|
||||
object_list=index_instance_list,
|
||||
extra_context = {
|
||||
extra_context={
|
||||
'object': index_instance
|
||||
}
|
||||
)
|
||||
@@ -105,7 +105,6 @@ def document_index_list(request, document_id):
|
||||
for index_instance in document.indexinstance_set.all():
|
||||
object_list.append(get_breadcrumbs(index_instance, single_link=True, include_count=True))
|
||||
|
||||
|
||||
return render_to_response('generic_list.html', {
|
||||
'title': _(u'indexes containing: %s') % document,
|
||||
'object_list': object_list,
|
||||
|
||||
@@ -25,7 +25,6 @@ from documents.literals import HISTORY_DOCUMENT_CREATED, \
|
||||
HISTORY_DOCUMENT_EDITED, HISTORY_DOCUMENT_DELETED
|
||||
from documents.conf.settings import ZOOM_MAX_LEVEL
|
||||
from documents.conf.settings import ZOOM_MIN_LEVEL
|
||||
from documents.conf.settings import CACHE_PATH
|
||||
from documents.conf import settings as document_settings
|
||||
from documents.widgets import document_thumbnail
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@ from django.utils.translation import ugettext
|
||||
from django.contrib.auth.models import User
|
||||
from django.contrib.contenttypes import generic
|
||||
from django.contrib.comments.models import Comment
|
||||
from django.conf import settings
|
||||
from django.core.exceptions import ValidationError
|
||||
|
||||
from taggit.managers import TaggableManager
|
||||
@@ -31,8 +30,6 @@ from documents.conf.settings import CACHE_PATH
|
||||
from documents.managers import RecentDocumentManager, \
|
||||
DocumentPageTransformationManager
|
||||
from documents.utils import document_save_to_temp_dir
|
||||
from documents.literals import PICTURE_ERROR_SMALL, PICTURE_ERROR_MEDIUM, \
|
||||
PICTURE_UNKNOWN_SMALL, PICTURE_UNKNOWN_MEDIUM
|
||||
from converter.literals import DEFAULT_ZOOM_LEVEL, DEFAULT_ROTATION, \
|
||||
DEFAULT_PAGE_NUMBER
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@ from django.template import RequestContext
|
||||
from django.contrib import messages
|
||||
from django.views.generic.list_detail import object_list
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.views.generic.create_update import delete_object, update_object
|
||||
from django.utils.http import urlencode
|
||||
|
||||
import sendfile
|
||||
@@ -19,7 +18,7 @@ from common.literals import PAGE_SIZE_DIMENSIONS, \
|
||||
PAGE_ORIENTATION_PORTRAIT, PAGE_ORIENTATION_LANDSCAPE
|
||||
from common.conf.settings import DEFAULT_PAPER_SIZE
|
||||
from converter.literals import DEFAULT_ZOOM_LEVEL, DEFAULT_ROTATION, \
|
||||
DEFAULT_FILE_FORMAT, DEFAULT_PAGE_NUMBER
|
||||
DEFAULT_PAGE_NUMBER
|
||||
from filetransfers.api import serve_file
|
||||
from grouping.utils import get_document_group_subtemplate
|
||||
from metadata.forms import MetadataFormSet, MetadataSelectionForm
|
||||
|
||||
0
apps/exporter/__init__.py
Normal file
0
apps/exporter/__init__.py
Normal file
3
apps/exporter/models.py
Normal file
3
apps/exporter/models.py
Normal file
@@ -0,0 +1,3 @@
|
||||
from django.db import models
|
||||
|
||||
# Create your models here.
|
||||
16
apps/exporter/tests.py
Normal file
16
apps/exporter/tests.py
Normal file
@@ -0,0 +1,16 @@
|
||||
"""
|
||||
This file demonstrates writing tests using the unittest module. These will pass
|
||||
when you run "manage.py test".
|
||||
|
||||
Replace this with more appropriate tests for your application.
|
||||
"""
|
||||
|
||||
from django.test import TestCase
|
||||
|
||||
|
||||
class SimpleTest(TestCase):
|
||||
def test_basic_addition(self):
|
||||
"""
|
||||
Tests that 1 + 1 always equals 2.
|
||||
"""
|
||||
self.assertEqual(1 + 1, 2)
|
||||
5
apps/exporter/urls.py
Normal file
5
apps/exporter/urls.py
Normal file
@@ -0,0 +1,5 @@
|
||||
from django.conf.urls.defaults import patterns, url
|
||||
|
||||
urlpatterns = patterns('exporter.views',
|
||||
url(r'^export_test/$', 'export_test', (), 'export_test'),
|
||||
)
|
||||
150
apps/exporter/views.py
Normal file
150
apps/exporter/views.py
Normal file
@@ -0,0 +1,150 @@
|
||||
import os
|
||||
import hashlib
|
||||
|
||||
from django.utils import simplejson
|
||||
from django.http import HttpResponse
|
||||
from django.template.defaultfilters import slugify
|
||||
|
||||
from documents.models import Document, DocumentType
|
||||
from metadata.models import MetadataType, MetadataSet
|
||||
|
||||
FORMAT_VERSION = 1.0
|
||||
HASH_FUNCTION = lambda x: hashlib.sha256(x).hexdigest()
|
||||
|
||||
|
||||
def get_hash(obj):
|
||||
if obj:
|
||||
return u'%s_%s' % (HASH_FUNCTION(unicode(obj)), slugify(unicode(obj)))
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
'''
|
||||
|
||||
|
||||
comments
|
||||
tags
|
||||
folders
|
||||
|
||||
pages
|
||||
pages transformation
|
||||
metadata
|
||||
doc_type metadata
|
||||
|
||||
sources
|
||||
sources transform
|
||||
|
||||
users
|
||||
|
||||
class DocumentTypeDefaults(models.Model):
|
||||
"""
|
||||
Default preselected metadata types and metadata set per document
|
||||
type
|
||||
"""
|
||||
document_type = models.ForeignKey(DocumentType, verbose_name=_(u'document type'))
|
||||
default_metadata_sets = models.ManyToManyField(MetadataSet, blank=True, verbose_name=_(u'default metadata sets'))
|
||||
default_metadata = models.ManyToManyField(MetadataType, blank=True, verbose_name=_(u'default metadata'))
|
||||
|
||||
|
||||
'''
|
||||
|
||||
def export_test(request):
|
||||
big_list = []
|
||||
big_list.append({'version': FORMAT_VERSION})
|
||||
|
||||
for metadata_type in MetadataType.objects.all():
|
||||
big_list.append(
|
||||
{
|
||||
'metadata_types': [
|
||||
{
|
||||
'id': get_hash(metadata_type.name),
|
||||
'name': metadata_type.name,
|
||||
'title': metadata_type.title,
|
||||
'default': metadata_type.default,
|
||||
'lookup': metadata_type.lookup,
|
||||
}
|
||||
]
|
||||
}
|
||||
)
|
||||
|
||||
for metadata_set in MetadataSet.objects.all():
|
||||
big_list.append(
|
||||
{
|
||||
'metadata_sets': [
|
||||
{
|
||||
'id': get_hash(metadata_set.title),
|
||||
'name': metadata_set.title,
|
||||
'metadata_types': [
|
||||
{
|
||||
'id': get_hash(metadata_type),
|
||||
}
|
||||
for metadata_type in metadata_set.metadatasetitem_set.all()
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
for document_type in DocumentType.objects.all():
|
||||
big_list.append(
|
||||
{
|
||||
'document_types': [
|
||||
{
|
||||
'id': get_hash(document_type.name),
|
||||
'name': document_type.name,
|
||||
'filenames': [
|
||||
{
|
||||
'filename': doc_type_filename.filename,
|
||||
'enabled': doc_type_filename.enabled,
|
||||
}
|
||||
for doc_type_filename in document_type.documenttypefilename_set.all()
|
||||
],
|
||||
'metadata_defaults': [
|
||||
{
|
||||
'default_metadata': [get_hash(metadata_type.name) for metadata_type in doc_type_defaults.default_metadata.all()],
|
||||
'default_metadata_sets': [get_hash(metadata_set.title) for metadata_set in doc_type_defaults.default_metadata_sets.all()],
|
||||
}
|
||||
for doc_type_defaults in document_type.documenttypedefaults_set.all()
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
)
|
||||
|
||||
for document in Document.objects.all()[:10]:
|
||||
big_list.append(
|
||||
{
|
||||
'documents': [
|
||||
{
|
||||
'document_type': get_hash(document.document_type),
|
||||
'filename': os.extsep.join([document.file_filename, document.file_extension]),
|
||||
#'date_added'
|
||||
'uuid': document.uuid,
|
||||
'description': unicode(document.description) if document.description else None,
|
||||
'tags': [get_hash(tag) for tag in document.tags.all()],
|
||||
'folders': [get_hash(folder_document.folder) for folder_document in document.folderdocument_set.all()],
|
||||
'comments': [
|
||||
{
|
||||
'comment': comment.comment,
|
||||
'user': unicode(comment.user),
|
||||
'submit_date': unicode(comment.submit_date),
|
||||
}
|
||||
for comment in document.comments.all()
|
||||
],
|
||||
'versions': [
|
||||
{
|
||||
1.0: {
|
||||
'mimetype': document.file_mimetype,
|
||||
'encoding': document.file_mime_encoding,
|
||||
#'date_updated'
|
||||
'checksum': document.checksum,
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
)
|
||||
|
||||
return HttpResponse(simplejson.dumps(big_list, indent=4, ensure_ascii=True), mimetype='application/json')
|
||||
@@ -2,7 +2,6 @@ from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from navigation.api import register_links, register_top_menu, \
|
||||
register_multi_item_links, register_sidebar_template
|
||||
from navigation.api import register_sidebar_template
|
||||
from documents.models import Document
|
||||
from documents.literals import PERMISSION_DOCUMENT_VIEW
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@ from django.core.exceptions import PermissionDenied
|
||||
|
||||
from documents.literals import PERMISSION_DOCUMENT_VIEW
|
||||
from documents.models import Document
|
||||
from documents.widgets import document_thumbnail, document_link
|
||||
from permissions.api import check_permissions
|
||||
from common.utils import encapsulate
|
||||
|
||||
@@ -36,6 +35,7 @@ def folder_list(request, queryset=None, extra_context=None):
|
||||
extra_context=context,
|
||||
)
|
||||
|
||||
|
||||
def folder_create(request):
|
||||
if request.method == 'POST':
|
||||
form = FolderForm(request.POST)
|
||||
|
||||
@@ -10,7 +10,6 @@ except ImportError:
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
from django.db import transaction
|
||||
from django.db.utils import DatabaseError
|
||||
#from django.utils import simplejson
|
||||
from django.core import serializers
|
||||
from django.shortcuts import get_object_or_404
|
||||
from django.db import models
|
||||
@@ -18,6 +17,7 @@ from django.db import models
|
||||
from history.models import HistoryType, History
|
||||
from history.runtime_data import history_types_dict
|
||||
|
||||
|
||||
@transaction.commit_manually
|
||||
def register_history_type(history_type_dict):
|
||||
namespace = history_type_dict['namespace']
|
||||
|
||||
@@ -61,7 +61,7 @@ setup_document_type_metadata = {'text': _(u'default metadata'), 'view': 'setup_d
|
||||
|
||||
#register_links(Document, [metadata_add, metadata_edit, metadata_remove])
|
||||
register_links(['metadata_add', 'metadata_edit', 'metadata_remove', 'metadata_view'], [metadata_add, metadata_edit, metadata_remove], menu_name='sidebar')
|
||||
register_links(Document, [metadata_view], menu_name='form_header')#, metadata_edit, metadata_remove])
|
||||
register_links(Document, [metadata_view], menu_name='form_header') #, metadata_edit, metadata_remove])
|
||||
register_multi_item_links(['document_find_duplicates', 'folder_view', 'index_instance_list', 'document_type_document_list', 'search', 'results', 'document_group_view', 'document_list', 'document_list_recent'], [metadata_multiple_add, metadata_multiple_edit, metadata_multiple_remove])
|
||||
|
||||
register_links(MetadataType, [setup_metadata_type_edit, setup_metadata_type_delete])
|
||||
|
||||
@@ -17,15 +17,15 @@ UNKNWON_TYPE_FILE_NAME = 'unknown.png'
|
||||
ERROR_FILE_NAME = 'error.png'
|
||||
|
||||
mimetype_icons = {
|
||||
'application/pdf' : 'file_extension_pdf.png',
|
||||
'application/zip' : 'file_extension_zip.png',
|
||||
'application/ogg' : 'file_extension_ogg.png',
|
||||
'application/postscript' : 'file_extension_ps.png',
|
||||
'application/x-gzip' : 'file_extension_gz.png',
|
||||
'application/x-rar-compressed' : 'file_extension_rar.png',
|
||||
'application/x-troff-msvideo' : 'file_extension_avi.png',
|
||||
'application/acad' : 'file_extension_dwg.png',
|
||||
'application/octet-stream' : 'file_extension_exe.png',
|
||||
'application/pdf': 'file_extension_pdf.png',
|
||||
'application/zip': 'file_extension_zip.png',
|
||||
'application/ogg': 'file_extension_ogg.png',
|
||||
'application/postscript': 'file_extension_ps.png',
|
||||
'application/x-gzip': 'file_extension_gz.png',
|
||||
'application/x-rar-compressed': 'file_extension_rar.png',
|
||||
'application/x-troff-msvideo': 'file_extension_avi.png',
|
||||
'application/acad': 'file_extension_dwg.png',
|
||||
'application/octet-stream': 'file_extension_exe.png',
|
||||
'application/vnd.oasis.opendocument.text': 'ODF_textdocument_32x32.png',
|
||||
'application/vnd.oasis.opendocument.spreadsheet': 'ODF_spreadsheet_32x32.png',
|
||||
'application/vnd.oasis.opendocument.presentation': 'ODF_presentation_32x32.png',
|
||||
@@ -36,9 +36,9 @@ mimetype_icons = {
|
||||
'application/vnd.openxmlformats-officedocument.wordprocessingml.document': 'file_extension_doc.png',
|
||||
'application/mspowerpoint': 'file_extension_pps.png',
|
||||
'application/vnd.ms-powerpoint': 'file_extension_pps.png',
|
||||
'application/wav' : 'file_extension_wav.png',
|
||||
'application/x-wav' : 'file_extension_wav.png',
|
||||
'application/vnd.oasis.opendocument.text' : 'ODF_textdocument_32x32.png',
|
||||
'application/wav': 'file_extension_wav.png',
|
||||
'application/x-wav': 'file_extension_wav.png',
|
||||
'application/vnd.oasis.opendocument.text': 'ODF_textdocument_32x32.png',
|
||||
|
||||
'image/jpeg' : 'file_extension_jpeg.png',
|
||||
'image/png' : 'file_extension_png.png',
|
||||
|
||||
@@ -73,6 +73,7 @@ register_tool(all_document_ocr_cleanup, namespace='ocr', title=_(u'OCR'))
|
||||
#Menus
|
||||
register_top_menu('ocr', link={'text': _('OCR'), 'famfam': 'hourglass', 'view': 'queue_document_list'}, children_path_regex=[r'^ocr/'])
|
||||
|
||||
|
||||
@transaction.commit_manually
|
||||
def create_default_queue():
|
||||
try:
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
from django.db import models
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
|
||||
from ocr.exceptions import AlreadyQueued
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@ from time import sleep
|
||||
from random import random
|
||||
|
||||
from django.db.models import Q
|
||||
from django.utils.translation import ugettext as _
|
||||
from django.core.cache import get_cache
|
||||
|
||||
from job_processor.api import process_job
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from navigation.api import register_links, \
|
||||
register_model_list_columns, register_multi_item_links, \
|
||||
register_sidebar_template
|
||||
register_model_list_columns
|
||||
from permissions.api import register_permission, set_namespace_title
|
||||
|
||||
from sources.staging import StagingFile
|
||||
|
||||
@@ -8,7 +8,7 @@ from django.core.exceptions import ValidationError
|
||||
|
||||
from converter.api import get_available_transformations_choices
|
||||
from converter.literals import DIMENSION_SEPARATOR
|
||||
from documents.models import DocumentType, Document#, RecentDocument
|
||||
from documents.models import DocumentType, Document
|
||||
from documents.literals import HISTORY_DOCUMENT_CREATED
|
||||
from document_indexing.api import update_indexes
|
||||
from history.api import create_history
|
||||
@@ -145,6 +145,7 @@ class SourceMetadata(models.Model):
|
||||
verbose_name_plural = _(u'sources metadata')
|
||||
'''
|
||||
|
||||
|
||||
class WebForm(InteractiveBaseModel):
|
||||
is_interactive = True
|
||||
source_type = SOURCE_CHOICE_WEB_FORM
|
||||
|
||||
@@ -5,7 +5,6 @@ import hashlib
|
||||
from django.core.files.base import File
|
||||
from django.core.exceptions import ObjectDoesNotExist
|
||||
from django.utils.translation import ugettext
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from mimetype.api import get_icon_file_path, get_error_icon_file_path, \
|
||||
get_mimetype
|
||||
|
||||
@@ -6,8 +6,10 @@ from django.utils.translation import ugettext
|
||||
|
||||
# From http://www.peterbe.com/plog/whitelist-blacklist-logic
|
||||
def accept_item(value, whitelist, blacklist, default_accept=True):
|
||||
""" return true if this item is either whitelisted or
|
||||
not blacklisted """
|
||||
"""
|
||||
return true if this item is either whitelisted or
|
||||
not blacklisted
|
||||
"""
|
||||
if not whitelist:
|
||||
whitelist = []
|
||||
|
||||
@@ -20,7 +22,7 @@ def accept_item(value, whitelist, blacklist, default_accept=True):
|
||||
#print 'reject: %s' % reject
|
||||
for okpattern in item_list:
|
||||
#print 'okpattern: %s' % okpattern
|
||||
if re.findall(okpattern.replace('*','\S+'), value, re.I):
|
||||
if re.findall(okpattern.replace('*', '\S+'), value, re.I):
|
||||
# match!
|
||||
#print 'MATCH'
|
||||
if reject:
|
||||
|
||||
@@ -140,7 +140,7 @@ def upload_interactive(request, source_type=None, source_id=None):
|
||||
return HttpResponseRedirect(request.get_full_path())
|
||||
else:
|
||||
form = WebFormForm(
|
||||
show_expand=(web_form.uncompress==SOURCE_UNCOMPRESS_CHOICE_ASK),
|
||||
show_expand=(web_form.uncompress == SOURCE_UNCOMPRESS_CHOICE_ASK),
|
||||
document_type=document_type,
|
||||
source=web_form
|
||||
)
|
||||
@@ -159,7 +159,7 @@ def upload_interactive(request, source_type=None, source_id=None):
|
||||
if request.method == 'POST':
|
||||
form = StagingDocumentForm(request.POST, request.FILES,
|
||||
cls=StagingFile, document_type=document_type,
|
||||
show_expand=(staging_folder.uncompress==SOURCE_UNCOMPRESS_CHOICE_ASK),
|
||||
show_expand=(staging_folder.uncompress == SOURCE_UNCOMPRESS_CHOICE_ASK),
|
||||
source=staging_folder
|
||||
)
|
||||
if form.is_valid():
|
||||
@@ -192,7 +192,7 @@ def upload_interactive(request, source_type=None, source_id=None):
|
||||
else:
|
||||
form = StagingDocumentForm(cls=StagingFile,
|
||||
document_type=document_type,
|
||||
show_expand=(staging_folder.uncompress==SOURCE_UNCOMPRESS_CHOICE_ASK),
|
||||
show_expand=(staging_folder.uncompress == SOURCE_UNCOMPRESS_CHOICE_ASK),
|
||||
source=staging_folder
|
||||
)
|
||||
try:
|
||||
@@ -299,7 +299,7 @@ def staging_file_delete(request, source_type, source_id, staging_file_id):
|
||||
|
||||
if request.method == 'POST':
|
||||
try:
|
||||
transformations, errors=SourceTransformation.transformations.get_for_object_as_list(staging_folder)
|
||||
transformations, errors = SourceTransformation.transformations.get_for_object_as_list(staging_folder)
|
||||
staging_file.delete(
|
||||
preview_size=staging_folder.get_preview_size(),
|
||||
transformations=transformations
|
||||
|
||||
@@ -59,7 +59,6 @@ class SettingsNode(Node):
|
||||
context[self.var_name] = getattr(web_theme_settings, self.format_string, '')
|
||||
return ''
|
||||
|
||||
from django.utils.safestring import mark_safe
|
||||
|
||||
@register.tag
|
||||
def get_web_theme_setting(parser, token):
|
||||
|
||||
Reference in New Issue
Block a user