Add missing imports, PEP8 cleanups
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
from __future__ import absolute_import
|
||||
|
||||
import warnings
|
||||
import os
|
||||
|
||||
from django import forms
|
||||
@@ -11,7 +12,7 @@ from django.utils.html import escape
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from .utils import return_attrib
|
||||
from .widgets import EmailInput, DetailSelectMultiple, PlainWidget
|
||||
from .widgets import DetailSelectMultiple, EmailInput, PlainWidget
|
||||
|
||||
|
||||
class DetailForm(forms.ModelForm):
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
from __future__ import absolute_import
|
||||
|
||||
from django.db import models
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import ugettext
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.contrib.auth.models import User
|
||||
|
||||
from solo.models import SingletonModel
|
||||
|
||||
@@ -3,8 +3,8 @@ from __future__ import absolute_import
|
||||
from django.conf import settings
|
||||
from django.contrib.auth.models import User
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.test.client import Client
|
||||
from django.test import TestCase
|
||||
from django.test.client import Client
|
||||
|
||||
import common
|
||||
|
||||
|
||||
@@ -71,9 +71,6 @@ class APIStagingSourceFileImageView(generics.GenericAPIView):
|
||||
|
||||
zoom = int(request.GET.get('zoom', DEFAULT_ZOOM_LEVEL))
|
||||
|
||||
if request.GET.get('as_base64', False):
|
||||
base64_version = True
|
||||
|
||||
if zoom < ZOOM_MIN_LEVEL:
|
||||
zoom = ZOOM_MIN_LEVEL
|
||||
|
||||
|
||||
@@ -7,23 +7,24 @@ import sys
|
||||
|
||||
from django.core.management.base import CommandError, LabelCommand
|
||||
|
||||
from documents.models import DocumentType
|
||||
from common.compressed_files import NotACompressedFile
|
||||
from documents.models import DocumentType
|
||||
from metadata.api import convert_dict_to_dict_list
|
||||
|
||||
from ...models import OutOfProcess
|
||||
|
||||
|
||||
class Command(LabelCommand):
|
||||
args = '<filename>'
|
||||
help = 'Upload documents from a compressed file in to the database.'
|
||||
option_list = LabelCommand.option_list + (
|
||||
make_option('--noinput', action='store_false', dest='interactive',
|
||||
default=True, help='Do not ask the user for confirmation before '
|
||||
'starting.'),
|
||||
default=True, help='Do not ask the user for confirmation before '
|
||||
'starting.'),
|
||||
make_option('--metadata', action='store', dest='metadata',
|
||||
help='A metadata dictionary list to apply to the documents.'),
|
||||
help='A metadata dictionary list to apply to the documents.'),
|
||||
make_option('--document_type', action='store', dest='document_type_name',
|
||||
help='The document type to apply to the uploaded documents.'),
|
||||
help='The document type to apply to the uploaded documents.'),
|
||||
)
|
||||
|
||||
def handle_label(self, label, **options):
|
||||
@@ -60,8 +61,7 @@ class Command(LabelCommand):
|
||||
source = OutOfProcess()
|
||||
fd = open(label)
|
||||
try:
|
||||
result = source.upload_file(fd, filename=None, use_file_name=False, document_type=document_type, expand=True, metadata_dict_list=metadata_dict_list, user=None, document=None, new_version_data=None, command_line=True)
|
||||
pass
|
||||
source.upload_file(fd, filename=None, use_file_name=False, document_type=document_type, expand=True, metadata_dict_list=metadata_dict_list, user=None, document=None, new_version_data=None, command_line=True)
|
||||
except NotACompressedFile:
|
||||
print '%s is not a compressed file.' % label
|
||||
else:
|
||||
@@ -76,5 +76,5 @@ def _confirm(interactive):
|
||||
if not interactive:
|
||||
return 'yes'
|
||||
return raw_input('You have requested to bulk upload a number of documents from a compressed file.\n'
|
||||
'Are you sure you want to do this?\n'
|
||||
'Type \'yes\' to continue, or any other value to cancel: ')
|
||||
'Are you sure you want to do this?\n'
|
||||
'Type \'yes\' to continue, or any other value to cancel: ')
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
# -*- 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
|
||||
@@ -14,7 +13,6 @@ class Migration(SchemaMigration):
|
||||
# Deleting field 'WebForm.icon'
|
||||
db.delete_column(u'sources_webform', 'icon')
|
||||
|
||||
|
||||
def backwards(self, orm):
|
||||
# Adding field 'StagingFolder.icon'
|
||||
db.add_column(u'sources_stagingfolder', 'icon',
|
||||
@@ -26,7 +24,6 @@ class Migration(SchemaMigration):
|
||||
self.gf('django.db.models.fields.CharField')(max_length=24, null=True, blank=True),
|
||||
keep_default=False)
|
||||
|
||||
|
||||
models = {
|
||||
u'contenttypes.contenttype': {
|
||||
'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
|
||||
@@ -88,4 +85,4 @@ class Migration(SchemaMigration):
|
||||
}
|
||||
}
|
||||
|
||||
complete_apps = ['sources']
|
||||
complete_apps = ['sources']
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
# -*- 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
|
||||
@@ -70,7 +69,6 @@ class Migration(SchemaMigration):
|
||||
))
|
||||
db.send_create_signal(u'sources', ['StagingFolderSource'])
|
||||
|
||||
|
||||
def backwards(self, orm):
|
||||
# Adding model 'StagingFolder'
|
||||
db.create_table(u'sources_stagingfolder', (
|
||||
@@ -140,7 +138,6 @@ class Migration(SchemaMigration):
|
||||
# Deleting model 'StagingFolderSource'
|
||||
db.delete_table(u'sources_stagingfoldersource')
|
||||
|
||||
|
||||
models = {
|
||||
u'contenttypes.contenttype': {
|
||||
'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
|
||||
@@ -198,4 +195,4 @@ class Migration(SchemaMigration):
|
||||
}
|
||||
}
|
||||
|
||||
complete_apps = ['sources']
|
||||
complete_apps = ['sources']
|
||||
|
||||
@@ -16,7 +16,6 @@ from acls.utils import apply_default_acls
|
||||
from common.compressed_files import CompressedFile, NotACompressedFile
|
||||
from converter.api import get_available_transformations_choices
|
||||
from converter.literals import DIMENSION_SEPARATOR
|
||||
from document_indexing.api import update_indexes
|
||||
from documents.events import HISTORY_DOCUMENT_CREATED
|
||||
from documents.models import Document
|
||||
from history.api import create_history
|
||||
@@ -27,7 +26,7 @@ from .literals import (SOURCE_CHOICES, SOURCE_CHOICES_PLURAL,
|
||||
SOURCE_CHOICE_STAGING, SOURCE_CHOICE_WATCH,
|
||||
SOURCE_CHOICE_WEB_FORM,
|
||||
SOURCE_INTERACTIVE_UNCOMPRESS_CHOICES,
|
||||
SOURCE_UNCOMPRESS_CHOICES, SOURCE_UNCOMPRESS_CHOICE_Y)
|
||||
SOURCE_UNCOMPRESS_CHOICES)
|
||||
from .managers import SourceTransformationManager
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -213,13 +212,6 @@ class WatchFolderSource(OutOfProcessSource):
|
||||
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.'))
|
||||
interval = models.PositiveIntegerField(verbose_name=_(u'Interval'), help_text=_(u'Inverval in seconds where the watch folder path is checked for new documents.'))
|
||||
|
||||
def execute(self, source_id):
|
||||
if self.uncompress == SOURCE_UNCOMPRESS_CHOICE_Y:
|
||||
expand = True
|
||||
else:
|
||||
expand = False
|
||||
print 'execute: %s' % self.internal_name()
|
||||
|
||||
class Meta:
|
||||
verbose_name = _(u'Watch folder')
|
||||
verbose_name_plural = _(u'Watch folders')
|
||||
|
||||
@@ -6,7 +6,7 @@ from django.core.files import File
|
||||
from mayan.celery import app
|
||||
|
||||
from documents.exceptions import NewDocumentVersionNotAllowed
|
||||
from documents.models import DocumentType
|
||||
from documents.models import Document, DocumentType
|
||||
|
||||
from .models import Source
|
||||
|
||||
@@ -49,5 +49,3 @@ def task_upload_document(source_id, file_path, filename=None, use_file_name=Fals
|
||||
|
||||
# if result['is_compressed'] is False:
|
||||
# messages.warning(request, _(u'File was not a compressed file, uploaded as it was.'))
|
||||
|
||||
|
||||
|
||||
@@ -149,7 +149,8 @@ def upload_interactive(request, source_id=None, document_pk=None):
|
||||
context['source'] = source
|
||||
|
||||
if request.method == 'POST':
|
||||
form = form_class(request.POST, request.FILES,
|
||||
form = form_class(
|
||||
request.POST, request.FILES,
|
||||
document_type=document_type,
|
||||
show_expand=(source.uncompress == SOURCE_UNCOMPRESS_CHOICE_ASK) and not document,
|
||||
source=source,
|
||||
@@ -319,7 +320,7 @@ def upload_interactive(request, source_id=None, document_pk=None):
|
||||
)
|
||||
|
||||
return render_to_response('main/generic_form.html', context,
|
||||
context_instance=RequestContext(request))
|
||||
context_instance=RequestContext(request))
|
||||
|
||||
|
||||
def get_form_filename(form):
|
||||
@@ -384,7 +385,7 @@ def setup_source_list(request, source_type):
|
||||
}
|
||||
|
||||
return render_to_response('main/generic_list.html', context,
|
||||
context_instance=RequestContext(request))
|
||||
context_instance=RequestContext(request))
|
||||
|
||||
|
||||
def setup_source_edit(request, source_id):
|
||||
@@ -420,8 +421,7 @@ def setup_source_edit(request, source_id):
|
||||
'next': next,
|
||||
'object_name': _(u'Source'),
|
||||
'source_type': source.source_type,
|
||||
},
|
||||
context_instance=RequestContext(request))
|
||||
}, context_instance=RequestContext(request))
|
||||
|
||||
|
||||
def setup_source_delete(request, source_id):
|
||||
@@ -464,7 +464,7 @@ def setup_source_delete(request, source_id):
|
||||
}
|
||||
|
||||
return render_to_response('main/generic_confirm.html', context,
|
||||
context_instance=RequestContext(request))
|
||||
context_instance=RequestContext(request))
|
||||
|
||||
|
||||
def setup_source_create(request, source_type):
|
||||
@@ -497,8 +497,7 @@ def setup_source_create(request, source_type):
|
||||
'form': form,
|
||||
'source_type': source_type,
|
||||
'navigation_object_name': 'source',
|
||||
},
|
||||
context_instance=RequestContext(request))
|
||||
}, context_instance=RequestContext(request))
|
||||
|
||||
|
||||
def setup_source_transformation_list(request, source_id):
|
||||
@@ -523,7 +522,7 @@ def setup_source_transformation_list(request, source_id):
|
||||
}
|
||||
|
||||
return render_to_response('main/generic_list.html', context,
|
||||
context_instance=RequestContext(request))
|
||||
context_instance=RequestContext(request))
|
||||
|
||||
|
||||
def setup_source_transformation_edit(request, transformation_id):
|
||||
@@ -555,8 +554,7 @@ def setup_source_transformation_edit(request, transformation_id):
|
||||
{'object': 'transformation', 'name': _(u'Transformation')}
|
||||
],
|
||||
'next': next,
|
||||
},
|
||||
context_instance=RequestContext(request))
|
||||
}, context_instance=RequestContext(request))
|
||||
|
||||
|
||||
def setup_source_transformation_delete(request, transformation_id):
|
||||
@@ -589,8 +587,7 @@ def setup_source_transformation_delete(request, transformation_id):
|
||||
},
|
||||
'previous': previous,
|
||||
'form_icon': u'shape_square_delete.png',
|
||||
},
|
||||
context_instance=RequestContext(request))
|
||||
}, context_instance=RequestContext(request))
|
||||
|
||||
|
||||
def setup_source_transformation_create(request, source_id):
|
||||
|
||||
@@ -6,6 +6,7 @@ from django.shortcuts import get_object_or_404
|
||||
from rest_framework import generics
|
||||
from taggit.models import Tag
|
||||
|
||||
from acls.models import AccessEntry
|
||||
from documents.models import Document
|
||||
from documents.permissions import PERMISSION_DOCUMENT_VIEW
|
||||
from permissions.models import Permission
|
||||
|
||||
@@ -4,8 +4,8 @@ from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from acls.permissions import ACLS_VIEW_ACL
|
||||
|
||||
from .permissions import (PERMISSION_TAG_CREATE, PERMISSION_TAG_DELETE,
|
||||
PERMISSION_TAG_ATTACH, PERMISSION_TAG_EDIT,
|
||||
from .permissions import (PERMISSION_TAG_ATTACH, PERMISSION_TAG_CREATE,
|
||||
PERMISSION_TAG_DELETE, PERMISSION_TAG_EDIT,
|
||||
PERMISSION_TAG_REMOVE)
|
||||
|
||||
tag_list = {'text': _(u'Tag list'), 'view': 'tags:tag_list', 'famfam': 'tag_blue'}
|
||||
|
||||
@@ -7,10 +7,11 @@ from navigation.api import register_links, register_multi_item_links
|
||||
from project_setup.api import register_setup
|
||||
from rest_api.classes import APIEndPoint
|
||||
|
||||
from .links import (user_list, user_setup, user_edit, user_add, user_delete,
|
||||
user_multiple_delete, user_set_password, user_multiple_set_password,
|
||||
user_groups, group_list, group_setup, group_edit, group_add, group_delete,
|
||||
group_multiple_delete, group_members)
|
||||
from .links import (group_add, group_delete, group_edit, group_list,
|
||||
group_members, group_multiple_delete, group_setup,
|
||||
user_add, user_delete, user_edit, user_groups, user_list,
|
||||
user_multiple_delete, user_multiple_set_password,
|
||||
user_set_password, user_setup)
|
||||
from .urls import api_urls
|
||||
|
||||
register_links(User, [user_edit, user_set_password, user_groups, user_delete])
|
||||
|
||||
@@ -7,9 +7,8 @@ from rest_framework import generics
|
||||
from rest_api.filters import MayanObjectPermissionsFilter
|
||||
from rest_api.permissions import MayanPermission
|
||||
|
||||
from .permissions import (PERMISSION_USER_CREATE,
|
||||
PERMISSION_USER_DELETE, PERMISSION_USER_EDIT,
|
||||
PERMISSION_USER_VIEW)
|
||||
from .permissions import (PERMISSION_USER_CREATE, PERMISSION_USER_DELETE,
|
||||
PERMISSION_USER_EDIT, PERMISSION_USER_VIEW)
|
||||
from .serializers import UserSerializer
|
||||
|
||||
|
||||
|
||||
@@ -2,9 +2,10 @@ from __future__ import absolute_import
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from .permissions import (PERMISSION_USER_CREATE, PERMISSION_USER_EDIT,
|
||||
PERMISSION_USER_VIEW, PERMISSION_USER_DELETE, PERMISSION_GROUP_CREATE,
|
||||
PERMISSION_GROUP_EDIT, PERMISSION_GROUP_VIEW, PERMISSION_GROUP_DELETE)
|
||||
from .permissions import (PERMISSION_GROUP_CREATE, PERMISSION_GROUP_DELETE,
|
||||
PERMISSION_GROUP_EDIT, PERMISSION_GROUP_VIEW,
|
||||
PERMISSION_USER_CREATE, PERMISSION_USER_DELETE,
|
||||
PERMISSION_USER_EDIT, PERMISSION_USER_VIEW)
|
||||
|
||||
user_list = {'text': _(u'User list'), 'view': 'user_management:user_list', 'famfam': 'user', 'permissions': [PERMISSION_USER_VIEW]}
|
||||
user_setup = {'text': _(u'Users'), 'view': 'user_management:user_list', 'famfam': 'user', 'icon': 'user.png', 'permissions': [PERMISSION_USER_VIEW], 'children_view_regex': [r'^user_']}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
from __future__ import absolute_import
|
||||
|
||||
import csv
|
||||
from optparse import make_option
|
||||
import os
|
||||
import sys
|
||||
from optparse import make_option
|
||||
|
||||
from django.core.management.base import CommandError, LabelCommand
|
||||
from django.contrib.auth.models import User
|
||||
from django.core.management.base import CommandError, LabelCommand
|
||||
from django.db.utils import IntegrityError
|
||||
|
||||
|
||||
@@ -29,12 +29,12 @@ class Command(LabelCommand):
|
||||
help = 'Import users from a CSV file with the field order: username, firstname, lastname, email.'
|
||||
option_list = LabelCommand.option_list + (
|
||||
make_option('--noinput', action='store_false', dest='interactive',
|
||||
default=True, help='Do not ask the user for confirmation before '
|
||||
'starting.'),
|
||||
default=True, help='Do not ask the user for confirmation before '
|
||||
'starting.'),
|
||||
make_option('--password', action='store', dest='password',
|
||||
help='The default password to assign to each new user.'),
|
||||
help='The default password to assign to each new user.'),
|
||||
make_option('--skip-repeated', action='store_true', dest='skip_repeated',
|
||||
default=False, help='Don\'t exit if the user already exists.'),
|
||||
default=False, help='Don\'t exit if the user already exists.'),
|
||||
)
|
||||
|
||||
def handle_label(self, label, **options):
|
||||
|
||||
Reference in New Issue
Block a user