Changeset 5936 for main/waeup.sirp/trunk/src
- Timestamp:
- 12 Apr 2011, 23:35:02 (14 years ago)
- Location:
- main/waeup.sirp/trunk/src/waeup/sirp/browser
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/browser/templates/facultycontainerpage.pt
r5929 r5936 30 30 </tbody> 31 31 </table> 32 33 <div tal:content="structure provider:subobjectlist"> 34 List of subobjects 35 </div> -
main/waeup.sirp/trunk/src/waeup/sirp/browser/viewlets.py
r5930 r5936 588 588 link_title = 'Data Center' 589 589 target_viewname = 'datacenter' 590 591 class SubobjectLister(grok.ViewletManager): 592 """Very special viewlet manager that displays lists of subobjects. 593 """ 594 grok.name('subobjectlist') 595 grok.template('subobjectlist') 596 597 def update(self): 598 # The default implementation of update() sets self.viewlets to 599 # a list of viewlets for the current context 600 # (self.context). We make use of that fact by retrieving all 601 # viewlets for all items in our context container by simply 602 # setting these items as context while we call the default 603 # update() method. So we get a list of lists of viewlets for 604 # each item in a 'row' (where a single item is a row). 605 rows = [] 606 orig_context = self.context 607 for name, value in self.context.items(): 608 # Retrieve all viewlets for the current item (not the context) 609 self.context = value 610 super(SubobjectLister, self).update() # sets self.viewlets 611 rows.append(self.viewlets) 612 self.context = orig_context 613 self.rows = rows 614 # Finally, set the viewlets we would retrieve normally... 615 super(SubobjectLister, self).update() 616 return 617 618 619 class FacultyContainerListHead(grok.Viewlet): 620 """The header line of faculty container subobject lists. 621 """ 622 grok.order(1) 623 grok.viewletmanager(SubobjectLister) 624 grok.context(IFacultyContainer) 625 grok.require('waeup.View') 626 627 def render(self): 628 return u'<th>Code</th><th>Title</th><th></th>' 629 630 class FacultyListName(grok.Viewlet): 631 """Display a the title of a faculty as link in a list. 632 """ 633 grok.order(1) 634 grok.viewletmanager(SubobjectLister) 635 grok.context(IFaculty) 636 grok.require('waeup.View') 637 638 def render(self): 639 return u'<a href="%s">%s</a>' % ( 640 self.view.url(self.context), self.context.__name__) 641 642 class FacultyListTitle(grok.Viewlet): 643 """Display the title of a faculty in a list. 644 """ 645 grok.order(2) 646 grok.viewletmanager(SubobjectLister) 647 grok.context(IFaculty) 648 grok.require('waeup.View') 649 650 def render(self): 651 return self.context.title 652 653 class FacultyRemoveButton(grok.Viewlet): 654 """Render a remove button for faculty lists. 655 """ 656 grok.order(3) 657 grok.viewletmanager(SubobjectLister) 658 grok.context(IFaculty) 659 grok.require('waeup.manageUniversity') 660 661 def render(self): 662 return u'<div class="text-right"><form method="POST"><input class="text-right" type="submit" value="remove" /></form></div>'
Note: See TracChangeset for help on using the changeset viewer.