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.

File:
1 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   
Note: See TracChangeset for help on using the changeset viewer.