Changeset 6956


Ignore:
Timestamp:
26 Oct 2011, 10:47:02 (13 years ago)
Author:
Henrik Bettermann
Message:

Add more fields and fix code.

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

Legend:

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

    r6954 r6956  
    3232from waeup.sirp.browser.resources import toggleall
    3333from waeup.sirp.authentication import get_principal_role_manager
    34 from waeup.sirp.students.browser import msave
    3534from waeup.sirp.hostels.container import HostelsContainer
    3635from waeup.sirp.hostels.hostel import Hostel
    3736from waeup.sirp.hostels.interfaces import IHostelsContainer, IHostel
    3837
     38def write_log_message(view, message):
     39    ob_class = view.__implemented__.__name__.replace('waeup.sirp.','')
     40    view.context.loggerInfo(ob_class, message)
     41    return
     42
     43# Save function used for save methods in manager pages
     44def msave(view, **data):
     45    form = view.request.form
     46    changed_fields = view.applyData(view.context, **data)
     47    # Turn list of lists into single list
     48    if changed_fields:
     49        changed_fields = reduce(lambda x,y: x+y, changed_fields.values())
     50    fields_string = ' + '.join(changed_fields)
     51    view.context._p_changed = True
     52    view.flash('Form has been saved.')
     53    if fields_string:
     54        write_log_message(view, 'saved: % s' % fields_string)
     55    return
    3956
    4057class HostelsTab(PrimaryNavTab):
     
    118135        hostel = Hostel()
    119136        self.applyData(hostel, **data)
     137        hostel.hostel_id = data['hostel_name'].lower().replace(' ','_')
    120138        self.context.addHostel(hostel)
    121139        self.flash('Hostel created.')
     
    132150    pnav = 5
    133151
    134     #@property
    135     #def label(self):
    136     #    return self.context.name
     152    @property
     153    def label(self):
     154        return self.context.hostel_name
    137155
    138     #@property
    139     #def title(self):
    140     #    return self.title
     156    @property
     157    def title(self):
     158        return self.context.hostel_name
    141159
    142160class HostelManageActionButton(ManageActionButton):
     
    159177    pnav = 5
    160178
    161     #@property
    162     #def title(self):
    163     #    return self.context.name
     179    @property
     180    def title(self):
     181        return self.context.hostel_name
    164182
    165183    def update(self):
  • main/waeup.sirp/trunk/src/waeup/sirp/hostels/container.py

    r6953 r6956  
    2020from grok import index
    2121from waeup.sirp.hostels.interfaces import IHostelsContainer, IHostel
    22 from waeup.sirp.utils.helpers import attrs_to_fields
     22from waeup.sirp.utils.helpers import attrs_to_fields, get_current_principal
    2323from waeup.sirp.utils.logger import Logger
    2424
  • main/waeup.sirp/trunk/src/waeup/sirp/hostels/interfaces.py

    r6954 r6956  
    1919        """
    2020
     21    #hostel_id = Attribute('Hostel Id')
     22
    2123    hostel_id = schema.TextLine(
    22         title = u'Hostel ID',
     24        title = u'Hostel Id',
     25        readonly = True,
     26        )
     27
     28    sort_id = schema.Int(
     29        title = u'Sort Id',
     30        required = True,
     31        default = 10,
     32        )
     33
     34    hostel_name = schema.TextLine(
     35        title = u'Hall Name',
    2336        required = True,
    2437        default = u'hostel_1',
    2538        )
     39
     40    nr_of_blocks = schema.Int(
     41        title = u'Number of Blocks',
     42        required = True,
     43        default = 3,
     44        )
     45
     46    nr_of_floors = schema.Int(
     47        title = u'Number of Blocks',
     48        required = True,
     49        default = 3,
     50        )
     51
     52    rooms_per_floor = schema.Int(
     53        title = u'Number of Blocks',
     54        required = True,
     55        default = 20,
     56        )
     57
     58    beds_per_room = schema.Int(
     59        title = u'Number of Blocks',
     60        required = True,
     61        default = 6,
     62        )
     63
Note: See TracChangeset for help on using the changeset viewer.