Changeset 6002 for main/waeup.sirp/trunk


Ignore:
Timestamp:
1 May 2011, 12:00:22 (14 years ago)
Author:
Henrik Bettermann
Message:

Implement department manage page by using jQueryUI tabs.

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

Legend:

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

    r6001 r6002  
    248248
    249249  >>> browser.open('http://localhost/myuniversity/faculties/TF/TD')
    250   >>> browser.getLink('Edit department').click()
     250  >>> browser.getLink('Manage department').click()
    251251
    252252Let's set a new title and save the form:
     
    256256
    257257Clicking 'Save' we will stay on the settings form. So we can change
    258 the department again. This time we will return to the overview page
    259 afterwards:
     258the department again.
    260259
    261260  >>> browser.getControl(name='form.title').value = "My renamed dept"
    262   >>> ctrl = browser.getControl("Save and return")
     261  >>> ctrl = browser.getControl("Save")
    263262  >>> ctrl.click()
    264263
    265 If we go to the settings page and click ``Cancel`` nothing will be
    266 changed:
    267 
    268   >>> browser.getLink('Edit department').click()
    269   >>> browser.getControl(name='form.title').value = "Blah"
    270   >>> browser.getControl('Cancel').click()
    271 
    272 Our department was indeed renamed to ``My renamed dept`` and not to
    273 ``Blah``:
     264
     265Our department was indeed renamed to ``My renamed dept``:
    274266
    275267  >>> browser.open('http://localhost/myuniversity/faculties/TF')
     
    414406----------------
    415407
    416 We can delete courses by browsing the containing department and
    417 clicking on the appropriate 'Delete' button. As we have only one
    418 course, there is only one 'Delete' button yet:
    419 
    420   >>> browser.open('http://localhost/myuniversity/faculties/TF/TD')
     408We can delete courses by browsing the manage page of the containing department and
     409checking the appropriate select box and clicking the ´´Remove selected´´ button.
     410
     411  >>> browser.open('http://localhost/myuniversity/faculties/TF/TD/@@manage#tab-2')
    421412  >>> 'My renamed course' in browser.contents
    422413  True
    423414
    424   >>> browser.getControl('Delete').click()
     415  >>> browser.getControl(name='val_id').getControl(value='COURSE1').selected = True
     416  >>> browser.getControl('Remove selected courses').click()
    425417
    426418  >>> browser.open('http://localhost/myuniversity/faculties/TF/TD')
     
    518510
    519511  >>> browser.open(dept_url + '/certificates/CERT1')
    520   >>> browser.getLink('Edit certificate').click()
     512  >>> browser.getLink('Manage certificate').click()
    521513
    522514When modifying a certificate, we cannot change the code any more:
     
    533525
    534526Clicking 'Save' we will stay on the settings form. So we can change
    535 the cert again. This time we will return to the overview page
    536 afterwards:
     527the cert again.
    537528
    538529  >>> browser.getControl(name='form.title').value = "My renamed cert"
    539   >>> ctrl = browser.getControl("Save and return")
     530  >>> ctrl = browser.getControl("Save",index=0)
    540531  >>> ctrl.click()
    541532
     
    543534changed:
    544535
    545   >>> browser.getLink('Edit certificate').click()
    546536  >>> browser.getControl(name='form.title').value = "Blah"
    547537  >>> browser.getControl('Cancel').click()
     
    561551---------------------
    562552
    563 We can delete certificates by browsing the containing department and
    564 clicking on the appropriate 'Delete' button. As we have only one
    565 certificate, there is only one 'Delete' button yet:
    566 
    567   >>> browser.open('http://localhost/myuniversity/faculties/TF/TD')
     553We can delete certificates by browsing the manage page of the containing department and
     554checking the appropriate select box and clicking the ´´Remove selected´´ button.
     555
     556  >>> browser.open('http://localhost/myuniversity/faculties/TF/TD/@@manage#tab-3')
    568557  >>> 'My renamed cert' in browser.contents
    569558  True
    570559
    571   >>> browser.getControl('Delete').click()
    572 
    573   >>> browser.open('http://localhost/myuniversity/faculties/TF/TD')
     560  >>> browser.getControl(name='val_id').getControl(value='CERT1').selected = True
     561  >>> browser.getControl('Remove selected certificates').click()
    574562  >>> 'My renamed cert' in browser.contents
    575563  False
  • main/waeup.sirp/trunk/src/waeup/sirp/browser/pages.py

    r6000 r6002  
    10911091    grok.name('index')
    10921092    pnav = 1
     1093    label = 'Courses and Certificates'
    10931094
    10941095    @property
    10951096    def title(self):
    1096         #import pdb; pdb.set_trace()
    10971097        return self.context.longtitle()
    10981098   
    10991099    def update(self):
    1100         yui.tabview.need()
    1101         if 'delcourse' in self.request.form:
    1102             code = self.request.form['code']
    1103             del self.context.courses[code]
    1104         if 'delcert' in self.request.form:
    1105             code = self.request.form['code']
    1106             del self.context.certificates[code]
     1100        tabs.need()
     1101        #if 'delcourse' in self.request.form:
     1102        #    code = self.request.form['code']
     1103        #    del self.context.courses[code]
     1104        #if 'delcert' in self.request.form:
     1105        #    code = self.request.form['code']
     1106        #    del self.context.certificates[code]
    11071107        self.tables = ITableProvider(self.context).getTables(view=self)
    11081108        self.coursetable = self.tables[0]
     
    11161116    grok.name('manage')
    11171117    grok.require('waeup.manageUniversity')
    1118     title = u'Edit department'
    1119     pnav = 1
     1118    pnav = 1
     1119    grok.template('departmentmanagepage')
     1120    taboneactions = ['Save','Cancel']
     1121    tabtwoactions = ['Add course', 'Remove selected courses','Cancel']
     1122    tabthreeactions = ['Add certificate', 'Remove selected certificates', 'Cancel']
     1123
     1124    @property
     1125    def label(self):
     1126        return 'Manage department'
     1127       
     1128    @property
     1129    def title(self):
     1130        return self.context.longtitle()   
     1131
     1132    def update(self):
     1133        tabs.need()
     1134        self.tables = ITableProvider(self.context).getTables(view=self)
     1135        self.coursetable = self.tables[0]
     1136        self.certificatetable = self.tables[1]
     1137        self.coursetable.need()
    11201138
    11211139    form_fields = grok.AutoFields(IDepartment)
     
    11251143        self.applyData(self.context, **data)
    11261144        return
    1127    
    1128     @grok.action('Save and return')
    1129     def saveAndReturn(self, **data):
    1130         self.applyData(self.context, **data)
    1131         self.redirect(self.url(self.context))
    1132         return
    1133 
     1145       
     1146    # ToDo: Show warning message before deletion
     1147    @grok.action('Remove selected courses')
     1148    def delCourses(self, **data):
     1149        form = self.request.form
     1150        child_id = form['val_id']
     1151        if not isinstance(child_id, list):
     1152            child_id = [child_id]
     1153        deleted = []
     1154        for id in child_id:
     1155            try:
     1156                del self.context.courses[id]
     1157                deleted.append(id)
     1158            except:
     1159                self.flash('Could not delete %s: %s: %s' % (
     1160                        id, sys.exc_info()[0], sys.exc_info()[1]))
     1161        if len(deleted):
     1162            self.flash('Successfully removed: %s' % ', '.join(deleted))
     1163        self.redirect(self.url(self.context, u'@@manage')+'#tab-2')   
     1164        return       
     1165     
     1166    @grok.action('Remove selected certificates')   
     1167    def delCertificates(self, **data):
     1168        form = self.request.form
     1169        child_id = form['val_id']
     1170        if not isinstance(child_id, list):
     1171            child_id = [child_id]
     1172        deleted = []
     1173        for id in child_id:
     1174            try:
     1175                del self.context.certificates[id]
     1176                deleted.append(id)
     1177            except:
     1178                self.flash('Could not delete %s: %s: %s' % (
     1179                        id, sys.exc_info()[0], sys.exc_info()[1]))
     1180        if len(deleted):
     1181            self.flash('Successfully removed: %s' % ', '.join(deleted))
     1182        self.redirect(self.url(self.context, u'@@manage')+'#tab-3')   
     1183        return               
     1184
     1185    @grok.action('Add course', validator=NullValidator)
     1186    def addCourse(self, **data):
     1187        self.redirect(self.url(self.context, 'addcourse'))
     1188        return   
     1189       
     1190    @grok.action('Add certificate', validator=NullValidator)
     1191    def addCertificate(self, **data):
     1192        self.redirect(self.url(self.context, 'addcertificate'))
     1193        return                     
     1194   
    11341195    @grok.action('Cancel', validator=NullValidator)
    11351196    def cancel(self, **data):
     
    11611222                                  'in the database')
    11621223            return
    1163         self.redirect(self.url(self.context))
     1224        self.redirect(self.url(self.context, u'@@manage')+'#tab-2')   
    11641225
    11651226    @grok.action('Cancel', validator=NullValidator)
     
    12021263                                  'in the database')
    12031264            return
    1204         self.redirect(self.url(self.context))
     1265        self.redirect(self.url(self.context, u'@@manage')+'#tab-3')   
    12051266
    12061267    @grok.action('Cancel', validator=NullValidator)
  • main/waeup.sirp/trunk/src/waeup/sirp/browser/tables.py

    r5945 r6002  
    4848        delcol = Col(header=' ', sortable=False,
    4949                     data = [
    50                 '<form method="post">'
    51                 '<input type="submit" name="delcourse" value="Delete" />'
    52                 '<input type="hidden" name="code" value="%s" />'
    53                 '</form>' % (data[x].code)
    54                 for x in data])
     50                '<input type="checkbox" name="val_id" value="%s" />'
     51                % (data[x].code) for x in data])
    5552
    5653        if checkPermission('waeup.manageUniversity', self.context.courses):
    5754            cols = list(cols)
    58             cols.append(delcol)
     55            cols = [delcol] + cols
    5956            cols = tuple(cols)
    6057        self.coursetable = Table('Courses', cols=cols)
     
    7572        delcol = Col(header='&nbsp;', sortable=False,
    7673                     data = [
    77                 '<form method="post">'
    78                 '<input type="submit" name="delcert" value="Delete" />'
    79                 '<input type="hidden" name="code" value="%s" />'
    80                 '</form>' % (data[x].code)
    81                 for x in data])
     74                '<input type="checkbox" name="val_id" value="%s" />'
     75                % (data[x].code) for x in data])
    8276
    8377        if checkPermission('waeup.manageUniversity', self.context.certificates):
    8478            certcols = list(certcols)
    85             certcols.append(delcol)
     79            certcols = [delcol] + certcols
    8680            certcols = tuple(certcols)
    8781
  • main/waeup.sirp/trunk/src/waeup/sirp/browser/templates/departmentpage.pt

    r4789 r6002  
    11<script type="text/javascript">
    22  var tabView = new YAHOO.widget.TabView('table-tabs');
    3 </script>
    4 <div id="table-tabs" class="yui-navset">
    5   <ul class="yui-nav">
    6     <li class="selected"><a href="#tab1"><em>Courses</em></a></li>
    7     <li><a href="#tab2"><em>Certificates</em></a></li>
    8   </ul>             
    9   <div class="yui-content">
    10     <div id="tab1">
    11        
    12       <div name="thecoursetable"
    13            tal:condition="python: len(context.courses.keys())">
    14         <div tal:replace="structure view/coursetable/renderHTML" />
    15       </div>
     3</script>
    164
     5<h2 i18n:translate=""
     6tal:condition="view/label"
     7tal:content="view/label">Label</h2>
     8
     9<div id="tabs">
     10    <ul>
     11      <li><a href="#tab-1"><span>Courses</span></a></li>
     12      <li><a href="#tab-2"><span>Certificates</span></a></li>
     13    </ul>
     14    <div id="tab-1"> 
     15        <div name="thecoursetable" tal:condition="python: len(context.courses.keys())">
     16        <div tal:replace="structure view/coursetable/renderHTML"></div>
     17        </div>
     18    </div>
     19    <div id="tab-2"> 
     20        <div name="thecerttable">
     21        <div tal:replace="structure view/certificatetable/renderHTML"></div>
     22        </div>
    1723    </div>
    18     <div id="tab2">
    19 
    20       <div name="thecerttable">
    21         <div tal:replace="structure view/certificatetable/renderHTML" />
    22       </div>
    23 
    24     </div>
    25   </div>
    2624</div>
  • main/waeup.sirp/trunk/src/waeup/sirp/browser/viewlets.py

    r6000 r6002  
    326326
    327327class ManageDepartmentActionButton(ManageActionButton):
    328     """ 'Edit settings' button for departments.
     328    """ 'Manage settings' button for departments.
    329329    """
    330330    grok.context(IDepartment)
    331331    grok.view(DepartmentPage)
    332     text = 'Edit department'
     332    text = 'Manage department'
    333333
    334334class ManageCourseActionButton(ManageActionButton):
     
    340340   
    341341class ManageCertificateActionButton(ManageActionButton):
    342     """ 'Edit settings' button for certificates.
     342    """ 'Manage settings' button for certificates.
    343343    """
    344344    grok.context(ICertificate)
    345345    grok.view(CertificatePage)
    346     text = 'Edit certificate'
     346    text = 'Manage certificate'
    347347
    348348class ManageCertificateCourseActionButton(ManageActionButton):
    349     """ 'Edit settings' button for certificate courses.
     349    """ 'Manage settings' button for certificate courses.
    350350    """
    351351    grok.context(ICertificateCourse)
     
    373373#    text = 'Add department'
    374374
    375 class AddCertificateActionButton(AddActionButton):
    376     grok.context(IDepartment)
    377     grok.view(DepartmentPage)
    378     grok.order(3)
    379     text = 'Add certificate'
    380     target = 'addcertificate'
    381    
    382 class AddCourseActionButton(AddActionButton):
    383     grok.context(IDepartment)
    384     grok.view(DepartmentPage)
    385     grok.order(4)
    386     text = 'Add course'
    387     target = 'addcourse'
    388 
    389 class AddCertificateCourseActionButton(AddActionButton):
    390     grok.context(ICertificate)
    391     grok.view(CertificatePage)
    392     grok.order(4)
    393     text = 'Add course referrer'
    394     target = 'addcertificatecourse'
     375#class AddCertificateActionButton(AddActionButton):
     376#    grok.context(IDepartment)
     377#    grok.view(DepartmentPage)
     378#    grok.order(3)
     379#    text = 'Add certificate'
     380#    target = 'addcertificate'
     381   
     382#class AddCourseActionButton(AddActionButton):
     383#    grok.context(IDepartment)
     384#    grok.view(DepartmentPage)
     385#    grok.order(4)
     386#    text = 'Add course'
     387#    target = 'addcourse'
     388
     389#class AddCertificateCourseActionButton(AddActionButton):
     390#    grok.context(ICertificate)
     391#    grok.view(CertificatePage)
     392#    grok.order(4)
     393#    text = 'Add course referrer'
     394#    target = 'addcertificatecourse'
    395395
    396396#
Note: See TracChangeset for help on using the changeset viewer.