PEP8 cleanup, unused imports, missing imports, style cleanups
This commit is contained in:
@@ -1,13 +1,12 @@
|
||||
# encoding: utf-8
|
||||
import datetime
|
||||
from south.db import db
|
||||
from south.v2 import SchemaMigration
|
||||
from django.db import models
|
||||
|
||||
|
||||
class Migration(SchemaMigration):
|
||||
|
||||
def forwards(self, orm):
|
||||
|
||||
# Adding model 'Index'
|
||||
db.create_table('document_indexing_index', (
|
||||
('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
|
||||
@@ -52,9 +51,7 @@ class Migration(SchemaMigration):
|
||||
))
|
||||
db.send_create_signal('document_indexing', ['DocumentRenameCount'])
|
||||
|
||||
|
||||
def backwards(self, orm):
|
||||
|
||||
# Deleting model 'Index'
|
||||
db.delete_table('document_indexing_index')
|
||||
|
||||
@@ -67,7 +64,6 @@ class Migration(SchemaMigration):
|
||||
# Deleting model 'DocumentRenameCount'
|
||||
db.delete_table('document_indexing_documentrenamecount')
|
||||
|
||||
|
||||
models = {
|
||||
'auth.group': {
|
||||
'Meta': {'object_name': 'Group'},
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
# encoding: utf-8
|
||||
import datetime
|
||||
from south.db import db
|
||||
from south.v2 import SchemaMigration
|
||||
from django.db import models
|
||||
|
||||
|
||||
class Migration(SchemaMigration):
|
||||
|
||||
def forwards(self, orm):
|
||||
|
||||
# Deleting model 'DocumentRenameCount'
|
||||
db.delete_table('document_indexing_documentrenamecount')
|
||||
|
||||
@@ -20,9 +19,7 @@ class Migration(SchemaMigration):
|
||||
# Deleting model 'Index'
|
||||
db.delete_table('document_indexing_index')
|
||||
|
||||
|
||||
def backwards(self, orm):
|
||||
|
||||
# Adding model 'DocumentRenameCount'
|
||||
db.create_table('document_indexing_documentrenamecount', (
|
||||
('suffix', self.gf('django.db.models.fields.PositiveIntegerField')(blank=True)),
|
||||
@@ -67,9 +64,8 @@ class Migration(SchemaMigration):
|
||||
))
|
||||
db.send_create_signal('document_indexing', ['Index'])
|
||||
|
||||
|
||||
models = {
|
||||
|
||||
|
||||
}
|
||||
|
||||
complete_apps = ['document_indexing']
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
# encoding: utf-8
|
||||
import datetime
|
||||
from south.db import db
|
||||
from south.v2 import SchemaMigration
|
||||
from django.db import models
|
||||
|
||||
|
||||
class Migration(SchemaMigration):
|
||||
|
||||
def forwards(self, orm):
|
||||
|
||||
# Adding model 'IndexTemplateNode'
|
||||
db.create_table('document_indexing_indextemplatenode', (
|
||||
('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
|
||||
@@ -53,9 +52,7 @@ class Migration(SchemaMigration):
|
||||
))
|
||||
db.send_create_signal('document_indexing', ['Index'])
|
||||
|
||||
|
||||
def backwards(self, orm):
|
||||
|
||||
# Deleting model 'IndexTemplateNode'
|
||||
db.delete_table('document_indexing_indextemplatenode')
|
||||
|
||||
@@ -68,7 +65,6 @@ class Migration(SchemaMigration):
|
||||
# Deleting model 'Index'
|
||||
db.delete_table('document_indexing_index')
|
||||
|
||||
|
||||
models = {
|
||||
'auth.group': {
|
||||
'Meta': {'object_name': 'Group'},
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
# encoding: utf-8
|
||||
import datetime
|
||||
from south.db import db
|
||||
from south.v2 import SchemaMigration
|
||||
from django.db import models
|
||||
|
||||
|
||||
class Migration(SchemaMigration):
|
||||
|
||||
def forwards(self, orm):
|
||||
|
||||
# Adding model 'DocumentRenameCount'
|
||||
db.create_table('document_indexing_documentrenamecount', (
|
||||
('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
|
||||
@@ -17,13 +16,10 @@ class Migration(SchemaMigration):
|
||||
))
|
||||
db.send_create_signal('document_indexing', ['DocumentRenameCount'])
|
||||
|
||||
|
||||
def backwards(self, orm):
|
||||
|
||||
# Deleting model 'DocumentRenameCount'
|
||||
db.delete_table('document_indexing_documentrenamecount')
|
||||
|
||||
|
||||
models = {
|
||||
'auth.group': {
|
||||
'Meta': {'object_name': 'Group'},
|
||||
|
||||
@@ -1,29 +1,25 @@
|
||||
# encoding: utf-8
|
||||
import datetime
|
||||
from south.db import db
|
||||
from south.v2 import SchemaMigration
|
||||
from django.db import models
|
||||
|
||||
|
||||
class Migration(SchemaMigration):
|
||||
|
||||
def forwards(self, orm):
|
||||
|
||||
# Adding unique constraint on 'Index', fields ['name']
|
||||
db.create_unique('document_indexing_index', ['name'])
|
||||
|
||||
# Adding unique constraint on 'Index', fields ['title']
|
||||
db.create_unique('document_indexing_index', ['title'])
|
||||
|
||||
|
||||
def backwards(self, orm):
|
||||
|
||||
# Removing unique constraint on 'Index', fields ['title']
|
||||
db.delete_unique('document_indexing_index', ['title'])
|
||||
|
||||
# Removing unique constraint on 'Index', fields ['name']
|
||||
db.delete_unique('document_indexing_index', ['name'])
|
||||
|
||||
|
||||
models = {
|
||||
'auth.group': {
|
||||
'Meta': {'object_name': 'Group'},
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import datetime
|
||||
from south.db import db
|
||||
from south.v2 import SchemaMigration
|
||||
from django.db import models
|
||||
@@ -16,12 +15,10 @@ class Migration(SchemaMigration):
|
||||
))
|
||||
db.create_unique('document_indexing_index_document_types', ['index_id', 'documenttype_id'])
|
||||
|
||||
|
||||
def backwards(self, orm):
|
||||
# Removing M2M table for field document_types on 'Index'
|
||||
db.delete_table('document_indexing_index_document_types')
|
||||
|
||||
|
||||
models = {
|
||||
'auth.group': {
|
||||
'Meta': {'object_name': 'Group'},
|
||||
@@ -149,4 +146,4 @@ class Migration(SchemaMigration):
|
||||
}
|
||||
}
|
||||
|
||||
complete_apps = ['document_indexing']
|
||||
complete_apps = ['document_indexing']
|
||||
|
||||
@@ -2,9 +2,9 @@ from __future__ import absolute_import
|
||||
|
||||
from documents.models import Document
|
||||
|
||||
from .models import Index, IndexInstanceNode, DocumentRenameCount
|
||||
from .filesystem import fs_delete_directory_recusive
|
||||
from .api import update_indexes
|
||||
from .filesystem import fs_delete_directory_recusive
|
||||
from .models import Index, IndexInstanceNode, DocumentRenameCount
|
||||
|
||||
|
||||
def do_rebuild_all_indexes():
|
||||
|
||||
@@ -12,28 +12,29 @@ from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from acls.models import AccessEntry
|
||||
from acls.utils import apply_default_acls
|
||||
from documents.permissions import PERMISSION_DOCUMENT_VIEW
|
||||
from documents.models import Document
|
||||
from documents.views import document_list
|
||||
from common.utils import encapsulate, generate_choices_w_labels
|
||||
from common.views import assign_remove
|
||||
from common.widgets import two_state_template
|
||||
from documents.permissions import PERMISSION_DOCUMENT_VIEW
|
||||
from documents.models import Document
|
||||
from documents.views import document_list
|
||||
from permissions.models import Permission
|
||||
|
||||
from .forms import IndexForm, IndexTemplateNodeForm
|
||||
from .models import (Index, IndexTemplateNode, IndexInstanceNode)
|
||||
from .tools import do_rebuild_all_indexes
|
||||
from .widgets import (index_instance_item_link, get_breadcrumbs, node_level)
|
||||
from .models import Index, IndexTemplateNode, IndexInstanceNode
|
||||
from .permissions import (PERMISSION_DOCUMENT_INDEXING_VIEW,
|
||||
PERMISSION_DOCUMENT_INDEXING_REBUILD_INDEXES,
|
||||
PERMISSION_DOCUMENT_INDEXING_SETUP,
|
||||
PERMISSION_DOCUMENT_INDEXING_CREATE,
|
||||
PERMISSION_DOCUMENT_INDEXING_EDIT,
|
||||
PERMISSION_DOCUMENT_INDEXING_DELETE
|
||||
)
|
||||
PERMISSION_DOCUMENT_INDEXING_REBUILD_INDEXES,
|
||||
PERMISSION_DOCUMENT_INDEXING_SETUP,
|
||||
PERMISSION_DOCUMENT_INDEXING_CREATE,
|
||||
PERMISSION_DOCUMENT_INDEXING_EDIT,
|
||||
PERMISSION_DOCUMENT_INDEXING_DELETE)
|
||||
from .tools import do_rebuild_all_indexes
|
||||
from .widgets import index_instance_item_link, get_breadcrumbs, node_level
|
||||
|
||||
|
||||
# Setup views
|
||||
|
||||
|
||||
def index_setup_list(request):
|
||||
context = {
|
||||
'title': _(u'indexes'),
|
||||
@@ -55,10 +56,8 @@ def index_setup_list(request):
|
||||
|
||||
context['object_list'] = queryset
|
||||
|
||||
return render_to_response('generic_list.html',
|
||||
context,
|
||||
context_instance=RequestContext(request)
|
||||
)
|
||||
return render_to_response('generic_list.html', context,
|
||||
context_instance=RequestContext(request))
|
||||
|
||||
|
||||
def index_setup_create(request):
|
||||
@@ -77,8 +76,7 @@ def index_setup_create(request):
|
||||
return render_to_response('generic_form.html', {
|
||||
'title': _(u'create index'),
|
||||
'form': form,
|
||||
},
|
||||
context_instance=RequestContext(request))
|
||||
}, context_instance=RequestContext(request))
|
||||
|
||||
|
||||
def index_setup_edit(request, index_pk):
|
||||
@@ -104,8 +102,7 @@ def index_setup_edit(request, index_pk):
|
||||
'index': index,
|
||||
'object_name': _(u'index'),
|
||||
'navigation_object_name': 'index',
|
||||
},
|
||||
context_instance=RequestContext(request))
|
||||
}, context_instance=RequestContext(request))
|
||||
|
||||
|
||||
def index_setup_delete(request, index_pk):
|
||||
@@ -125,9 +122,9 @@ def index_setup_delete(request, index_pk):
|
||||
try:
|
||||
index.delete()
|
||||
messages.success(request, _(u'Index: %s deleted successfully.') % index)
|
||||
except Exception, e:
|
||||
except Exception as exception:
|
||||
messages.error(request, _(u'Index: %(index)s delete error: %(error)s') % {
|
||||
'index': index, 'error': e})
|
||||
'index': index, 'error': exception})
|
||||
|
||||
return HttpResponseRedirect(next)
|
||||
|
||||
@@ -224,8 +221,7 @@ def template_node_create(request, parent_pk):
|
||||
'index': parent_node.index,
|
||||
'object_name': _(u'index'),
|
||||
'navigation_object_name': 'index',
|
||||
},
|
||||
context_instance=RequestContext(request))
|
||||
}, context_instance=RequestContext(request))
|
||||
|
||||
|
||||
def template_node_edit(request, node_pk):
|
||||
@@ -255,8 +251,7 @@ def template_node_edit(request, node_pk):
|
||||
{'object': 'index', 'name': _(u'index')},
|
||||
{'object': 'node', 'name': _(u'node')}
|
||||
],
|
||||
},
|
||||
context_instance=RequestContext(request))
|
||||
}, context_instance=RequestContext(request))
|
||||
|
||||
|
||||
def template_node_delete(request, node_pk):
|
||||
@@ -276,9 +271,9 @@ def template_node_delete(request, node_pk):
|
||||
try:
|
||||
node.delete()
|
||||
messages.success(request, _(u'Node: %s deleted successfully.') % node)
|
||||
except Exception, e:
|
||||
except Exception as exception:
|
||||
messages.error(request, _(u'Node: %(node)s delete error: %(error)s') % {
|
||||
'node': node, 'error': e})
|
||||
'node': node, 'error': exception})
|
||||
|
||||
return HttpResponseRedirect(next)
|
||||
|
||||
@@ -324,10 +319,8 @@ def index_list(request):
|
||||
|
||||
context['object_list'] = queryset
|
||||
|
||||
return render_to_response('generic_list.html',
|
||||
context,
|
||||
context_instance=RequestContext(request)
|
||||
)
|
||||
return render_to_response('generic_list.html', context,
|
||||
context_instance=RequestContext(request))
|
||||
|
||||
|
||||
def index_instance_node_view(request, index_instance_node_pk):
|
||||
@@ -402,10 +395,10 @@ def rebuild_index_instances(request):
|
||||
for warning in warnings:
|
||||
messages.warning(request, warning)
|
||||
|
||||
except Exception, e:
|
||||
except Exception as exception:
|
||||
if settings.DEBUG:
|
||||
raise
|
||||
messages.error(request, _(u'Index rebuild error: %s') % e)
|
||||
messages.error(request, _(u'Index rebuild error: %s') % exception)
|
||||
|
||||
return HttpResponseRedirect(next)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user