Changeset 6007 for main/waeup.sirp/trunk


Ignore:
Timestamp:
2 May 2011, 07:22:30 (14 years ago)
Author:
Henrik Bettermann
Message:

Implement certificate manage page by using jQueryUI tabs.

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/browser.txt

    r6002 r6007  
    535535
    536536  >>> browser.getControl(name='form.title').value = "Blah"
    537   >>> browser.getControl('Cancel').click()
     537  >>> browser.getControl('Cancel',index=0).click()
    538538
    539539Our certificate was indeed renamed to ``My renamed cert`` and not to
     
    700700---------------------------
    701701
    702 We can delete certcourses by browsing the containing certificate and
    703 clicking on the appropriate 'Delete' button. As we have only one
    704 certcourse, there is only one 'Delete' button yet:
    705 
    706   >>> browser.open(cert_url)
    707   >>> 'COURSE1_200' in browser.contents
     702We can delete certcourses by browsing the containing certificate manage page:
     703
     704  >>> browser.open(cert_url + '/manage#tab-2')
     705  >>> 'COURSE1_200</a>' in browser.contents
    708706  True
    709707
    710   >>> browser.getControl('delete').click()
    711 
    712   >>> browser.open(cert_url)
    713   >>> 'COURSE1_200' in browser.contents
     708  >>> browser.getControl(name='val_id').getControl(value='COURSE1_200').selected = True
     709  >>> browser.getControl('Remove selected course referrers').click()
     710  >>> 'Successfully removed: COURSE1_200' in browser.contents
     711  True
     712 
     713  >>> 'COURSE1_200</a>' in browser.contents
    714714  False
     715
    715716
    716717
  • main/waeup.sirp/trunk/src/waeup/sirp/browser/pages.py

    r6006 r6007  
    13441344        return "Certificate: %s (%s)" % (self.context.title, self.context.code)
    13451345       
    1346     def update(self):
    1347         if 'delcourse' in self.request.form:
    1348             code = self.request.form['code']
    1349             level = self.request.form['level']
    1350             self.context.delCourseRef(code, level=level)
    1351         return
     1346    #def update(self):
     1347    #    if 'delcourse' in self.request.form:
     1348    #        code = self.request.form['code']
     1349    #        level = self.request.form['level']
     1350    #        self.context.delCourseRef(code, level=level)
     1351    #    return
    13521352       
    13531353    def getCourseList(self):
     
    13981398
    13991399class CertificateManageFormPage(WAeUPEditFormPage):
    1400     """Manage the basic properties of a `Certificate` instance.
     1400    """Manage the properties of a `Certificate` instance.
    14011401    """
    14021402    grok.context(ICertificate)
     
    14081408    form_fields = grok.AutoFields(ICertificate)
    14091409   
     1410    pnav = 1
     1411    grok.template('certificatemanagepage')
     1412    taboneactions = ['Save','Cancel']
     1413    tabtwoactions = ['Add course referrer', 'Remove selected course referrers','Cancel']
     1414
     1415    @property
     1416    def label(self):
     1417        return 'Manage certificate'
     1418       
    14101419    @property
    14111420    def title(self):
    1412         return "Certificate: %s (%s)" % (self.context.title, self.context.code)   
    1413 
    1414     #@property
    1415     #def title(self):
    1416     #    # Set certificate name as form label
    1417     #    return self.form_fields['title'].field.get(self.context)
    1418    
     1421        return "Certificate: %s (%s)" % (self.context.title, self.context.code)
     1422
     1423    def update(self):
     1424        tabs.need()
     1425        #warning.need()
     1426        return super(CertificateManageFormPage, self).update()
     1427       
     1428    form_fields = grok.AutoFields(ICertificate)
     1429
    14191430    @grok.action('Save')
    14201431    def save(self, **data):
    14211432        self.applyData(self.context, **data)
    1422        
    1423         #try:
    1424         #    self.applyData(self.context, **data)
    1425         #except NoTransitionAvailableError:
    1426         #    self.status = Invalid('Review state cannot be changed to '
    1427         #                          'requested state: no such transition '
    1428         #                          'available in workflow.')
    1429         #return
    1430    
    1431     @grok.action('Save and return')
    1432     def saveAndReturn(self, **data):
    1433         self.applyData(self.context, **data)
    1434        
    1435         #try:
    1436         #    self.applyData(self.context, **data)
    1437         #except NoTransitionAvailableError:
    1438         #    self.status = Invalid('Review state cannot be changed to '
    1439         #                          'requested state: no such transition '
    1440         #                          'available in workflow.')
    1441         #    return
    1442        
    1443         self.redirect(self.url(self.context))
    1444         return
    1445 
     1433        return
     1434       
     1435    # ToDo: Show warning message before deletion
     1436    @grok.action('Remove selected course referrers')
     1437    def delCertificateCourses(self, **data):
     1438        form = self.request.form
     1439        child_id = form['val_id']
     1440        if not isinstance(child_id, list):
     1441            child_id = [child_id]
     1442        deleted = []
     1443        for id in child_id:
     1444            try:
     1445                del self.context[id]
     1446                deleted.append(id)
     1447            except:
     1448                self.flash('Could not delete %s: %s: %s' % (
     1449                        id, sys.exc_info()[0], sys.exc_info()[1]))
     1450        if len(deleted):
     1451            self.flash('Successfully removed: %s' % ', '.join(deleted))
     1452        self.redirect(self.url(self.context, u'@@manage')+'#tab-2')   
     1453        return       
     1454     
     1455
     1456    @grok.action('Add course referrer', validator=NullValidator)
     1457    def addCertificateCourse(self, **data):
     1458        self.redirect(self.url(self.context, 'addcertificatecourse'))
     1459        return   
     1460       
    14461461    @grok.action('Cancel', validator=NullValidator)
    14471462    def cancel(self, **data):
    14481463        self.redirect(self.url(self.context))
    14491464        return
    1450 
     1465   
     1466   
    14511467class CertificateCourseAddFormPage(WAeUPAddFormPage):
    14521468    """Add-page to add a course ref to a certificate
     
    14751491                                  'this certificate')
    14761492            return
    1477         self.redirect(self.url(self.context))
     1493        self.redirect(self.url(self.context, u'@@manage')+'#tab-2')
    14781494
    14791495    @grok.action('Cancel', validator=NullValidator)
  • main/waeup.sirp/trunk/src/waeup/sirp/browser/templates/certificatepage.pt

    r5991 r6007  
    4343      <th>Semester</th>
    4444      <th>Mandatory</th>
    45       <th>&nbsp;</th>
    4645    </tr>     
    4746  </thead>   
     
    6059    <td tal:content="python:semester[0]">semester</td>
    6160    <td tal:content="courseref/mandatory">mandatory</td>
    62     <td>
    63         <form method="POST">
    64           <input type="hidden" name="code"
    65                  value="" tal:attributes="value courseref/course/code" />
    66           <input type="hidden" name="level"
    67                  value="" tal:attributes="value python:level[0]" />
    68           <input type="submit" name="delcourse" value="delete" />
    69          </form>       
    70     </td>
    7161  </tr>
    7262  </span>
Note: See TracChangeset for help on using the changeset viewer.