Merge branch 'feature/pep8_cleanup' into development

This commit is contained in:
Roberto Rosario
2012-02-22 14:37:25 -04:00
56 changed files with 74 additions and 609 deletions

View File

@@ -52,7 +52,7 @@ class BaseHolderSelectionForm(forms.Form):
class HolderSelectionForm(BaseHolderSelectionForm):
special_holders = [AnonymousUserSingleton.objects.get()]
class ClassHolderSelectionForm(BaseHolderSelectionForm):
special_holders = [AnonymousUserSingleton.objects.get(), CreatorSingleton.objects.get()]

View File

@@ -3,7 +3,6 @@ from __future__ import absolute_import
import logging
from django.db import models
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import ugettext
from django.contrib.contenttypes.models import ContentType
from django.contrib.auth.models import User
@@ -14,8 +13,7 @@ from django.db.models import Q
from common.models import AnonymousUserSingleton
from permissions.models import Permission, RoleMember
from .classes import (EncapsulatedObject, AccessHolder, ClassAccessHolder,
get_source_object)
from .classes import AccessHolder, ClassAccessHolder, get_source_object
logger = logging.getLogger(__name__)
@@ -62,7 +60,6 @@ class AccessEntryManager(models.Manager):
access_entry.delete()
return True
def has_access(self, permission, actor, obj, db_only=False):
"""
Returns whether an actor has a specific permission for an object
@@ -152,7 +149,7 @@ class AccessEntryManager(models.Manager):
groups = actor.groups.all()
else:
groups = []
for group in groups:
group_type = ContentType.objects.get_for_model(group)
if related:
@@ -162,8 +159,8 @@ class AccessEntryManager(models.Manager):
if total_queries is None:
total_queries = query
else:
total_queries = total_queries | query
total_queries = total_queries | query
if related:
actor_query = Q(holder_type=actor_type, holder_id=actor.pk, permission=permission.get_stored_permission)
master_list = [obj.content_object for obj in self.model.objects.select_related().filter(actor_query | total_queries)]
@@ -189,9 +186,9 @@ class AccessEntryManager(models.Manager):
holder_list = []
for access_entry in self.model.objects.filter(content_type=content_type, object_id=obj.pk):
if access_entry.holder_object:
# Don't add references to non existant content type objects
# Don't add references to non existant content type objects
entry = AccessHolder.encapsulate(access_entry.holder_object)
if entry not in holder_list:
holder_list.append(entry)

View File

@@ -7,8 +7,6 @@ from django.utils.translation import ugettext_lazy as _
from django.utils.translation import ugettext
from django.contrib.contenttypes.models import ContentType
from django.contrib.contenttypes import generic
from django.core.exceptions import PermissionDenied
from django.core.exceptions import ObjectDoesNotExist
from permissions.models import StoredPermission
from common.models import Singleton, SingletonManager
@@ -102,6 +100,7 @@ class CreatorSingletonManager(SingletonManager):
else:
return holder
class CreatorSingleton(Singleton):
objects = CreatorSingletonManager()

View File

@@ -1,16 +0,0 @@
"""
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)

View File

