Changeset 7027


Ignore:
Timestamp:
8 Nov 2011, 06:42:07 (13 years ago)
Author:
Henrik Bettermann
Message:

Implement ExportPDFBedTicketSlipPage.

Location:
main/waeup.sirp/trunk/src/waeup/sirp/students
Files:
2 edited

Legend:

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

    r7026 r7027  
    12651265        return 'Bed Ticket %s' % self.context.getSessionString()
    12661266
     1267class BedTicketSlipActionButton(ManageActionButton):
     1268    grok.context(IBedTicket)
     1269    grok.require('waeup.viewStudent')
     1270    icon = 'actionicon_pdf.png'
     1271    text = 'Download bed allocation slip'
     1272    target = 'bed_allocation.pdf'
     1273
     1274class ExportPDFBedTicketSlipPage(grok.View):
     1275    """Deliver a PDF slip of the context.
     1276    """
     1277    grok.context(IBedTicket)
     1278    grok.name('bed_allocation.pdf')
     1279    grok.require('waeup.viewStudent')
     1280    form_fields = grok.AutoFields(IBedTicket)
     1281    form_fields['booking_date'].custom_widget = FriendlyDateDisplayWidget('le')
     1282    prefix = 'form'
     1283
     1284    @property
     1285    def label(self):
     1286        return 'Bed Allocation %s' % self.context.bed_coordinates
     1287
     1288    def render(self):
     1289        studentview = StudentBaseDisplayFormPage(self.context.getStudent(),
     1290            self.request)
     1291        return renderPDF(self,'Bed Allocation', 'bed_allocation.pdf',
     1292            self.context.getStudent, studentview)
     1293
    12671294class RelocateStudentActionButton(ManageActionButton):
    1268     grok.order(1)
     1295    grok.order(2)
    12691296    grok.context(IBedTicket)
    12701297    grok.view(BedTicketDisplayFormPage)
  • main/waeup.sirp/trunk/src/waeup/sirp/students/tests/test_browser.py

    r7026 r7027  
    981981        parts = pin.split('-')[1:]
    982982        sfeseries, sfenumber = parts
     983
    983984        # Students can use HOS code and book a bed space with it
    984985        self.browser.open(self.acco_student_path)
     
    995996        self.assertMatches('...Hall 1, Block A, Room 101, Bed A...',
    996997                           self.browser.contents)
     998
    997999        # Bed has been allocated
    9981000        bed = self.app['hostels']['hall-1']['hall-1_A_101_A']
    9991001        self.assertTrue(bed.owner == self.student_id)
     1002
    10001003        # BedTicketAddPage is now blocked
    10011004        self.browser.getLink("Book accommodation").click()
    10021005        self.assertMatches('...You already booked a bed space...',
    10031006            self.browser.contents)
     1007
    10041008        # The bed ticket displays the data correctly
    10051009        self.browser.open(self.acco_student_path + '/2004')
     
    10091013        self.assertMatches('...regular_male_fr...', self.browser.contents)
    10101014        self.assertMatches('...%s...' % pin, self.browser.contents)
     1015
     1016        # Students can open the pdf slip
     1017        self.browser.open(self.browser.url + '/bed_allocation.pdf')
     1018        self.assertEqual(self.browser.headers['Status'], '200 Ok')
     1019        self.assertEqual(self.browser.headers['Content-Type'], 'application/pdf')
     1020
    10111021        # Students can't relocate themselves
    10121022        self.assertFalse('Relocate' in self.browser.contents)
     
    10141024        self.assertRaises(
    10151025            Unauthorized, self.browser.open, relocate_path)
     1026
    10161027        # Students can't the Remove button and check boxes
    10171028        self.browser.open(self.acco_student_path)
Note: See TracChangeset for help on using the changeset viewer.