Ignore:
Timestamp:
20 Jun 2011, 16:04:14 (13 years ago)
Author:
uli
Message:

Support batch-local counters for used/disabled pins. This time we only set a simple attribute and remove the enable(), disable(), ... methods that have no purpose any more.

Location:
main/waeup.sirp/trunk/src/waeup/sirp/accesscodes
Files:
4 edited

Legend:

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

    r6424 r6425  
    8181        self.num = num
    8282        self.invalidated_num = 0
     83        self.used_num = 0
    8384        self.disabled_num = 0
    8485
     
    134135        return
    135136
    136     def invalidate(self, ac_id, student_id=None):
    137         """Invalidate the AC with ID ``ac_id``.
    138         """
    139         self.invalidated_num += 1
    140 
    141     def disable(self, ac_id, user_id=None):
    142         """Disable the AC with ID ``ac_id``.
    143 
    144         ``user_id`` is the user ID of the user triggering the
    145         process. Already disabled ACs are left untouched.
    146         """
    147         num = self._acids[ac_id]
    148         ac = self.getAccessCode(ac_id)
    149         if ac._disabled == True:
    150             return
    151         self.disabled_num += 1
    152 
    153     def enable(self, ac_id):
    154         """(Re-)enable the AC with ID ``ac_id``.
    155 
    156         This leaves the given AC in state ``unused``. Already enabled
    157         ACs are left untouched.
    158         """
     137    #def invalidate(self, ac_id, student_id=None):
     138    #    """Invalidate the AC with ID ``ac_id``.
     139    #    """
     140    #    self.invalidated_num += 1
     141
     142    #def disable(self, ac_id, user_id=None):
     143    #    """Disable the AC with ID ``ac_id``.
     144    #
     145    #    ``user_id`` is the user ID of the user triggering the
     146    #    process. Already disabled ACs are left untouched.
     147    #    """
     148    #    num = self._acids[ac_id]
     149    #    ac = self.getAccessCode(ac_id)
     150    #    if ac._disabled == True:
     151    #        return
     152    #    self.disabled_num += 1
     153
     154    #def enable(self, ac_id):
     155    #    """(Re-)enable the AC with ID ``ac_id``.
     156    #
     157    #    This leaves the given AC in state ``unused``. Already enabled
     158    #    ACs are left untouched.
     159    #    """
    159160
    160161    def createCSVLogFile(self):
  • main/waeup.sirp/trunk/src/waeup/sirp/accesscodes/browser.txt

    r6417 r6425  
    140140    >>> browser.getControl('Create batch').click()
    141141
    142 We also invalidate one entry:
    143 
    144     >>> batch = getRootFolder()['myuniversity']['accesscodes']['BLA-1']
    145     >>> ac = list(batch.entries())[0]
    146     >>> batch.invalidate(ac.representation)
    147142
    148143Creating Archive Files
  • main/waeup.sirp/trunk/src/waeup/sirp/accesscodes/interfaces.py

    r6423 r6425  
    6767        default = 0.0, min = 0.0,
    6868        )
     69    disabled_num = schema.Int(
     70        title = u'Number of disabled access codes inside the batch',
     71        default = 0,
     72        readonly = True,
     73        )
     74    used_num = schema.Int(
     75        title = u'Number of used access codes inside the batch',
     76        default = 0,
     77        readonly = True,
     78        )
    6979
    7080class IAccessCodeBatchContainer(IWAeUPObject):
  • main/waeup.sirp/trunk/src/waeup/sirp/accesscodes/workflow.py

    r6421 r6425  
    3939    if batch is None:
    4040        return
    41     pin = context.representation
    42     batch.invalidate(pin)
     41    batch.used_num += 1
    4342    return
    4443
    45 def disable_action(wf, context):
    46     #batch = getattr(context, '__parent__', None)
    47     #if batch is None:
    48     #    return
    49     #pin = context.representation
    50     #batch.disable(pin)
     44def disable_used_action(wf, context):
     45    batch = getattr(context, '__parent__', None)
     46    if batch is None:
     47        return
     48    batch.used_num -= 1
     49    batch.disabled_num += 1
     50
     51def disable_unused_action(wf, context):
     52    batch = getattr(context, '__parent__', None)
     53    if batch is None:
     54        return
     55    batch.disabled_num += 1
    5156    return
    5257
     
    5560    if batch is None:
    5661        return
    57     pin = context.representation
    58     batch.enable(pin)
     62    batch.disabled_num -= 1
    5963    return
    6064
     
    7983        source = INITIALIZED,
    8084        destination = DISABLED,
    81         action = disable_action),
     85        action = disable_unused_action),
    8286
    8387    Transition(
     
    8690        source = USED,
    8791        destination = DISABLED,
    88         action = disable_action),
     92        action = disable_used_action),
    8993
    9094    Transition(
Note: See TracChangeset for help on using the changeset viewer.