Final changes to support duplicate document search

This commit is contained in:
Roberto Rosario
2011-02-21 19:32:03 -04:00
parent 5209847ab5
commit 5b4f2ecb57
4 changed files with 39 additions and 20 deletions
+1 -1
View File
@@ -12,7 +12,7 @@ check_settings = {'text':_(u'settings'), 'view':'check_settings', 'famfam':'cog'
register_menu([
{'text':_(u'home'), 'view':'home', 'famfam':'house', 'position':0},
{'text':_(u'tools'), 'view':'document_find_all_duplicates', 'links': [
{'text':_(u'tools'), 'view':'tools_menu', 'links': [
document_find_all_duplicates,
],'famfam':'wrench', 'name':'tools','position':7},
+2 -1
View File
@@ -3,5 +3,6 @@ from django.conf.urls.defaults import *
urlpatterns = patterns('main.views',
url(r'^$', 'home', (), 'home'),
url(r'^check_settings/$', 'check_settings', (), 'check_settings')
url(r'^check_settings/$', 'check_settings', (), 'check_settings'),
url(r'^tools_menu/$', 'blank_menu', (), 'tools_menu')
)
+12 -4
View File
@@ -64,8 +64,8 @@ def check_settings(request):
'hide_object':True,
'extra_columns':[
{'name':_(u'name'), 'attribute':'name'},
{'name':_(u'value'), 'attribute': lambda x: return_type(x['value'])},
{'name':_(u'exists'), 'attribute':lambda x: exists(x['value']) if 'exists' in x else ''},
{'name':_(u'value'), 'attribute': lambda x: _return_type(x['value'])},
{'name':_(u'exists'), 'attribute':lambda x: _exists(x['value']) if 'exists' in x else ''},
]
}
@@ -73,7 +73,7 @@ def check_settings(request):
context_instance=RequestContext(request))
def return_type(value):
def _return_type(value):
if isinstance(value, types.FunctionType):
return _(u'function found')
elif isinstance(value, types.ClassType):
@@ -85,8 +85,16 @@ def return_type(value):
else:
return value
def exists(path):
def _exists(path):
try:
return os.path.exists(path)
except Exception, exc:
return exc
def blank_menu(request):
return render_to_response('generic_template.html', {
'title':_(u'Tools menu'),
'content':_(u'"Find all duplicates": Search all the documents\' checksums and return a list of the exact matches.')
},
context_instance=RequestContext(request))