PEP8 cleanups, unused imports and bumped version to 0.7.3
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
"""Configuration options for the document_indexing app"""
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from common.utils import proper_name
|
||||
from smart_settings.api import register_settings
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ def _index_instance_item_link(index_instance_item):
|
||||
return u'<span class="famfam active famfam-%(icon)s"></span><a href="%(url)s">%(text)s</a>' % {
|
||||
'url': index_instance_item.get_absolute_url(), 'icon': icon, 'text': index_instance_item}
|
||||
|
||||
|
||||
|
||||
def index_instance_list(request, index_id=None):
|
||||
check_permissions(request.user, [PERMISSION_DOCUMENT_INDEXING_VIEW])
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ HISTORY_DOCUMENT_EDITED = {
|
||||
'summary': _(u'Document "%(content_object)s" edited by %(fullname)s.'),
|
||||
'details': _(u'Document "%(content_object)s" was edited on %(datetime)s by %(fullname)s. The following changes took place: %(changes)s.'),
|
||||
'expressions': {
|
||||
'fullname': 'user.get_full_name() if user.get_full_name() else user.username',
|
||||
'fullname': 'user.get_full_name() if user.get_full_name() else user.username',
|
||||
'changes': 'u\', \'.join([\'"%s": "%s" -> "%s"\' % (key, value[\'old_value\'], value[\'new_value\']) for key, value in diff.items()])'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ class StagingFile(object):
|
||||
@classmethod
|
||||
def get_all(cls):
|
||||
"""
|
||||
Return a list of StagingFile instances corresponding to the
|
||||
Return a list of StagingFile instances corresponding to the
|
||||
current path
|
||||
"""
|
||||
staging_files = []
|
||||
|
||||
@@ -167,7 +167,7 @@ def upload_document_with_type(request, source):
|
||||
document_type = get_object_or_404(DocumentType, pk=document_type_id[0])
|
||||
else:
|
||||
document_type = None
|
||||
|
||||
|
||||
if request.method == 'POST':
|
||||
if source == UPLOAD_SOURCE_LOCAL:
|
||||
form = DocumentForm(request.POST, request.FILES, document_type=document_type)
|
||||
@@ -279,7 +279,7 @@ def document_view(request, document_id, advanced=False):
|
||||
# Triggers a 404 error on documents uploaded via local upload
|
||||
# TODO: investigate
|
||||
document = get_object_or_404(Document, pk=document_id)
|
||||
|
||||
|
||||
RecentDocument.objects.add_document_for_user(request.user, document)
|
||||
|
||||
subtemplates_list = []
|
||||
@@ -294,7 +294,7 @@ def document_view(request, document_id, advanced=False):
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
content_form = DocumentContentForm(document=document)
|
||||
|
||||
subtemplates_list.append(
|
||||
@@ -333,7 +333,7 @@ def document_view(request, document_id, advanced=False):
|
||||
'title': _(u'document properties'),
|
||||
}
|
||||
},
|
||||
)
|
||||
)
|
||||
|
||||
if document.tags.count():
|
||||
subtemplates_list.append(get_tags_subtemplate(document))
|
||||
@@ -445,7 +445,7 @@ def document_edit(request, document_id):
|
||||
if 'document_type_available_filenames' in form.cleaned_data:
|
||||
if form.cleaned_data['document_type_available_filenames']:
|
||||
document.file_filename = form.cleaned_data['document_type_available_filenames'].filename
|
||||
|
||||
|
||||
document.save()
|
||||
create_history(HISTORY_DOCUMENT_EDITED, document, {'user': request.user, 'diff': return_diff(old_document, document, ['file_filename', 'description'])})
|
||||
RecentDocument.objects.add_document_for_user(request.user, document)
|
||||
|
||||
@@ -25,7 +25,7 @@ class DocumentCreateWizard(BoundFormWizard):
|
||||
}
|
||||
if data not in initial:
|
||||
initial.append(data)
|
||||
|
||||
|
||||
return initial
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
"""Configuration options for the grouping app"""
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from smart_settings.api import register_settings
|
||||
|
||||
register_settings(
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from navigation.api import register_links
|
||||
from permissions.api import register_permission, set_namespace_title
|
||||
|
||||
PERMISSION_HISTORY_VIEW = {'namespace': 'history', 'name': u'history_view', 'label': _(u'Access the history app')}
|
||||
|
||||
@@ -4,8 +4,6 @@ import json
|
||||
from django.db.utils import DatabaseError
|
||||
#from django.utils import simplejson
|
||||
from django.core import serializers
|
||||
from django.utils.translation import ugettext
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.shortcuts import get_object_or_404
|
||||
from django.db import models
|
||||
|
||||
@@ -51,7 +49,6 @@ def create_history(history_type_dict, source_object=None, data=None):
|
||||
else:
|
||||
new_dict[key]['value'] = json.dumps(value)
|
||||
new_dict[key]['type'] = pickle.dumps(type(value))
|
||||
|
||||
|
||||
new_history.dictionary = json.dumps(new_dict)
|
||||
print 'new_history', new_history
|
||||
new_history.save()
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
from django import forms
|
||||
|
||||
from common.forms import DetailForm
|
||||
|
||||
from history.models import History
|
||||
|
||||
@@ -34,8 +34,6 @@ class History(models.Model):
|
||||
history_type = models.ForeignKey(HistoryType, verbose_name=_(u'history type'))
|
||||
dictionary = models.TextField(verbose_name=_(u'dictionary'), blank=True)
|
||||
|
||||
#objects = HistoryManager()
|
||||
|
||||
def __unicode__(self):
|
||||
return u'%s - %s - %s' % (self.datetime, self.content_object, self.history_type)
|
||||
|
||||
@@ -77,9 +75,9 @@ def _process_history_text(history, text):
|
||||
'content_object': history.content_object,
|
||||
'datetime': history.datetime
|
||||
}
|
||||
|
||||
|
||||
loaded_dictionary = json.loads(history.dictionary)
|
||||
|
||||
|
||||
new_dict = {}
|
||||
for key, values in loaded_dictionary.items():
|
||||
value_type = pickle.loads(str(values['type']))
|
||||
@@ -93,7 +91,7 @@ def _process_history_text(history, text):
|
||||
new_dict[key] = qs
|
||||
else:
|
||||
new_dict[key] = json.loads(values['value'])
|
||||
|
||||
|
||||
key_values.update(new_dict)
|
||||
expressions_dict = {}
|
||||
|
||||
|
||||
@@ -5,4 +5,3 @@ urlpatterns = patterns('history.views',
|
||||
url(r'^list/for_object/(?P<app_label>[\w\-]+)/(?P<module_name>[\w\-]+)/(?P<object_id>\d+)/$', 'history_for_object', (), 'history_for_object'),
|
||||
url(r'^(?P<object_id>\d+)/$', 'history_view', (), 'history_view'),
|
||||
)
|
||||
|
||||
|
||||
@@ -2,17 +2,13 @@ from django.shortcuts import render_to_response
|
||||
from django.template import RequestContext
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.shortcuts import get_object_or_404
|
||||
from django.contrib import messages
|
||||
from django.http import HttpResponseRedirect
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.utils.http import urlencode
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.db.models.loading import get_model
|
||||
from django.http import Http404
|
||||
|
||||
from permissions.api import check_permissions
|
||||
|
||||
from history.models import History
|
||||
from history.api import history_types_dict
|
||||
from history.forms import HistoryDetailForm
|
||||
from history import PERMISSION_HISTORY_VIEW
|
||||
|
||||
@@ -87,7 +83,7 @@ def history_view(request, object_id):
|
||||
check_permissions(request.user, [PERMISSION_HISTORY_VIEW])
|
||||
|
||||
history = get_object_or_404(History, pk=object_id)
|
||||
|
||||
|
||||
form = HistoryDetailForm(instance=history, extra_fields=[
|
||||
{'label': _(u'Date'), 'field':lambda x: x.datetime.date()},
|
||||
{'label': _(u'Time'), 'field':lambda x: unicode(x.datetime.time()).split('.')[0]},
|
||||
@@ -95,7 +91,7 @@ def history_view(request, object_id):
|
||||
{'label': _(u'Event type'), 'field': lambda x: x.get_label()},
|
||||
{'label': _(u'Event details'), 'field': lambda x: x.get_processed_details()},
|
||||
])
|
||||
|
||||
|
||||
return render_to_response('generic_detail.html', {
|
||||
'title': _(u'details for: %s') % history.get_processed_summary(),
|
||||
'form': form,
|
||||
|
||||
@@ -23,7 +23,7 @@ sentry = {'text': _(u'sentry'), 'url': '/sentry', 'famfam': 'bug', 'condition':
|
||||
__version_info__ = {
|
||||
'major': 0,
|
||||
'minor': 7,
|
||||
'micro': 2,
|
||||
'micro': 3,
|
||||
'releaselevel': 'final',
|
||||
'serial': 0
|
||||
}
|
||||
@@ -48,7 +48,7 @@ register_links(['setting_list'], tool_links, menu_name='secondary_menu')
|
||||
register_links(permission_views, tool_links, menu_name='secondary_menu')
|
||||
register_links(user_management_views, tool_links, menu_name='secondary_menu')
|
||||
|
||||
|
||||
|
||||
def get_version():
|
||||
"""
|
||||
Return the formatted version information
|
||||
|
||||
@@ -28,8 +28,8 @@ class MetadataSetAdmin(admin.ModelAdmin):
|
||||
|
||||
class DocumentTypeDefaultsAdmin(admin.ModelAdmin):
|
||||
filter_horizontal = ('default_metadata_sets', 'default_metadata')
|
||||
|
||||
|
||||
|
||||
|
||||
admin.site.register(MetadataType, MetadataTypeAdmin)
|
||||
admin.site.register(MetadataSet, MetadataSetAdmin)
|
||||
admin.site.register(DocumentTypeDefaults, DocumentTypeDefaultsAdmin)
|
||||
|
||||
@@ -33,7 +33,7 @@ def decode_metadata_from_url(url_dict):
|
||||
|
||||
def save_metadata_list(metadata_list, document, create=False):
|
||||
"""
|
||||
Take a list of metadata dictionaries and associate them to a
|
||||
Take a list of metadata dictionaries and associate them to a
|
||||
document
|
||||
"""
|
||||
for item in metadata_list:
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
import datetime
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.contrib.auth.models import User
|
||||
|
||||
from smart_settings.api import register_settings
|
||||
|
||||
@@ -78,7 +78,7 @@ class MetadataSelectionForm(forms.Form):
|
||||
self.fields['metadata_types'].initial = defaults.default_metadata.all()
|
||||
except DocumentTypeDefaults.DoesNotExist:
|
||||
pass
|
||||
|
||||
|
||||
metadata_sets = forms.ModelMultipleChoiceField(
|
||||
queryset=MetadataSet.objects.all(),
|
||||
label=_(u'Metadata sets'),
|
||||
|
||||
@@ -10,7 +10,7 @@ def register_multi_item_links(src, links, menu_name=None):
|
||||
Register a multiple item action action to be displayed in the
|
||||
generic list template
|
||||
"""
|
||||
|
||||
|
||||
multi_object_navigation.setdefault(menu_name, {})
|
||||
if hasattr(src, '__iter__'):
|
||||
for one_src in src:
|
||||
@@ -24,8 +24,8 @@ def register_multi_item_links(src, links, menu_name=None):
|
||||
def register_links(src, links, menu_name=None):
|
||||
"""
|
||||
Associate a link to a model a view, or an url
|
||||
"""
|
||||
|
||||
"""
|
||||
|
||||
object_navigation.setdefault(menu_name, {})
|
||||
if hasattr(src, '__iter__'):
|
||||
for one_src in src:
|
||||
@@ -41,7 +41,7 @@ def register_top_menu(name, link, children_views=None, children_path_regex=None,
|
||||
Register a new menu entry for the main menu displayed at the top
|
||||
of the page
|
||||
"""
|
||||
|
||||
|
||||
entry = {'link': link, 'name': name}
|
||||
if children_views:
|
||||
entry['children_views'] = children_views
|
||||
@@ -58,7 +58,7 @@ def register_model_list_columns(model, columns):
|
||||
Define which columns will be displayed in the generic list template
|
||||
for a given model
|
||||
"""
|
||||
|
||||
|
||||
model_list_columns.setdefault(model, [])
|
||||
model_list_columns[model].extend(columns)
|
||||
|
||||
|
||||
@@ -25,19 +25,19 @@ class TopMenuNavigationNode(Node):
|
||||
request = Variable('request').resolve(context)
|
||||
current_path = request.META['PATH_INFO']
|
||||
current_view = resolve_to_name(current_path)
|
||||
|
||||
|
||||
all_menu_links = [entry.get('link', {}) for entry in top_menu_entries]
|
||||
menu_links = resolve_links(context, all_menu_links, current_view, current_path)
|
||||
|
||||
|
||||
for index, link in enumerate(top_menu_entries):
|
||||
children_views = link.get('children_views', [])
|
||||
if current_view in children_views:
|
||||
menu_links[index]['active'] = True
|
||||
|
||||
|
||||
children_path_regex = link.get('children_path_regex', [])
|
||||
for child_path_regex in children_path_regex:
|
||||
if re.compile(child_path_regex).match(current_path.lstrip('/')):
|
||||
menu_links[index]['active'] = True
|
||||
menu_links[index]['active'] = True
|
||||
|
||||
context['menu_links'] = menu_links
|
||||
return ''
|
||||
@@ -46,7 +46,7 @@ class TopMenuNavigationNode(Node):
|
||||
@register.tag
|
||||
def get_top_menu_links(parser, token):
|
||||
return TopMenuNavigationNode()
|
||||
|
||||
|
||||
|
||||
def resolve_arguments(context, src_args):
|
||||
args = []
|
||||
|
||||
@@ -28,6 +28,7 @@ register_links(['role_members', 'role_list', 'role_view', 'role_create', 'role_e
|
||||
|
||||
permission_views = ['role_list', 'role_create', 'role_edit', 'role_members', 'role_permissions', 'role_delete']
|
||||
|
||||
|
||||
def user_post_save(sender, instance, **kwargs):
|
||||
if kwargs.get('created', False):
|
||||
for default_role in DEFAULT_ROLES:
|
||||
|
||||
@@ -169,8 +169,8 @@ def tag_tagged_item_list(request, tag_id):
|
||||
object_list = [tagged_item.content_object for tagged_item in tag.taggit_taggeditem_items.all()]
|
||||
|
||||
return document_list(
|
||||
request,
|
||||
object_list=object_list,
|
||||
request,
|
||||
object_list=object_list,
|
||||
title=_('documents with the tag "%s"') % tag,
|
||||
extra_context={
|
||||
'object': tag
|
||||
|
||||
Reference in New Issue
Block a user