Misc cleanups, PEP8, conding conventions, spaces, unused imports, False/True comparisons

This commit is contained in:
Roberto Rosario
2014-05-23 03:06:26 -04:00
parent cdb93e46ae
commit 935845719f
44 changed files with 188 additions and 223 deletions

View File

@@ -6,25 +6,24 @@ import logging
from django.db import models
from django.core.exceptions import PermissionDenied
from acls.models import AccessEntry
from documents.models import Document
from history.api import create_history
from permissions.models import Permission
from acls.models import AccessEntry
from .exceptions import DocumentNotCheckedOut
from .literals import STATE_CHECKED_OUT, STATE_CHECKED_IN
from .events import (HISTORY_DOCUMENT_CHECKED_IN, HISTORY_DOCUMENT_AUTO_CHECKED_IN,
HISTORY_DOCUMENT_FORCEFUL_CHECK_IN)
from .exceptions import DocumentNotCheckedOut
from .literals import STATE_CHECKED_OUT, STATE_CHECKED_IN
from .permissions import PERMISSION_DOCUMENT_RESTRICTIONS_OVERRIDE
from history.api import create_history
logger = logging.getLogger(__name__)
class DocumentCheckoutManager(models.Manager):
def checked_out_documents(self):
return Document.objects.filter(pk__in=self.model.objects.all().values_list('document__pk', flat=True))
def expired_check_outs(self):
expired_list = Document.objects.filter(pk__in=self.model.objects.filter(expiration_datetime__lte=datetime.datetime.now()).values_list('document__pk', flat=True))
logger.debug('expired_list: %s' % expired_list)
@@ -39,7 +38,7 @@ class DocumentCheckoutManager(models.Manager):
return True
else:
return False
def check_in_document(self, document, user=None):
try:
document_checkout = self.model.objects.get(document=document)
@@ -53,9 +52,9 @@ class DocumentCheckoutManager(models.Manager):
create_history(HISTORY_DOCUMENT_CHECKED_IN, source_object=document, data={'user': user, 'document': document})
else:
create_history(HISTORY_DOCUMENT_AUTO_CHECKED_IN, source_object=document, data={'document': document})
document_checkout.delete()
def document_checkout_info(self, document):
try:
return self.model.objects.get(document=document)
@@ -95,7 +94,6 @@ class DocumentCheckoutManager(models.Manager):
# Last resort check if original user enabled restriction
return not checkout_info.block_new_version
else:
return True
return True
else:
return True
return True