@@ -7,8 +7,7 @@ from django.contrib.contenttypes.models import ContentType
from common.models import AnonymousUserSingleton
from .models import AccessEntry, DefaultAccessEntry, CreatorSingleton
from .classes import (EncapsulatedObject, AccessHolder, ClassAccessHolder,
get_source_object)
from .classes import get_source_object
logger = logging.getLogger(__name__)
@@ -24,7 +23,7 @@ def apply_default_acls(obj, actor=None):
for default_acl in DefaultAccessEntry.objects.filter(content_type=content_type):
holder = CreatorSingleton.objects.passthru_check(default_acl.holder_object, actor)
if holder:
# When the creator is admin
access_entry = AccessEntry(

View File

@@ -120,7 +120,7 @@ def acl_detail_for(request, actor, obj):
'multi_select_item_properties': {
'permission_pk': lambda x: x.pk,
'holder_gid': lambda x: actor.gid,
'object_gid': lambda x: obj.gid,
'object_gid': lambda x: obj.gid,
},
'access_object': obj,
'navigation_object_list': [
@@ -138,10 +138,9 @@ def acl_detail_for(request, actor, obj):
def acl_grant(request):
items_property_list = loads(request.GET.get('items_property_list', []))
post_action_redirect = None
next = request.POST.get('next', request.GET.get('next', request.META.get('HTTP_REFERER', None)))
previous = request.POST.get('previous', request.GET.get('previous', request.META.get('HTTP_REFERER', None)))
next = request.POST.get('next', request.GET.get('next', request.META.get('HTTP_REFERER', '/')))
previous = request.POST.get('previous', request.GET.get('previous', request.META.get('HTTP_REFERER', '/')))
items = {}
title_suffix = []
@@ -232,10 +231,9 @@ def acl_grant(request):
def acl_revoke(request):
items_property_list = loads(request.GET.get('items_property_list', []))
post_action_redirect = None
next = request.POST.get('next', request.GET.get('next', request.META.get('HTTP_REFERER', None)))
previous = request.POST.get('previous', request.GET.get('previous', request.META.get('HTTP_REFERER', None)))
next = request.POST.get('next', request.GET.get('next', request.META.get('HTTP_REFERER', '/')))
previous = request.POST.get('previous', request.GET.get('previous', request.META.get('HTTP_REFERER', '/')))
items = {}
title_suffix = []
@@ -403,7 +401,7 @@ def acl_class_acl_list(request, access_object_class_gid):
access_object_class = AccessObjectClass.get(gid=access_object_class_gid)
logger.debug('access_object_class: %s' % access_object_class)
context = {
'object_list': DefaultAccessEntry.objects.get_holders_for(access_object_class.source_object),
'title': _(u'default access control lists for class: %s') % access_object_class,
@@ -496,10 +494,9 @@ def acl_class_new_holder_for(request, access_object_class_gid):
def acl_class_multiple_grant(request):
Permission.objects.check_permissions(request.user, [ACLS_CLASS_EDIT_ACL])
items_property_list = loads(request.GET.get('items_property_list', []))
post_action_redirect = None
next = request.POST.get('next', request.GET.get('next', request.META.get('HTTP_REFERER', None)))
previous = request.POST.get('previous', request.GET.get('previous', request.META.get('HTTP_REFERER', None)))
next = request.POST.get('next', request.GET.get('next', request.META.get('HTTP_REFERER', '/')))
previous = request.POST.get('previous', request.GET.get('previous', request.META.get('HTTP_REFERER', '/')))
items = {}
title_suffix = []
@@ -576,10 +573,9 @@ def acl_class_multiple_grant(request):
def acl_class_multiple_revoke(request):
Permission.objects.check_permissions(request.user, [ACLS_CLASS_EDIT_ACL])
items_property_list = loads(request.GET.get('items_property_list', []))
post_action_redirect = None
next = request.POST.get('next', request.GET.get('next', request.META.get('HTTP_REFERER', None)))
previous = request.POST.get('previous', request.GET.get('previous', request.META.get('HTTP_REFERER', None)))
next = request.POST.get('next', request.GET.get('next', request.META.get('HTTP_REFERER', '/')))
previous = request.POST.get('previous', request.GET.get('previous', request.META.get('HTTP_REFERER', '/')))
items = {}
title_suffix = []

View File

@@ -1,22 +0,0 @@
"""
This file demonstrates two different styles of tests (one doctest and one
unittest). These will both pass when you run "manage.py test".
Replace these 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.failUnlessEqual(1 + 1, 2)
__test__ = {"doctest": """
Another way to test that 1 + 1 is equal to 2.
>>> 1 + 1 == 2
True
"""}

View File

@@ -178,7 +178,7 @@ class GPG(object):
self.keyservers = keyservers
self.gpg = gnupg.GPG(**kwargs)
def verify_file(self, file_input, detached_signature=None, fetch_key=False):
"""
Verify the signature of a file.

View File

@@ -1,6 +1,5 @@
from django import forms
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import ugettext
class KeySearchForm(forms.Form):

View File

@@ -8,6 +8,6 @@ from .conf.settings import KEYSERVERS, GPG_HOME
try:
gpg = GPG(home=GPG_HOME, keyservers=KEYSERVERS)
except Exception, e:
gpg = GPG(keyservers=KEYSERVERS)
gpg = GPG(keyservers=KEYSERVERS)
sys.stderr.write(u'ERROR: GPG initialization error: %s\n' % e)
sys.stderr.write(u'INFO: Initializating GPG with system default home\n')

View File

@@ -9,12 +9,11 @@ from django.template import RequestContext
from django.contrib import messages
from permissions.models import Permission
from common.utils import (urlquote, encapsulate)
from common.utils import encapsulate
from .api import Key, SIGNATURE_STATES
from .api import Key
from .runtime import gpg
from .exceptions import (GPGVerificationError, KeyFetchingError,
KeyImportError)
from .exceptions import KeyFetchingError, KeyImportError
from .forms import KeySearchForm
from .permissions import (PERMISSION_KEY_VIEW, PERMISSION_KEY_DELETE,
PERMISSION_KEYSERVER_QUERY, PERMISSION_KEY_RECEIVE)
@@ -40,7 +39,7 @@ def key_receive(request, key_id):
except (KeyImportError, KeyError, TypeError), e:
messages.error(
request,
_(u'Unable to import key id: %(key_id)s; %(error)s') %
_(u'Unable to import key id: %(key_id)s; %(error)s') %
{
'key_id': key_id,
'error': e,

View File

@@ -1,16 +0,0 @@
"""
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)

View File

@@ -1,23 +0,0 @@
"""
This file demonstrates two different styles of tests (one doctest and one
unittest). These will both pass when you run "manage.py test".
Replace these 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.failUnlessEqual(1 + 1, 2)
__test__ = {"doctest": """
Another way to test that 1 + 1 is equal to 2.
>>> 1 + 1 == 2
True
"""}

View File

@@ -34,7 +34,7 @@ def comment_delete(request, comment_id=None, comment_id_list=None):
if not comments:
messages.error(request, _(u'Must provide at least one comment.'))
return HttpResponseRedirect(request.META.get('HTTP_REFERER', '/'))
return HttpResponseRedirect(request.META.get('HTTP_REFERER', '/'))
previous = request.POST.get('previous', request.GET.get('previous', request.META.get('HTTP_REFERER', '/')))
next = request.POST.get('next', request.GET.get('next', post_action_redirect if post_action_redirect else request.META.get('HTTP_REFERER', '/')))

View File

@@ -2,13 +2,11 @@ from __future__ import absolute_import
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import ugettext
from django.core.urlresolvers import reverse
from django.template.defaultfilters import slugify
from metadata.classes import MetadataClass
from .models import (Index, IndexTemplateNode, IndexInstanceNode,
DocumentRenameCount)
from .models import Index, IndexInstanceNode, DocumentRenameCount
from .conf.settings import (AVAILABLE_INDEXING_FUNCTIONS,
MAX_SUFFIX_COUNT, SLUGIFY_PATHS)
from .filesystem import (fs_create_index_directory,
@@ -94,7 +92,7 @@ def cascade_eval(eval_dict, document, template_node, parent_index_instance=None)
fs_create_index_directory(index_instance)
except Exception, exc:
warnings.append(_(u'Error updating document index, expression: %(expression)s; %(exception)s') % {
'expression': template_node.expression, 'exception': exc})
'expression': template_node.expression, 'exception': exc})
if template_node.link_documents:
suffix = find_lowest_available_suffix(index_instance, document)
@@ -109,7 +107,7 @@ def cascade_eval(eval_dict, document, template_node, parent_index_instance=None)
fs_create_document_link(index_instance, document, suffix)
except Exception, exc:
warnings.append(_(u'Error updating document index, expression: %(expression)s; %(exception)s') % {
'expression': template_node.expression, 'exception': exc})
'expression': template_node.expression, 'exception': exc})
index_instance.documents.add(document)

View File

@@ -1,22 +0,0 @@
"""
This file demonstrates two different styles of tests (one doctest and one
unittest). These will both pass when you run "manage.py test".
Replace these 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.failUnlessEqual(1 + 1, 2)
__test__ = {"doctest": """
Another way to test that 1 + 1 is equal to 2.
>>> 1 + 1 == 2
True
"""}

View File

@@ -10,7 +10,7 @@ from .api import update_indexes
def do_rebuild_all_indexes():
for index in Index.objects.all():
fs_delete_directory_recusive(index)
IndexInstanceNode.objects.all().delete()
DocumentRenameCount.objects.all().delete()
for document in Document.objects.all():

View File

@@ -1,8 +1,7 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import
#from django.utils.safestring import mark_safe
from django.utils.html import conditional_escape, mark_safe
from django.utils.html import mark_safe
from .models import IndexInstanceNode
@@ -73,7 +72,7 @@ def get_breadcrumbs(index_instance, simple=False, single_link=False, include_cou
else:
output.insert(0, u' / '.join(result))
return mark_safe(u' '.join(output))
def node_level(x):
"""

View File

@@ -69,7 +69,7 @@ class DocumentVersionSignatureManager(models.Manager):
document_descriptor.close()
if detached_signature:
detached_signature.close()
def clear_detached_signature(self, document):
document_signature = self.get_document_signature(document)
if not document_signature.signature_file:
@@ -77,4 +77,4 @@ class DocumentVersionSignatureManager(models.Manager):
document_signature.delete_detached_signature_file()
document_signature.signature_file = None
document_signature.save()
document_signature.save()

View File

@@ -1,16 +0,0 @@
"""
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)

View File

@@ -1,23 +0,0 @@
"""
This file demonstrates two different styles of tests (one doctest and one
unittest). These will both pass when you run "manage.py test".
Replace these 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.failUnlessEqual(1 + 1, 2)
__test__ = {"doctest": """
Another way to test that 1 + 1 is equal to 2.
>>> 1 + 1 == 2
True
"""}

View File

@@ -2,8 +2,7 @@ from __future__ import absolute_import
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_links
from common import about_view, license_view
form_view = {'text': _('Feedback'), 'view': 'form_view', 'famfam': 'telephone'}

View File

@@ -9,4 +9,4 @@ TIMEOUT = 10
def submit_form(form):
r = requests.post(FORM_SUBMIT_URL, data={'formkey': FORM_KEY, FORM_RECEIVER_FIELD: dumps(form.cleaned_data)}, timeout=TIMEOUT)
requests.post(FORM_SUBMIT_URL, data={'formkey': FORM_KEY, FORM_RECEIVER_FIELD: dumps(form.cleaned_data)}, timeout=TIMEOUT)

View File

@@ -50,7 +50,7 @@ class FeedbackForm(forms.Form):
label=_(u'Are currently providing or planning to provide paid support for Mayan EDMS?'),
required=False
)
hosted = forms.BooleanField(
label=_(u'Would you be interested in a cloud hosted solution for Mayan EDMS?'),
required=False
@@ -70,7 +70,7 @@ class FeedbackForm(forms.Form):
label=_(u'Your email:'),
required=False
)
company = forms.CharField(
label=_(u'Company name:'),
required=False

View File

@@ -1,16 +0,0 @@
"""
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)

View File

@@ -2,10 +2,9 @@ from __future__ import absolute_import
from django.utils.translation import ugettext_lazy as _
from django.http import HttpResponseRedirect
from django.shortcuts import render_to_response, get_object_or_404
from django.shortcuts import render_to_response
from django.template import RequestContext
from django.contrib import messages
from django.core.urlresolvers import reverse
from .forms import FeedbackForm
from .api import submit_form
@@ -28,4 +27,4 @@ def form_view(request):
'title': _(u'feedback form'),
'form': form,
},
context_instance=RequestContext(request))
context_instance=RequestContext(request))

View File

@@ -1,23 +0,0 @@
"""
This file demonstrates two different styles of tests (one doctest and one
unittest). These will both pass when you run "manage.py test".
Replace these 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.failUnlessEqual(1 + 1, 2)
__test__ = {"doctest": """
Another way to test that 1 + 1 is equal to 2.
>>> 1 + 1 == 2
True
"""}

View File

@@ -1,23 +0,0 @@
"""
This file demonstrates two different styles of tests (one doctest and one
unittest). These will both pass when you run "manage.py test".
Replace these 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.failUnlessEqual(1 + 1, 2)
__test__ = {"doctest": """
Another way to test that 1 + 1 is equal to 2.
>>> 1 + 1 == 2
True
"""}

View File

@@ -1,12 +1,10 @@
from __future__ import absolute_import
from django import forms
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import ugettext
from django.core.urlresolvers import reverse
from django.utils.safestring import mark_safe
from django.template.defaultfilters import capfirst
from django.conf import settings
from documents.widgets import document_html_widget
from tags.widgets import get_tags_inline_widget

View File

@@ -127,7 +127,6 @@ def smart_link_list(request):
except PermissionDenied:
qs = AccessEntry.objects.filter_objects_by_access(PERMISSION_SMART_LINK_VIEW, request.user, qs)
return render_to_response('generic_list.html', {
'title': _(u'smart links'),
'object_list': qs,

View File

@@ -1,22 +0,0 @@
"""
This file demonstrates two different styles of tests (one doctest and one
unittest). These will both pass when you run "manage.py test".
Replace these 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.failUnlessEqual(1 + 1, 2)
__test__ = {"doctest": """
Another way to test that 1 + 1 is equal to 2.
>>> 1 + 1 == 2
True
"""}

View File

@@ -1,22 +0,0 @@
"""
This file demonstrates two different styles of tests (one doctest and one
unittest). These will both pass when you run "manage.py test".
Replace these 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.failUnlessEqual(1 + 1, 2)
__test__ = {"doctest": """
Another way to test that 1 + 1 is equal to 2.
>>> 1 + 1 == 2
True
"""}

View File

@@ -83,10 +83,11 @@ def get_error_icon_file_path():
else:
return os.path.join(settings.STATIC_ROOT, MIMETYPE_ICONS_DIRECTORY_NAME, ERROR_FILE_NAME)
def get_error_icon_url():
return os.path.join(MIMETYPE_ICONS_DIRECTORY_NAME, ERROR_FILE_NAME)
def get_mimetype(file_description, filepath, mimetype_only=False):
"""
Determine a file's mimetype by calling the system's libmagic

View File

@@ -1,23 +0,0 @@
"""
This file demonstrates two different styles of tests (one doctest and one
unittest). These will both pass when you run "manage.py test".
Replace these 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.failUnlessEqual(1 + 1, 2)
__test__ = {"doctest": """
Another way to test that 1 + 1 is equal to 2.
>>> 1 + 1 == 2
True
"""}

View File

@@ -1,23 +0,0 @@
"""
This file demonstrates two different styles of tests (one doctest and one
unittest). These will both pass when you run "manage.py test".
Replace these 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.failUnlessEqual(1 + 1, 2)
__test__ = {"doctest": """
Another way to test that 1 + 1 is equal to 2.
>>> 1 + 1 == 2
True
"""}

View File

@@ -95,6 +95,7 @@ def document_post_save(sender, instance, **kwargs):
# logger.debug('got call_queue signal: %s' % kwargs)
# task_process_document_queues()
@receiver(post_syncdb, dispatch_uid='create_default_queue', sender=ocr_models)
def create_default_queue_signal_handler(sender, **kwargs):
create_default_queue()

View File

@@ -1,22 +0,0 @@
"""
This file demonstrates two different styles of tests (one doctest and one
unittest). These will both pass when you run "manage.py test".
Replace these 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.failUnlessEqual(1 + 1, 2)
__test__ = {"doctest": """
Another way to test that 1 + 1 is equal to 2.
>>> 1 + 1 == 2
True
"""}

View File

@@ -1,7 +1,5 @@
from __future__ import absolute_import
import socket
from django.http import HttpResponseRedirect
from django.shortcuts import render_to_response, get_object_or_404
from django.template import RequestContext

View File

@@ -1,22 +0,0 @@
"""
This file demonstrates two different styles of tests (one doctest and one
unittest). These will both pass when you run "manage.py test".
Replace these 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.failUnlessEqual(1 + 1, 2)
__test__ = {"doctest": """
Another way to test that 1 + 1 is equal to 2.
>>> 1 + 1 == 2
True
"""}

View File

@@ -1,23 +0,0 @@
"""
This file demonstrates two different styles of tests (one doctest and one
unittest). These will both pass when you run "manage.py test".
Replace these 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.failUnlessEqual(1 + 1, 2)
__test__ = {"doctest": """
Another way to test that 1 + 1 is equal to 2.
>>> 1 + 1 == 2
True
"""}

View File

@@ -1,23 +0,0 @@
"""
This file demonstrates two different styles of tests (one doctest and one
unittest). These will both pass when you run "manage.py test".
Replace these 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.failUnlessEqual(1 + 1, 2)
__test__ = {"doctest": """
Another way to test that 1 + 1 is equal to 2.
>>> 1 + 1 == 2
True
"""}

View File

@@ -1 +0,0 @@

View File

@@ -1,23 +0,0 @@
"""
This file demonstrates two different styles of tests (one doctest and one
unittest). These will both pass when you run "manage.py test".
Replace these 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.failUnlessEqual(1 + 1, 2)
__test__ = {"doctest": """
Another way to test that 1 + 1 is equal to 2.
>>> 1 + 1 == 2
True
"""}

View File

@@ -10,4 +10,4 @@ class Command(collectstatic.Command):
def handle_noargs(self, *args, **kwargs):
pre_collectstatic.send(sender=self)
super(Command, self).handle_noargs(*args, **kwargs)
super(Command, self).handle_noargs(*args, **kwargs)

View File

@@ -1,22 +0,0 @@
"""
This file demonstrates two different styles of tests (one doctest and one
unittest). These will both pass when you run "manage.py test".
Replace these 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.failUnlessEqual(1 + 1, 2)
__test__ = {"doctest": """
Another way to test that 1 + 1 is equal to 2.
>>> 1 + 1 == 2
True
"""}

View File

@@ -1,10 +1,11 @@
from __future__ import absolute_import
import os, sys
import os
import sys
from optparse import make_option
from django.core.management.base import BaseCommand, CommandError, LabelCommand
from django.utils.simplejson import loads, dumps
from django.utils.simplejson import loads
from metadata.api import convert_dict_to_dict_list
from documents.models import DocumentType
@@ -25,7 +26,7 @@ class Command(LabelCommand):
make_option('--document_type', action='store', dest='document_type_name',
help='The document type to apply to the uploaded documents.'),
)
def handle_label(self, label, **options):
if not os.access(label, os.R_OK):
raise CommandError("File '%s' is not readable." % label)
@@ -53,10 +54,10 @@ class Command(LabelCommand):
print 'Using the metadata values:'
for key, value in metadata_dict.items():
print '%s: %s' % (key, value)
if document_type:
print 'Uploaded document will be of type: %s' % options['document_type_name']
source = OutOfProcess()
fd = open(label)
try:
@@ -71,7 +72,7 @@ class Command(LabelCommand):
else:
print 'Cancelled.'
def _confirm(interactive):
if not interactive:
return 'yes'

View File

@@ -9,7 +9,6 @@ from django.contrib.contenttypes.models import ContentType
from django.contrib.contenttypes import generic
from django.core.exceptions import ValidationError
from django.db import transaction
from django.db.utils import DatabaseError
from converter.api import get_available_transformations_choices
from converter.literals import DIMENSION_SEPARATOR
@@ -91,7 +90,7 @@ class BaseModel(models.Model):
@transaction.commit_on_success
def upload_single_file(self, file_object, filename=None, use_file_name=False, document_type=None, metadata_dict_list=None, user=None, document=None, new_version_data=None):
new_document = not document
if not document:
document = Document()
if document_type:
@@ -99,7 +98,7 @@ class BaseModel(models.Model):
document.save()
apply_default_acls(document, user)
if user:
document.add_as_recent_document_for_user(user)
create_history(HISTORY_DOCUMENT_CREATED, document, {'user': user})
@@ -113,7 +112,7 @@ class BaseModel(models.Model):
if not new_version_data:
new_version_data = {}
try:
new_version = document.new_version(file=file_object, **new_version_data)
except Exception:
@@ -121,7 +120,7 @@ class BaseModel(models.Model):
# document.delete()
transaction.rollback()
raise
if filename:
document.rename(filename)
@@ -129,11 +128,11 @@ class BaseModel(models.Model):
new_version.apply_default_transformations(transformations)
#TODO: new HISTORY for version updates
if metadata_dict_list and new_document:
# Only do for new documents
save_metadata_list(metadata_dict_list, document, create=True)
warnings = update_indexes(document)
warnings = update_indexes(document)
class Meta:
ordering = ('title',)
@@ -288,6 +287,7 @@ class SourceTransformation(models.Model):
class OutOfProcess(BaseModel):
is_interactive = False
class Meta(BaseModel.Meta):
verbose_name = _(u'out of process')
verbose_name_plural = _(u'out of process')

View File

@@ -1,22 +0,0 @@
"""
This file demonstrates two different styles of tests (one doctest and one
unittest). These will both pass when you run "manage.py test".
Replace these 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.failUnlessEqual(1 + 1, 2)
__test__ = {"doctest": """
Another way to test that 1 + 1 is equal to 2.
>>> 1 + 1 == 2
True
"""}

View File

@@ -165,13 +165,13 @@ def upload_interactive(request, source_type=None, source_id=None, document_pk=No
else:
if result['is_compressed'] == None:
messages.success(request, _(u'File uploaded successfully.'))
if result['is_compressed'] == True:
messages.success(request, _(u'File uncompressed successfully and uploaded as individual files.'))
if result['is_compressed'] == False:
messages.warning(request, _(u'File was not a compressed file, uploaded as it was.'))
return HttpResponseRedirect(request.get_full_path())
except Exception, e:
if settings.DEBUG:
@@ -240,7 +240,7 @@ def upload_interactive(request, source_type=None, source_id=None, document_pk=No
if result['is_compressed'] == True:
messages.success(request, _(u'Staging file: %s, uncompressed successfully and uploaded as individual files.') % staging_file.filename)
if result['is_compressed'] == False:
messages.warning(request, _(u'Staging file: %s, was not compressed, uploaded as a single file.') % staging_file.filename)

View File

@@ -1,23 +0,0 @@
"""
This file demonstrates two different styles of tests (one doctest and one
unittest). These will both pass when you run "manage.py test".
Replace these 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.failUnlessEqual(1 + 1, 2)
__test__ = {"doctest": """
Another way to test that 1 + 1 is equal to 2.
>>> 1 + 1 == 2
True
"""}

View File

@@ -49,7 +49,7 @@ register_model_list_columns(Document, [
register_links(Tag, [tag_tagged_item_list, tag_edit, tag_delete, tag_acl_list])
register_multi_item_links(['tag_list'], [tag_multiple_delete])
register_links([Tag, 'tag_list', 'tag_create'], [tag_list, tag_create], menu_name='secondary_menu')
register_top_menu('tags', link={'text': _(u'tags'), 'view': 'tag_list', 'famfam': 'tag_blue'}, children_path_regex=[r'^tags/[^d]'])#TODO: change to children view regex or list
register_top_menu('tags', link={'text': _(u'tags'), 'view': 'tag_list', 'famfam': 'tag_blue'}, children_view_regex=[r'^tag_(list|create|delete|edit|tagged|acl)'])
register_links(Document, [tag_document_list], menu_name='form_header')
register_links(['document_tags', 'tag_remove', 'tag_multiple_remove', 'tag_attach'], [tag_attach], menu_name='sidebar')

View File

@@ -14,9 +14,8 @@ from taggit.models import Tag
from documents.models import Document
from documents.views import document_list
from documents.permissions import PERMISSION_DOCUMENT_VIEW
from common.utils import encapsulate
from acls.models import AccessEntry, PermissionDenied
from acls.views import acl_list_for, acl_new_holder_for
from acls.views import acl_list_for
from acls.utils import apply_default_acls
from .forms import TagListForm, TagForm

View File

@@ -1,4 +1,3 @@
from django.utils.translation import ugettext_lazy as _
from django.utils.safestring import mark_safe
@@ -41,7 +40,7 @@ def single_tag_widget(tag):
tags_template = []
tags_template.append('<ul class="tags">')
tags_template.append(get_single_tag_template(tag))
tags_template.append('</ul>')
tags_template.append('</ul>')
return mark_safe(u''.join(tags_template))

View File

@@ -1,10 +1,11 @@
from __future__ import absolute_import
import csv, os, sys
import csv
import os
import sys
from optparse import make_option
from django.core.management.base import BaseCommand, CommandError, LabelCommand
from django.utils.simplejson import loads, dumps
from django.contrib.auth.models import User
from django.db.utils import IntegrityError
@@ -17,11 +18,12 @@ def unicode_csv_reader(unicode_csv_data, dialect=csv.excel, **kwargs):
# decode UTF-8 back to Unicode, cell by cell:
yield [unicode(cell, 'utf-8') for cell in row]
def utf_8_encoder(unicode_csv_data):
for line in unicode_csv_data:
yield line.encode('utf-8')
class Command(LabelCommand):
args = '<filename>'
help = 'Import users from a CSV file with the field order: username, firstname, lastname, email.'
@@ -34,7 +36,7 @@ class Command(LabelCommand):
make_option('--skip-repeated', action='store_true', dest='skip_repeated',
default=False, help='Don\'t exit if the user already exists.'),
)
def handle_label(self, label, **options):
if not os.access(label, os.R_OK):
raise CommandError("File '%s' is not readable." % label)
@@ -68,7 +70,7 @@ class Command(LabelCommand):
sys.exit()
except csv.Error, e:
sys.exit('file %s, line %d: %s' % (label, reader.line_num, e))
sys.exit('file %s, line %d: %s' % (label, reader.line_num, e))
else:
print 'Finish.'
else:

View File

@@ -1,23 +0,0 @@
"""
This file demonstrates two different styles of tests (one doctest and one
unittest). These will both pass when you run "manage.py test".
Replace these 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.failUnlessEqual(1 + 1, 2)
__test__ = {"doctest": """
Another way to test that 1 + 1 is equal to 2.
>>> 1 + 1 == 2
True
"""}

View File

@@ -1,23 +0,0 @@
"""
This file demonstrates two different styles of tests (one doctest and one
unittest). These will both pass when you run "manage.py test".
Replace these 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.failUnlessEqual(1 + 1, 2)
__test__ = {"doctest": """
Another way to test that 1 + 1 is equal to 2.
>>> 1 + 1 == 2
True
"""}