Changeset 6959


Ignore:
Timestamp:
27 Oct 2011, 10:22:32 (13 years ago)
Author:
Henrik Bettermann
Message:

Add pagetemplates and extend logging.

Location:
main/waeup.sirp/trunk/src/waeup/sirp/hostels
Files:
4 added
3 edited

Legend:

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

    r6956 r6959  
    2121from zope.component import createObject
    2222from waeup.sirp.browser import (
    23     WAeUPPage, WAeUPEditFormPage, WAeUPAddFormPage, WAeUPDisplayFormPage)
     23    WAeUPPage, WAeUPEditFormPage, WAeUPAddFormPage, WAeUPDisplayFormPage,
     24    NullValidator)
    2425from waeup.sirp.browser.breadcrumbs import Breadcrumb
    25 from waeup.sirp.browser.resources import datepicker, datatable, tabs
     26from waeup.sirp.browser.resources import datepicker, datatable, tabs, toggleall
    2627from waeup.sirp.browser.viewlets import (
    2728    ManageActionButton, PrimaryNavTab, AddActionButton)
     
    3031    FriendlyDateWidget, FriendlyDateDisplayWidget,
    3132    FriendlyDatetimeDisplayWidget)
    32 from waeup.sirp.browser.resources import toggleall
     33from waeup.sirp.browser.pages import delSubobjects
    3334from waeup.sirp.authentication import get_principal_role_manager
    3435from waeup.sirp.hostels.container import HostelsContainer
     
    8283    grok.context(IHostel)
    8384
     85    def title(self):
     86        return self.context.hostel_name
     87
    8488class HostelsContainerPage(WAeUPDisplayFormPage):
    8589    """The standard view for hostels containers.
     
    8892    grok.name('index')
    8993    grok.require('waeup.viewHostels')
    90     #grok.template('containerpage')
     94    grok.template('containerpage')
    9195    label = 'Accommodation Section'
    92     title = 'Accommodation'
     96    title = 'Hostels'
    9397    pnav = 5
    9498
     
    106110    grok.name('manage')
    107111    grok.require('waeup.manageHostels')
    108     #grok.template('containermanagepage')
    109     pnav = 5
    110     title = 'Accommodation'
     112    grok.template('containermanagepage')
     113    pnav = 5
     114    title = 'Hostels'
    111115    label = 'Manage accommodation section'
    112116
    113 class HostelsContainerAddActionButton(AddActionButton):
    114     grok.order(1)
    115     grok.context(IHostelsContainer)
    116     grok.view(HostelsContainerManagePage)
    117     grok.require('waeup.manageHostels')
    118     text = 'Add hostel'
    119     target = 'addhostel'
     117    # It's quite dangerous to remove entire hostels with its content (beds).
     118    # Thus, this removed should be combined with an archiving function.
     119    @grok.action('Remove selected')
     120    def delHostels(self, **data):
     121        form = self.request.form
     122        if form.has_key('val_id'):
     123            deleted = []
     124            child_id = form['val_id']
     125            child_id = [child_id]
     126            for id in child_id:
     127                deleted.append(id)
     128            write_log_message(self, 'deleted: % s' % ', '.join(deleted))
     129        delSubobjects(self, redirect='@@manage', tab='2')
     130        return
     131
     132    @grok.action('Add hostel', validator=NullValidator)
     133    def addSubunit(self, **data):
     134        self.redirect(self.url(self.context, 'addhostel'))
     135        return
    120136
    121137class HostelAddFormPage(WAeUPAddFormPage):
     
    127143    grok.template('hosteladdpage')
    128144    form_fields = grok.AutoFields(IHostel)
    129     title = 'Accommodation'
     145    title = 'Hostels'
    130146    label = 'Add hostel'
    131147    pnav = 5
     
    138154        self.context.addHostel(hostel)
    139155        self.flash('Hostel created.')
     156        write_log_message(self, 'added: % s' % data['hostel_name'])
    140157        self.redirect(self.url(self.context[hostel.hostel_id], 'index'))
    141158        return
     
    174191    form_fields = grok.AutoFields(IHostel).omit('hostel_id')
    175192    #grok.template('hostelmanagepage')
    176     label = 'Manage hostel data'
     193    label = 'Manage hostel'
    177194    pnav = 5
    178195
  • main/waeup.sirp/trunk/src/waeup/sirp/hostels/container.py

    r6956 r6959  
    6262                user, ob_class, target, comment))
    6363        return
     64
     65    def loggerInfo(self, ob_class, comment=None):
     66        target = self.__name__
     67        return self.logger_info(ob_class,target,comment)
  • main/waeup.sirp/trunk/src/waeup/sirp/hostels/interfaces.py

    r6958 r6959  
    3434        title = u'Hall Name',
    3535        required = True,
    36         default = u'hostel_1',
     36        default = u'Hall 1',
    3737        )
    3838
     
    4343        )
    4444
    45     nr_of_floors = schema.Int(
    46         title = u'Number of Floors',
     45    floors_per_block = schema.Int(
     46        title = u'Floors per Block',
    4747        required = True,
    4848        default = 3,
Note: See TracChangeset for help on using the changeset viewer.