Changeset 6000


Ignore:
Timestamp:
1 May 2011, 04:05:43 (14 years ago)
Author:
Henrik Bettermann
Message:

Implement faculty manage page by using jQueryUI tabs. RemoveFormPages? are now redundant.

Location:
main/waeup.sirp/trunk/src/waeup/sirp/browser
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.sirp/trunk/src/waeup/sirp/browser/pages.py

    r5999 r6000  
    155155        return
    156156       
    157 class RemoveFormPage(WAeUPPage):
    158     grok.require('waeup.manageUniversity')
    159     grok.name('remove')
    160     grok.template('removesubobjectspage')
    161     pnav = 1
    162 
    163     def update(self):
    164         warning.need()
    165         form = self.request.form
    166         if 'CANCEL' in form.keys():
    167             self.redirect(self.url(self.context))
    168         if not 'REMOVE' in form.keys():
    169             return
    170         child_id = form['val_id']
    171         if not isinstance(child_id, list):
    172             child_id = [child_id]
    173         deleted = []
    174         for id in child_id:
    175             try:
    176                 del self.context[id]
    177                 deleted.append(id)
    178             except:
    179                 self.flash('Could not delete %s: %s: %s' % (
    180                         id, sys.exc_info()[0], sys.exc_info()[1]))
    181         if len(deleted):
    182             self.flash('Successfully removed: %s' % ', '.join(deleted))
    183         # We have to redirect to let flash messages appear immediately...
    184         self.redirect(self.url())
    185         return
     157#class RemoveFormPage(WAeUPPage):
     158#    grok.require('waeup.manageUniversity')
     159#    grok.name('remove')
     160#    grok.template('removesubobjectspage')
     161#    pnav = 1
     162#
     163#    def update(self):
     164#        warning.need()
     165#        form = self.request.form
     166#        if 'CANCEL' in form.keys():
     167#            self.redirect(self.url(self.context))
     168#        if not 'REMOVE' in form.keys():
     169#            return
     170#        child_id = form['val_id']
     171#        if not isinstance(child_id, list):
     172#            child_id = [child_id]
     173#        deleted = []
     174#        for id in child_id:
     175#            try:
     176#                del self.context[id]
     177#                deleted.append(id)
     178#            except:
     179#                self.flash('Could not delete %s: %s: %s' % (
     180#                        id, sys.exc_info()[0], sys.exc_info()[1]))
     181#        if len(deleted):
     182#            self.flash('Successfully removed: %s' % ', '.join(deleted))
     183#        # We have to redirect to let flash messages appear immediately...
     184#        self.redirect(self.url())
     185#        return
    186186
    187187class AdministrationPage(WAeUPPage):
     
    846846    grok.name('index')
    847847    title = 'Academics'
    848     label = 'Faculties'
     848    label = 'Academic Section'
    849849    pnav = 1
    850850    grok.template('facultypage')
     
    884884                                  'in the database')
    885885            return
    886         self.redirect(self.url(self.context))
     886        self.redirect(self.url(self.context, u'@@manage')+'#tab-1')
    887887       
    888888    @grok.action('Cancel')
     
    890890        self.redirect(self.url(self.context))   
    891891
    892 class RemoveFacultyFormPage(RemoveFormPage):
    893     """ Remove Faculty Page
    894     """
    895     grok.context(IFacultyContainer)
    896     title = "Remove faculty"
    897     pnav = 1
     892#class RemoveFacultyFormPage(RemoveFormPage):
     893#   """ Remove Faculty Page
     894#    """
     895#    grok.context(IFacultyContainer)
     896#    title = "Remove faculty"
     897#    pnav = 1
    898898
    899899#
     
    953953                                  'in the database')
    954954            return
    955         self.redirect(self.url(self.context, u'@@manage'))
     955        self.redirect(self.url(self.context, u'@@manage')+'#tab-2')
    956956       
    957957    @grok.action('Cancel')
     
    969969    taboneactions = ['Save','Save and return','Cancel']
    970970    tabtwoactions = ['Add department', 'Remove selected','Cancel']
     971    subunits = 'Departments'
    971972
    972973    form_fields = grok.AutoFields(IFaculty)
     
    10071008        if len(deleted):
    10081009            self.flash('Successfully removed: %s' % ', '.join(deleted))
     1010        self.redirect(self.url(self.context, u'@@manage')+'#tab-2')   
    10091011        return       
    10101012
    10111013    @grok.action('Add department', validator=NullValidator)
    10121014    def addDepartment(self, **data):
     1015        self.redirect(self.url(self.context, '@@add'))
     1016        return   
     1017       
     1018    @grok.action('Cancel', validator=NullValidator)
     1019    def cancel(self, **data):
     1020        self.redirect(self.url(self.context))
     1021        return
     1022
     1023class ManageFacultyContainerFormPage(WAeUPEditFormPage):
     1024    """Manage the basic properties of a `Faculty` instance.
     1025    """
     1026    grok.context(IFacultyContainer)
     1027    grok.name('manage')
     1028    grok.require('waeup.manageUniversity')
     1029    grok.template('facultycontainermanagepage')
     1030    pnav = 1
     1031    taboneactions = ['Add faculty', 'Remove selected','Cancel']
     1032    subunits = 'Faculties'
     1033    title = 'Academics'
     1034
     1035    @property
     1036    def label(self):
     1037        return 'Manage academic section'
     1038       
     1039    def update(self):
     1040        tabs.need()
     1041        #warning.need()
     1042        return super(ManageFacultyContainerFormPage, self).update()
     1043
     1044    # ToDo: Show warning message before deletion
     1045    @grok.action('Remove selected')
     1046    def delFaculties(self, **data):
     1047        form = self.request.form
     1048        child_id = form['val_id']
     1049        if not isinstance(child_id, list):
     1050            child_id = [child_id]
     1051        deleted = []
     1052        for id in child_id:
     1053            try:
     1054                del self.context[id]
     1055                deleted.append(id)
     1056            except:
     1057                self.flash('Could not delete %s: %s: %s' % (
     1058                        id, sys.exc_info()[0], sys.exc_info()[1]))
     1059        if len(deleted):
     1060            self.flash('Successfully removed: %s' % ', '.join(deleted))
     1061        self.redirect(self.url(self.context, '@@manage')+'#tab-1')   
     1062        return       
     1063
     1064    @grok.action('Add faculty', validator=NullValidator)
     1065    def addFaculty(self, **data):
    10131066        self.redirect(self.url(self.context, '@@add'))
    10141067        return   
  • main/waeup.sirp/trunk/src/waeup/sirp/browser/templates/facultymanagepage.pt

    r5999 r6000  
    2525<ul>
    2626  <li><a href="#tab-1"><span>Settings</span></a></li>
    27   <li><a href="#tab-2"><span>Contents</span></a></li>
     27  <li><a href="#tab-2"><span tal:content="view/subunits">Contents</span></a></li>
    2828</ul>
    2929   
     
    7373   
    7474<div id="tab-2">
    75   <h3>Departments</h3>
     75  <h3 tal:content="view/subunits">Departments</h3>
    7676  <table class="zebra">
    7777    <thead>
  • main/waeup.sirp/trunk/src/waeup/sirp/browser/viewlets.py

    r5999 r6000  
    310310    grok.view(DatacenterPage)
    311311    text = 'Edit settings'
     312
     313class ManageFacultyContainerActionButton(ManageActionButton):
     314    """ 'Manage settings' button for faculties.
     315    """
     316    grok.context(IFacultyContainer)
     317    grok.view(FacultyContainerPage)
     318    text = 'Manage academic section'
    312319   
    313320class ManageFacultyActionButton(ManageActionButton):
    314     """ 'Edit settings' button for faculties.
     321    """ 'Manage settings' button for faculties.
    315322    """
    316323    grok.context(IFaculty)
     
    356363    text = 'Add user'
    357364
    358 class AddFacultyActionButton(AddActionButton):
    359     grok.context(IFacultyContainer)
    360     grok.view(FacultyContainerPage)
    361     text = 'Add faculty'
     365#class AddFacultyActionButton(AddActionButton):
     366#    grok.context(IFacultyContainer)
     367#    grok.view(FacultyContainerPage)
     368#    text = 'Add faculty'
    362369   
    363370#class AddDepartmentActionButton(AddActionButton):
     
    392399
    393400
    394 class RemoveFacultyActionButton(RemoveActionButton):
    395     grok.context(IFacultyContainer)
    396     grok.view(FacultyContainerPage)
    397     text = 'Remove faculty'
     401#class RemoveFacultyActionButton(RemoveActionButton):
     402#    grok.context(IFacultyContainer)
     403#    grok.view(FacultyContainerPage)
     404#    text = 'Remove faculty'
    398405   
    399406#class RemoveDepartmentActionButton(RemoveActionButton):
Note: See TracChangeset for help on using the changeset viewer.