Changeset 8685 for main/waeup.kofa/trunk


Ignore:
Timestamp:
12 Jun 2012, 07:17:01 (13 years ago)
Author:
Henrik Bettermann
Message:

Add hostel allocation start end end date attributes to hostels.

Move hostel allocation parameters from configuration to hostels. AccommodationOfficer? must be able to edit these parameters.

Location:
main/waeup.kofa/trunk/src/waeup/kofa
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/browser/static/waeup-base.css

    r8463 r8685  
    232232}
    233233
    234 .ordered-selection-field {
    235 }
     234table .ordered-selection-field select {
     235  width: 250px;
     236}
  • main/waeup.kofa/trunk/src/waeup/kofa/hostels/browser.py

    r7833 r8685  
    3838from waeup.kofa.hostels.interfaces import (
    3939    IHostelsContainer, IHostel, IBed, IBedAllocateStudent)
     40from waeup.kofa.widgets.datewidget import FriendlyDatetimeDisplayWidget
    4041
    4142def write_log_message(view, message):
     
    105106    label = _('Accommodation Section')
    106107    pnav = 5
     108    form_fields = grok.AutoFields(IHostelsContainer)
     109    form_fields[
     110        'startdate'].custom_widget = FriendlyDatetimeDisplayWidget('le')
     111    form_fields[
     112        'enddate'].custom_widget = FriendlyDatetimeDisplayWidget('le')
    107113
    108114class HostelsContainerManageActionButton(ManageActionButton):
     
    113119    text = _('Manage accommodation section')
    114120
    115 class HostelsContainerManagePage(KofaDisplayFormPage):
     121class HostelsContainerManagePage(KofaEditFormPage):
    116122    """The manage page for hostel containers.
    117123    """
     
    122128    pnav = 5
    123129    label = _('Manage accommodation section')
     130    form_fields = grok.AutoFields(IHostelsContainer)
     131    taboneactions = [_('Save')]
     132    tabtwoactions = [_('Add hostel'), _('Remove selected')]
    124133
    125134    def update(self):
     135        tabs.need()
     136        self.tab1 = self.tab2 = self.tab3 = self.tab4 = ''
     137        qs = self.request.get('QUERY_STRING', '')
     138        if not qs:
     139            qs = 'tab1'
     140        setattr(self, qs, 'active')
    126141        warning.need()
     142        datatable.need()
    127143        return super(HostelsContainerManagePage, self).update()
    128144
     
    146162    def addSubunit(self, **data):
    147163        self.redirect(self.url(self.context, 'addhostel'))
     164        return
     165
     166    @action(_('Save'), style='primary')
     167    def save(self, **data):
     168        self.applyData(self.context, **data)
     169        self.flash(_('Settings have been saved.'))
    148170        return
    149171
  • main/waeup.kofa/trunk/src/waeup/kofa/hostels/browser_templates/containermanagepage.pt

    r7811 r8685  
    22    i18n:domain="waeup.kofa"
    33    method="POST" enctype="multipart/form-data">
    4   <table>
    5     <thead>
    6       <tr>
    7         <th>&nbsp;
    8         </th>
    9         <th i18n:translate="">Id
    10         </th>
    11         <th i18n:translate="">Name
    12         </th>
    13       </tr>
    14     </thead>
    15     <tbody>
    16       <tr tal:repeat="hostel context/values"> <td>
    17           <input type="checkbox" name="val_id" tal:attributes="value hostel/hostel_id" /> </td> <td>
    18           <a tal:attributes="href python: view.url(hostel)" tal:content="hostel/__name__"> ID</a> </td> <td>
    19           <span tal:content="hostel/hostel_name">ID
    20           </span> </td>
    21       </tr>
    22     </tbody>
    23   </table>
    24   <div tal:condition="view/availableActions">
    25     <span tal:repeat="action view/actions" tal:omit-tag="">
    26       <input tal:replace="structure action/render"/>
    27     </span>
     4
     5
     6  <ul class="tabs" data-tabs="tabs">
     7    <li tal:attributes="class view/tab1">
     8    <a href="#tab-1">
     9      <span i18n:translate="">Settings
     10      </span></a>
     11    </li>
     12    <li tal:attributes="class view/tab2">
     13    <a href="#tab-2" i18n:translate="">Hostels</a>
     14    </li>
     15  </ul>
     16
     17  <div class="tab-content">
     18    <div id="tab-1" tal:attributes="class view/tab1">
     19      <table class="form-table">
     20        <tbody>
     21          <tal:widgets content="structure provider:widgets" />
     22        </tbody>
     23      </table>
     24      <div tal:condition="view/availableActions">
     25        <span tal:repeat="action view/actions" tal:omit-tag="">
     26          <input tal:condition="python:action.label in view.taboneactions"
     27            tal:replace="structure action/render"/>
     28        </span>
     29      </div>
     30    </div>
     31    <div id="tab-2" tal:attributes="class view/tab2"> <br />
     32      <table class="display dataTableManage">
     33        <thead>
     34          <tr>
     35            <th>&nbsp;
     36            </th>
     37            <th i18n:translate="">Id
     38            </th>
     39            <th i18n:translate="">Name
     40            </th>
     41          </tr>
     42        </thead>
     43        <tbody>
     44          <tr tal:repeat="hostel context/values"> <td>
     45              <input type="checkbox" name="val_id" tal:attributes="value hostel/hostel_id" /> </td> <td>
     46              <a tal:attributes="href python: view.url(hostel)" tal:content="hostel/__name__"> ID</a> </td> <td>
     47              <span tal:content="hostel/hostel_name">ID
     48              </span> </td>
     49          </tr>
     50        </tbody>
     51      </table>
     52      <div tal:condition="view/availableActions">
     53        <span tal:repeat="action view/actions" tal:omit-tag="">
     54          <input tal:condition="python:action.label in view.tabtwoactions"
     55            tal:replace="structure action/render"/>
     56        </span>
     57      </div>
     58    </div>
    2859  </div>
    2960</form>
  • main/waeup.kofa/trunk/src/waeup/kofa/hostels/browser_templates/containerpage.pt

    r7811 r8685  
    1 <div i18n:domain="waeup.kofa"
    2    i18n:translate="" tal:condition="python: not len(context.keys())">
    3 There no subobjects registered yet.
    4 </div>
     1<table class="form-table" i18n:domain="waeup.kofa">
     2  <tbody>
     3    <tal:block repeat="widget view/widgets">
     4      <tr>
     5        <td class="fieldname">
     6          <span tal:content="widget/label">LABEL</span>:
     7        </td>
     8        <td>
     9          <span tal:content="structure widget">
     10            <input type="text" />
     11          </span>
     12        </td>
     13      </tr>
     14    </tal:block>
     15  </tbody>
     16</table>
    517
    618<table i18n:domain="waeup.kofa">
  • main/waeup.kofa/trunk/src/waeup/kofa/hostels/container.py

    r7811 r8685  
    2222from waeup.kofa.hostels.interfaces import IHostelsContainer, IHostel
    2323from waeup.kofa.utils.logger import Logger
     24from waeup.kofa.utils.helpers import attrs_to_fields
    2425
    2526class HostelsContainer(grok.Container, Logger):
     
    6162        target = self.__name__
    6263        return self.logger_info(ob_class,target,comment)
     64
     65HostelsContainer = attrs_to_fields(HostelsContainer)
  • main/waeup.kofa/trunk/src/waeup/kofa/hostels/hostel.py

    r8234 r8685  
    202202            notify(grok.ObjectModifiedEvent(self))
    203203            accommodation_session = grok.getSite()[
    204                 'configuration'].accommodation_session
     204                'hostels'].accommodation_session
    205205            try:
    206206                bedticket = grok.getSite()['students'][old_owner][
  • main/waeup.kofa/trunk/src/waeup/kofa/hostels/interfaces.py

    r7819 r8685  
    1616## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
    1717##
     18from datetime import datetime
    1819from zope.interface import invariant, Invalid
    1920from zope import schema
    20 from waeup.kofa.interfaces import IKofaObject
     21from waeup.kofa.interfaces import (
     22    IKofaObject, academic_sessions_vocab, registration_states_vocab)
    2123from waeup.kofa.interfaces import MessageFactory as _
    2224from waeup.kofa.hostels.vocabularies import (
     
    2729
    2830    """
     31
     32    startdate = schema.Datetime(
     33        title = _(u'Hostel Allocation Start Date'),
     34        required = False,
     35        description = _('Example:') + u'2011-12-01 18:30:00+01:00',
     36        )
     37
     38    enddate = schema.Datetime(
     39        title = _(u'Hostel Allocation Closing Date'),
     40        required = False,
     41        description = _('Example:') + u'2011-12-31 23:59:59+01:00',
     42        )
     43
     44    accommodation_session = schema.Choice(
     45        title = _(u'Booking Session'),
     46        source = academic_sessions_vocab,
     47        default = datetime.now().year,
     48        required = False,
     49        readonly = False,
     50        )
     51
     52    accommodation_states = schema.List(
     53        title = _(u'Allowed States'),
     54        value_type = schema.Choice(
     55            vocabulary = registration_states_vocab,
     56            ),
     57        default = [],
     58        )
    2959
    3060class IHostel(IKofaObject):
  • main/waeup.kofa/trunk/src/waeup/kofa/hostels/tests.py

    r8234 r8685  
    124124
    125125        # Set accommodation_session
    126         self.app['configuration'].accommodation_session = 2004
     126        self.app['hostels'].accommodation_session = 2004
    127127
    128128        # Create a hostel
  • main/waeup.kofa/trunk/src/waeup/kofa/hostels/vocabularies.py

    r7819 r8685  
    3333    def acco_students(self, context):
    3434        catalog = getUtility(ICatalog, name='students_catalog')
    35         accommodation_session = getSite()['configuration'].accommodation_session
     35        accommodation_session = getSite()['hostels'].accommodation_session
    3636        students = catalog.searchResults(current_session=(
    3737            accommodation_session,accommodation_session))
  • main/waeup.kofa/trunk/src/waeup/kofa/interfaces.py

    r8638 r8685  
    516516        )
    517517
    518     accommodation_session = schema.Choice(
    519         title = _(u'Accommodation Booking Session'),
    520         source = academic_sessions_vocab,
    521         default = datetime.now().year,
    522         required = False,
    523         readonly = False,
    524         )
    525 
    526     accommodation_states = schema.List(
    527         title = _(u'Allowed States for Accommodation Booking'),
    528         value_type = schema.Choice(
    529             vocabulary = registration_states_vocab,
    530             ),
    531         default = [],
    532         )
    533 
    534518    name_admin = schema.TextLine(
    535519        title = _(u'Name of Administrator'),
  • main/waeup.kofa/trunk/src/waeup/kofa/students/browser.py

    r8642 r8685  
    10551055        if p_category == 'bed_allocation' and student[
    10561056            'studycourse'].current_session != grok.getSite()[
    1057             'configuration'].accommodation_session:
     1057            'hostels'].accommodation_session:
    10581058                self.flash(
    10591059                    _('Your current session does not match ' + \
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py

    r8642 r8685  
    172172
    173173        # Configure university
    174         self.app['configuration'].accommodation_states = ['admitted']
    175         self.app['configuration'].accommodation_session = 2004
     174        self.app['hostels'].accommodation_states = ['admitted']
     175        self.app['hostels'].accommodation_session = 2004
    176176        self.app['configuration'].carry_over = True
    177177        configuration = createObject('waeup.SessionConfiguration')
     
    16011601        self.browser.getControl(name="form.p_category").value = ['bed_allocation']
    16021602        # If student is not in accommodation session, payment cannot be processed
    1603         self.app['configuration'].accommodation_session = 2011
     1603        self.app['hostels'].accommodation_session = 2011
    16041604        self.browser.getControl("Create ticket").click()
    16051605        self.assertMatches('...Your current session does not match...',
    16061606                           self.browser.contents)
    1607         self.app['configuration'].accommodation_session = 2004
     1607        self.app['hostels'].accommodation_session = 2004
    16081608        self.browser.getControl("Add online payment ticket").click()
    16091609        self.browser.getControl(name="form.p_category").value = ['bed_allocation']
  • main/waeup.kofa/trunk/src/waeup/kofa/students/utils.py

    r8621 r8685  
    320320        d = {}
    321321        d['error'] = u''
    322         site_configuration = grok.getSite()['configuration']
    323         d['booking_session'] = site_configuration.accommodation_session
    324         d['allowed_states'] = site_configuration.accommodation_states
     322        hostels = grok.getSite()['hostels']
     323        d['booking_session'] = hostels.accommodation_session
     324        d['allowed_states'] = hostels.accommodation_states
    325325        # Determine bed type
    326326        studycourse = student['studycourse']
     
    331331            return
    332332        end_level = certificate.end_level
    333         if entry_session == grok.getSite()[
    334             'configuration'].accommodation_session:
     333        if entry_session == grok.getSite()['hostels'].accommodation_session:
    335334            bt = 'fr'
    336335        elif current_level >= end_level:
Note: See TracChangeset for help on using the changeset viewer.