Ignore:
Timestamp:
6 Apr 2011, 09:41:06 (14 years ago)
Author:
Henrik Bettermann
Message:

Implement RemoveFormPage? to remove subobjects in containers.

File:
1 edited

Legend:

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

    r5524 r5917  
    125125    grok.context(IUniversity)
    126126    grok.require('waeup.manageUniversity')
    127     title = u'Edit settings'
     127    title = u'Edit portal settings'
    128128    pnav = 0
    129129
     
    140140        self.flash('Settings have been saved.')
    141141        return
    142 
    143142    @grok.action('Cancel', validator=NullValidator)
    144143    def cancel(self, **data):
     
    152151        self.flash('Plugins were updated. See log file for details.')
    153152        self.redirect(self.url(self.context))
     153        return
     154       
     155class RemoveFormPage(WAeUPPage):
     156    grok.require('waeup.manageUniversity')
     157    grok.name('remove')
     158    grok.template('removesubobjectspage')
     159    pnav = 1
     160
     161    def update(self):
     162        form = self.request.form
     163        if 'CANCEL' in form.keys():
     164            self.redirect(self.url(self.context))
     165        if not 'REMOVE' in form.keys():
     166            return
     167        child_id = form['val_id']
     168        if not isinstance(child_id, list):
     169            child_id = [child_id]
     170        deleted = []
     171        for id in child_id:
     172            try:
     173                del self.context[id]
     174                deleted.append(id)
     175            except:
     176                self.flash('Could not delete %s: %s: %s' % (
     177                        id, sys.exc_info()[0], sys.exc_info()[1]))
     178        if len(deleted):
     179            self.flash('Successfully removed: %s' % ', '.join(deleted))
     180        # We have to redirect to let flash messages appear immediately...
     181        self.redirect(self.url())
    154182        return
    155183
     
    221249    grok.name('add')
    222250    form_fields = grok.AutoFields(IUserAccount)
    223     label = 'Add user'
     251    label = ''
    224252    title = 'Add user'
    225253
     
    318346    grok.template('contactadminform')
    319347    grok.require('waeup.Public')
    320     pnav = 3
     348    pnav = 2
    321349   
    322350    def title(self):
     
    839867    grok.name('add')
    840868    form_fields = grok.AutoFields(IFaculty)
    841     label = 'Add a faculty'
    842     title = 'Add a faculty'
     869    label = ''
     870    title = 'Add faculty'
    843871    pnav = 1
    844872
     
    858886            return
    859887        self.redirect(self.url(self.context))
    860 
    861 class ManageFacultyContainerPage(WAeUPPage):
    862     """ Manage Page
     888       
     889    @grok.action('Cancel')
     890    def cancel(self, **data):
     891        self.redirect(self.url(self.context))   
     892
     893class RemoveFacultyFormPage(RemoveFormPage):
     894    """ Remove Faculty Page
    863895    """
    864896    grok.context(IFacultyContainer)
    865     grok.require('waeup.manageUniversity')
    866     grok.template('facultycontainermanagepage')
    867     grok.name('manage')
    868     title = "Manage Faculties"
    869     pnav = 1
    870 
    871     def update(self):
    872         form = self.request.form
    873         if 'CANCEL' in form.keys():
    874             self.redirect(self.url(self.context))
    875         if not 'DELETE' in form.keys():
    876             return
    877         fac_id = form['fac_id']
    878         if not isinstance(fac_id, list):
    879             fac_id = [fac_id]
    880         deleted = []
    881         for id in fac_id:
    882             try:
    883                 del self.context[id]
    884                 deleted.append(id)
    885             except:
    886                 self.flash('Could not delete %s: %s: %s' % (
    887                         id, sys.exc_info()[0], sys.exc_info()[1]))
    888         if len(deleted):
    889             self.flash('Successfully deleted: %s' % ', '.join(deleted))
    890         # We have to redirect to let flash messages appear immediately...
    891         self.redirect(self.url())
    892         return
     897    title = "Remove faculty"
     898    pnav = 1
    893899
    894900#
     
    917923    grok.require('waeup.manageUniversity')
    918924    form_fields = grok.AutoFields(IDepartment)
    919     title = 'Add a department'
     925    title = 'Add department'
     926    label = ''
    920927    pnav = 1
    921928   
     
    935942            return
    936943        self.redirect(self.url(self.context))
     944       
     945    @grok.action('Cancel')
     946    def cancel(self, **data):
     947        self.redirect(self.url(self.context))           
    937948
    938949class ManageFacultyFormPage(WAeUPEditFormPage):
     
    961972        self.redirect(self.url(self.context))
    962973        return
     974
     975
     976class RemoveDepartmentFormPage(RemoveFormPage):
     977    """ Remove Department Page
     978    """
     979    grok.context(IFaculty)
     980    title = "Remove department"
     981    pnav = 1
     982
    963983
    964984#
     
    9971017    grok.name('manage')
    9981018    grok.require('waeup.manageUniversity')
    999     title = u'Edit department settings'
     1019    title = u'Edit department'
    10001020    pnav = 1
    10011021
     
    11121132    grok.name('manage')
    11131133    grok.require('waeup.manageUniversity')
    1114     title = u'Edit course settings'
     1134    title = u'Edit course'
    11151135    pnav = 1
    11161136
     
    12961316    form_fields = grok.AutoFields(ICertificateCourse)
    12971317    pnav = 1
    1298     title = 'Add a course'
     1318    title = 'Add course'
    12991319
    13001320    @grok.action('Add course')
Note: See TracChangeset for help on using the changeset viewer.