comparison MoinMoin/apps/frontend/views.py @ 484:19b257c0e102

code to get the subitem index flag has been refactored and moved under items/__init__.py and also unitest is added for the same.
author Akash Sinha <akash2607@gmail.com>
date Sat, 09 Jul 2011 00:11:02 +0530
parents 4307261bac75
children 3a3aea61aa1b
comparison
equal deleted inserted replaced
483:4307261bac75 484:19b257c0e102
476 item = Item.create(item_name) 476 item = Item.create(item_name)
477 except AccessDeniedError: 477 except AccessDeniedError:
478 abort(403) 478 abort(403)
479 index = item.flat_index() 479 index = item.flat_index()
480 480
481 index_more_links = [] 481 detailed_index = item.get_detailed_index(index)
482 all_item_index = item.get_index() 482 detailed_index.sort()
483 all_item_text = "\n".join(item_info[1] for item_info in all_item_index)
484 for fullname, relname, contenttype in index:
485 hassubitem = False
486 subitem_name_re = u"%s/" % re.escape(relname)
487 regex = re.compile(subitem_name_re, re.UNICODE)
488 if regex.search(all_item_text):
489 hassubitem = True
490 index_more_links.append((fullname, relname, contenttype, hassubitem))
491 index_more_links.sort()
492 split_char = u'/' 483 split_char = u'/'
493 item_names = item_name.split(split_char) 484 item_names = item_name.split(split_char)
494 485
495 return render_template(item.index_template, 486 return render_template(item.index_template,
496 item=item, item_name=item_name, 487 item=item, item_name=item_name,
497 index=index_more_links, 488 index=detailed_index,
498 item_names=item_names 489 item_names=item_names
499 ) 490 )
500 491
501 492
502 @frontend.route('/+index') 493 @frontend.route('/+index')