Ignore:
Timestamp:
01/28/11 15:57:45 (2 years ago)
Author:
Jose Benito <jose.benito.gonzalez@…>
Branches:
master, burotel, hello-world-walkthrough, ipv6, v0.97-series, v0.98-series, v0.98.2, v0.98.3, v0.98b1, v0.98b2, v0.99, 051b2622c51afb171a1dedb46a0df4fbb0cbd02e, 4c7d4152dff271ba5df5a8606605969cab454080
Children:
97539e
Parents:
c50671
git-author:
Adrian Moennich <jerome.ernst.monnich@…> (01/28/11 15:20:03)
git-committer:
Jose Benito <jose.benito.gonzalez@…> (01/28/11 15:57:45)
Message:

[FIX] Disable billable fields after payment

File:
1 edited

Legend:

Unmodified
Added
Removed
  • indico/MaKaC/webinterface/rh/registrantsModif.py

    r9cd2c8 r2e8d57  
    570570    def _process( self ): 
    571571        if not self._cancel: 
    572             self._registrant.setSessions(self._sessions) 
     572            if not self._registrant.getPayed(): 
     573                sessions = self._sessions 
     574            else: 
     575                # First keep all sessions which are billable (they are not submitted anymore) 
     576                sessions = [session for session in self._registrant.getSessionList() if session.isBillable()] 
     577                # Then take all chosen sessions which are not billable 
     578                sessions += [session for session in self._sessions if not session.isBillable()] 
     579            self._registrant.setSessions(sessions) 
    573580        self._redirect(urlHandlers.UHRegistrantModification.getURL(self._registrant)) 
    574581 
     
    606613    def _process( self ): 
    607614        if not self._cancel: 
    608             self._registrant.getAccommodation().setArrivalDate(self._arrivalDate) 
    609             self._registrant.getAccommodation().setDepartureDate(self._departureDate) 
     615            # Allow changing of the dates only if the current accomodation is not billable or the user hasn't paid yet 
     616            currentAccoType = self._registrant.getAccommodation().getAccommodationType() 
     617            if not self._registrant.getPayed() or currentAccoType is None or not currentAccoType.isBillable(): 
     618                self._registrant.getAccommodation().setArrivalDate(self._arrivalDate) 
     619                self._registrant.getAccommodation().setDepartureDate(self._departureDate) 
    610620            if self._regForm.getAccommodationForm().getAccommodationTypesList() !=[]: 
    611                 self._registrant.getAccommodation().setAccommodationType(self._accoType) 
     621                # Only change the accommodation type if: 
     622                # - the registrant hasn't paid yet OR 
     623                # - neither the current nor the new accommodation is billable 
     624                if not self._registrant.getPayed() or \ 
     625                    ((currentAccoType is None or not currentAccoType.isBillable()) and \ 
     626                     (self._accoType is None or not self._accoType.isBillable())): 
     627                    self._registrant.getAccommodation().setAccommodationType(self._accoType) 
    612628        self._redirect(urlHandlers.UHRegistrantModification.getURL(self._registrant)) 
    613629 
     
    642658        if not self._cancel: 
    643659            for seItem in self._registrant.getSocialEvents()[:]: 
    644                 self._registrant.removeSocialEventById(seItem.getId()) 
     660                # Remove all items which can be added back (i.e. if paid only non-billable ones) 
     661                if not (self._registrant.getPayed() and seItem.isBillable()): 
     662                    self._registrant.removeSocialEventById(seItem.getId()) 
    645663 
    646664            l = [] 
    647665            for seItem in self._socialEvents: 
    648                 newSE = SocialEvent(seItem, int(self._places[seItem.getId()])) 
    649                 self._registrant.addSocialEvent(newSE) 
     666                # Only add item if the registrant hasn't paid yet or the item is not billable 
     667                if not self._registrant.getPayed() or not seItem.isBillable(): 
     668                    newSE = SocialEvent(seItem, int(self._places[seItem.getId()])) 
     669                    self._registrant.addSocialEvent(newSE) 
    650670        self._redirect(urlHandlers.UHRegistrantModification.getURL(self._registrant)) 
    651671 
Note: See TracChangeset for help on using the changeset viewer.