Changeset 5917


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

Implement RemoveFormPage? to remove subobjects in containers.

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

Legend:

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

    r5523 r5917  
    144144  >>> print browser.contents
    145145  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
    146   ...<h2>Registered Faculties</h2>
     146  ...<h2>Faculties</h2>
    147147  ...<td><a href="http://localhost/myuniversity/faculties/TF">TF</a></td><td>Faculty of TestFac</td>
    148148  ...
     
    164164
    165165We can change the settings for a faculty by clicking on the
    166 provided 'Edit  settings' button:
    167 
    168   >>> browser.getLink('Edit settings').click()
     166provided 'Edit  faculty' button:
     167
     168  >>> browser.getLink('Edit faculty').click()
    169169
    170170Let's set a new title and save the form:
     
    184184changed:
    185185
    186   >>> browser.getLink('Edit settings').click()
     186  >>> browser.getLink('Edit faculty').click()
    187187  >>> browser.getControl(name='form.title').value = "Blah"
    188188  >>> browser.getControl('Cancel').click()
     
    194194  >>> print browser.contents
    195195  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
    196   ...<h2>Registered Faculties</h2>
     196  ...<h2>Faculties</h2>
    197197  ...<td><a href="http://localhost/myuniversity/faculties/TF">TF</a></td><td>Faculty of My renamed faculty</td>
    198198  ...
     
    250250  >>> print browser.contents
    251251  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
    252   ...<h2>Registered Departments:</h2>
     252  ...<h2>Departments</h2>
    253253  ...<td><a href="http://localhost/myuniversity/faculties/TF/TD">TD</a></td><td>Department of TestDept</td>
    254254  ...
     
    259259
    260260We can change the settings for a department by clicking on the
    261 provided 'Edit settings' button:
     261provided 'Edit department' button:
    262262
    263263  >>> browser.open('http://localhost/myuniversity/faculties/TF/TD')
    264   >>> browser.getLink('Edit settings').click()
     264  >>> browser.getLink('Edit department').click()
    265265
    266266Let's set a new title and save the form:
     
    280280changed:
    281281
    282   >>> browser.getLink('Edit settings').click()
     282  >>> browser.getLink('Edit department').click()
    283283  >>> browser.getControl(name='form.title').value = "Blah"
    284284  >>> browser.getControl('Cancel').click()
     
    290290  >>> print browser.contents
    291291  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
    292   ...<h2>Registered Departments:</h2>
     292  ...<h2>Departments</h2>
    293293  ...<td><a href="http://localhost/myuniversity/faculties/TF/TD">TD</a></td><td>Department of My renamed dept</td>
    294294  ...
     
    384384
    385385  >>> browser.open(dept_url + '/courses/COURSE1')
    386   >>> browser.getLink('Edit settings').click()
     386  >>> browser.getLink('Edit course').click()
    387387
    388388When modifying a course, we cannot change the code any more:
     
    409409changed:
    410410
    411   >>> browser.getLink('Edit settings').click()
     411  >>> browser.getLink('Edit course').click()
    412412  >>> browser.getControl(name='form.title').value = "Blah"
    413413  >>> browser.getControl('Cancel').click()
     
    530530
    531531We can change the settings for a cert by clicking on the provided
    532 'Edit settings' link:
     532'Edit certificate' link:
    533533
    534534  >>> browser.open(dept_url + '/certificates/CERT1')
    535   >>> browser.getLink('Edit settings').click()
     535  >>> browser.getLink('Edit certificate').click()
    536536
    537537When modifying a certificate, we cannot change the code any more:
     
    558558changed:
    559559
    560   >>> browser.getLink('Edit settings').click()
     560  >>> browser.getLink('Edit certificate').click()
    561561  >>> browser.getControl(name='form.title').value = "Blah"
    562562  >>> browser.getControl('Cancel').click()
     
    690690
    691691We can change the settings for a certcourse by clicking on the
    692 provided 'Edit settings' link:
     692provided 'Edit certificate course' link:
    693693
    694694  >>> browser.open(cert_url + '/COURSE1_100')
    695   >>> browser.getLink('Edit settings').click()
     695  >>> browser.getLink('Edit certificate course').click()
    696696
    697697Let's set a new level (it was 100 before) and save the form. This will
     
    711711changed:
    712712
    713   >>> browser.getLink('Edit settings').click()
     713  >>> browser.getLink('Edit certificate course').click()
    714714  >>> browser.getControl(name='form.level').value = "666"
    715715  >>> browser.getControl('Cancel').click()
  • 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')
  • main/waeup.sirp/trunk/src/waeup/sirp/browser/templates/facultycontainerpage.pt

    r4789 r5917  
    1   <h2>Registered Faculties</h2>
     1  <h2>Faculties</h2>
    22
    33  <div tal:condition="python: not len(context.keys())">
  • main/waeup.sirp/trunk/src/waeup/sirp/browser/templates/facultypage.pt

    r4789 r5917  
    1   <h2>Registered Departments:</h2>
     1  <h2>Departments</h2>
    22
    33
  • main/waeup.sirp/trunk/src/waeup/sirp/browser/viewlets.py

    r5914 r5917  
    6262    icon = 'actionicon_modify.png' # File must exist in static/
    6363    target = '@@manage' # link to this viewname.
    64     text = 'Edit settings' # Text to display on the button
     64    text = 'Edit' # Text to display on the button
    6565
    6666    # We set the template file explicitly (instead of using
     
    125125    icon = 'actionicon_modify.png'
    126126    target = '@@manage'
    127     text = 'Edit settings'
     127    text = 'Edit'
    128128
    129129class AddActionButton(ActionButton):
     
    133133    grok.order(4)
    134134    grok.require('waeup.manageUniversity')
    135     icon = 'actionicon_addfavorite.png'
     135    icon = 'actionicon_add.png'
    136136    target = 'add'
    137137    text = 'Add'
     138   
     139class RemoveActionButton(ActionButton):
     140    """A base for 'remove' buttons.
     141    """
     142    grok.baseclass()
     143    grok.order(4)
     144    grok.require('waeup.manageUniversity')
     145    icon = 'actionicon_delete.png'
     146    target = 'remove'
     147    text = 'Remove'   
    138148
    139149class SearchActionButton(ActionButton):
     
    282292#
    283293class ManageUniversityActionButton(ManageActionButton):
    284     """ 'Edit settings' button for University instances.
     294    """ 'Edit' button for University instances.
    285295    """
    286296    grok.context(IUniversity)
    287297    grok.view(UniversityPage)
    288    
    289 class ManageFacultiesActionButton(ManageActionButton):
    290     """ 'Edit settings' button for faculty container.
    291     """
    292     grok.context(IFacultyContainer)
    293     grok.view(FacultyContainerPage)
     298    text = 'Edit portal settings'
     299   
     300#class ManageFacultiesActionButton(ManageActionButton):
     301#    """ 'Edit settings' button for faculty container.
     302#    """
     303#    grok.context(IFacultyContainer)
     304#    grok.view(FacultyContainerPage)
    294305
    295306class ManageDataCenterActionButton(ManageActionButton):
     
    298309    grok.context(IDataCenter)
    299310    grok.view(DatacenterPage)
     311    text = 'Edit settings'
    300312   
    301313class ManageFacultyActionButton(ManageActionButton):
     
    304316    grok.context(IFaculty)
    305317    grok.view(FacultyPage)
     318    text = 'Edit faculty'
    306319
    307320class ManageDepartmentActionButton(ManageActionButton):
     
    310323    grok.context(IDepartment)
    311324    grok.view(DepartmentPage)
     325    text = 'Edit department'
    312326
    313327class ManageCourseActionButton(ManageActionButton):
     
    316330    grok.context(ICourse)
    317331    grok.view(CoursePage)
     332    text = 'Edit course'
    318333   
    319334class ManageCertificateActionButton(ManageActionButton):
     
    322337    grok.context(ICertificate)
    323338    grok.view(CertificatePage)
     339    text = 'Edit certificate'
    324340
    325341class ManageCertificateCourseActionButton(ManageActionButton):
     
    328344    grok.context(ICertificateCourse)
    329345    grok.view(CertificateCoursePage)
     346    text = 'Edit certificate course'
    330347
    331348#
     
    363380    text = 'Add course reference'
    364381    target = 'addcertificatecourse'
     382
     383#
     384# Remove actions...
     385#
     386
     387
     388class RemoveFacultyActionButton(RemoveActionButton):
     389    grok.context(IFacultyContainer)
     390    grok.view(FacultyContainerPage)
     391    text = 'Remove faculty'
     392   
     393class RemoveDepartmentActionButton(RemoveActionButton):
     394    grok.context(IFaculty)
     395    grok.view(FacultyPage)
     396    text = 'Remove department'
     397
    365398
    366399#
Note: See TracChangeset for help on using the changeset viewer.