Changeset 6452 for main/waeup.sirp


Ignore:
Timestamp:
22 Jun 2011, 13:51:55 (13 years ago)
Author:
Henrik Bettermann
Message:

Replace properties 'used' and 'disabled' by 'status'.

Location:
main/waeup.sirp/trunk/src/waeup/sirp
Files:
9 edited

Legend:

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

    r6450 r6452  
    5656
    5757    @property
    58     def disabled(self):
    59         return IWorkflowState(self).getState() == DISABLED
    60 
    61     @property
    62     def used(self):
    63         return IWorkflowState(self).getState() == USED
    64 
    65     @property
    6658    def history(self):
    6759        history = IObjectHistory(self)
     
    174166            )
    175167        writer = csv.writer(open(csv_path, 'w'), quoting=csv.QUOTE_ALL)
    176         writer.writerow(['prefix', 'serial', 'ac', 'used',
    177                          'disabled', 'history'])
     168        writer.writerow(['prefix', 'serial', 'ac', 'status', 'history'])
    178169        writer.writerow([self.prefix, '%0.2f' % self.cost, str(self.num),
    179170                         str(self.entry_num)])
     
    184175            writer.writerow([
    185176                    self.prefix, value.batch_serial, value.representation,
    186                     value.used and '1' or '0', value.disabled and '1' or '0',
    187                     value.history
     177                    value.status, value.history
    188178                    ])
    189179        return os.path.basename(csv_path)
     
    292282        return
    293283
    294     #def search(self, searchterm, searchtype):
    295     #    """Look for access-codes that comply with the given params.
    296     #    """
    297     #    results = []
    298     #    return results
    299 
    300284    def getAccessCode(self, ac_id):
    301285        """Get the AccessCode with ID ``ac_id`` or ``KeyError``.
     
    332316        reenable_accesscode(ac_id, user_id)
    333317        return
    334 
    335     #def invalidate(self, ac_id):
    336     #    """Invalidate the AC with ID ``ac_id``.
    337     #    """
    338     #    ac = self.getAccessCode(ac_id)
    339     #    if ac is None:
    340     #        return
    341     #    ac.__parent__.invalidate(ac_id)
    342     #    return
    343 
    344318
    345319class AccessCodePlugin(grok.GlobalUtility):
  • main/waeup.sirp/trunk/src/waeup/sirp/accesscodes/browser.txt

    r6450 r6452  
    306306    ...                             sorted(os.listdir(ac_storage))[-2])
    307307    >>> print open(archive_file, 'rb').read()
    308     "prefix","serial","ac","used","disabled","history"
     308    "prefix","serial","ac","status","history"
    309309    "BLA","19.12","1","3"
    310     "BLA","0","BLA-1-<10-DIGITS>","0","0","..."
    311     "BLA","1","BLA-1-<10-DIGITS>","0","0","..."
    312     "BLA","2","BLA-1-<10-DIGITS>","0","0","..."
     310    "BLA","0","BLA-1-<10-DIGITS>","initialized","..."
     311    "BLA","1","BLA-1-<10-DIGITS>","initialized","..."
     312    "BLA","2","BLA-1-<10-DIGITS>","initialized","..."
    313313
    314314Clean up:
  • main/waeup.sirp/trunk/src/waeup/sirp/accesscodes/browser_templates/reimportbatchpage.pt

    r5132 r6452  
    1 <h3>Reimport Access-Code Batches</h3>
     1<h3>Reimport Access Code Batches</h3>
    22<p>
    33  Please select the files to reimport. Please note, that batches with
  • main/waeup.sirp/trunk/src/waeup/sirp/accesscodes/catalog.py

    r6450 r6452  
    1717    code = grok.index.Field(attribute='representation')
    1818    history = grok.index.Text(attribute='history')
    19     disabled = grok.index.Field(attribute='disabled')
    20     used = grok.index.Field(attribute='used')
    2119    batch_serial = grok.index.Field(attribute='batch_serial')
    2220    status = grok.index.Field(attribute='status')
  • main/waeup.sirp/trunk/src/waeup/sirp/accesscodes/interfaces.py

    r6450 r6452  
    2626    status = schema.TextLine(
    2727        title = u'Workflow status',
    28         )
    29     disabled = schema.Bool(
    30         title = u'Access code is disabled',
    31         default = False,
    32         readonly = True,
    33         )
    34     used = schema.Bool(
    35         title = u'Access code is already in use.',
    36         default = False,
    37         readonly = True,
    3828        )
    3929    representation = schema.TextLine(
  • main/waeup.sirp/trunk/src/waeup/sirp/accesscodes/tests/test_accesscodes.py

    r6423 r6452  
    106106
    107107    def test_invalidate_accesscode(self):
    108         assert self.ac1.used is False
     108        assert self.ac1.status != USED
    109109        result = invalidate_accesscode('APP-1-11111111')
    110         assert self.ac1.used is True
     110        assert self.ac1.status == USED
    111111        assert result is True
    112112
    113113    def test_disable_accesscode_unused(self):
    114114        # we can disable initialized acs
    115         assert self.ac1.disabled is False
     115        assert self.ac1.status != USED
    116116        disable_accesscode('APP-1-11111111')
    117         assert self.ac1.disabled is True
     117        assert self.ac1.status == DISABLED
    118118
    119119    def test_disable_accesscode_used(self):
    120120        # we can disable already used acs
    121         assert self.ac1.disabled is False
     121        assert self.ac1.status != DISABLED
    122122        invalidate_accesscode('APP-1-11111111')
    123123        disable_accesscode('APP-1-11111111')
    124         assert self.ac1.disabled is True
     124        assert self.ac1.status == DISABLED
    125125
    126126    def test_reenable_accesscode(self):
     
    129129        result = reenable_accesscode('APP-1-11111111')
    130130        assert result is True
    131         assert self.ac1.disabled is False
     131        assert self.ac1.status != USED
    132132
    133133    def test_fire_transition(self):
  • main/waeup.sirp/trunk/src/waeup/sirp/accesscodes/tests/test_catalog.py

    r6438 r6452  
    110110        # Now we want to find the disabled access code
    111111        cat = queryUtility(ICatalog, name='accesscodes_catalog')
    112         results1 = cat.searchResults(disabled=(True, True))
    113         results2 = cat.searchResults(disabled=(False, False))
     112        results1 = cat.searchResults(status=('disabled', 'disabled'))
     113        results2 = cat.searchResults(status=('initialized', 'initialized'))
    114114        results1 = [x for x in results1] # Turn results generator into list
    115115        # We found 1 accescode disabled
     
    125125        # Now we want to find the invalidated access code
    126126        cat = queryUtility(ICatalog, name='accesscodes_catalog')
    127         results1 = cat.searchResults(used=(True, True))
    128         results2 = cat.searchResults(used=(False, False))
     127        results1 = cat.searchResults(status=('used', 'used'))
     128        results2 = cat.searchResults(status=('initialized', 'initialized'))
    129129        results1 = [x for x in results1] # Turn results generator into list
    130130        # We found 1 accescode used
     
    145145        # exactly one access code.
    146146        results = cat.searchResults(history='Tester',
    147                                     used=(True, True),
     147                                    status=('used', 'used'),
    148148                                    code=('APP-1-11111111', 'APP-1-22222222'))
    149149        assert len(results) == 1
     
    154154        # immediately in catalog
    155155        cat = queryUtility(ICatalog, name='accesscodes_catalog')
    156         result = cat.searchResults(used=(True, True))
     156        result = cat.searchResults(status=('used', 'used'))
    157157        assert len(result) == 0
    158158        invalidate_accesscode('APP-1-11111111')
    159         result = cat.searchResults(used=(True, True))
     159        result = cat.searchResults(status=('used', 'used'))
    160160        assert len(result) == 1
  • main/waeup.sirp/trunk/src/waeup/sirp/applicants/authentication.py

    r6411 r6452  
    228228        if ac is None:
    229229            return None
    230         if ac.disabled is not False:
    231             return None
    232         if ac.used is not False and appl_ac != ac.representation:
     230        if ac.status == 'disabled':
     231            return None
     232        if ac.status == 'used' and appl_ac != ac.representation:
    233233            return None
    234234        if appl_ac is not None and appl_ac != ac.representation:
  • main/waeup.sirp/trunk/src/waeup/sirp/applicants/tests/test_authentication.py

    r6412 r6452  
    5050
    5151class FakeAccessCode(object):
    52     def __init__(self, repr, inv_date=None, disabled=False):
    53         self.used = inv_date is not None
     52    def __init__(self, repr, status = 'initialized'):
    5453        self.representation = repr
    55         self.disabled = disabled
    56 
    57 class FakeInvAccessCode(object):
    58     invalidation_date = True
     54        self.status = status
    5955
    6056class FakeApplication(object):
     
    7167                'APP-44444': FakeApplication(),
    7268                'APP-55555': FakeApplication(u'APP-OTHER'),
    73                 },
    74             'JAMB': {
    75                 'JAMB1': FakeApplication(),
    76                 'JAMB2': FakeApplication(u'APP-12345'),
    77                 'JAMB3': FakeApplication(u'APP-54321'),
    78                 'JAMB4': FakeApplication(u'APP-44444'),
     69                'APP-77777': FakeApplication(u'APP-77777'),
    7970                },
    8071            },
     
    8273            'APP': FakeBatch({
    8374                    'APP-12345': FakeAccessCode('APP-12345'),
    84                     'APP-54321': FakeAccessCode('APP-54321', True),
     75                    'APP-54321': FakeAccessCode('APP-54321', 'used'),
    8576                    'APP-11111': FakeAccessCode('APP-11111'),
    8677                    'APP-22222': FakeAccessCode('APP-22222'),
    87                     'APP-33333': FakeAccessCode('APP-33333', True),
    88                     'APP-44444': FakeAccessCode('APP-44444', True),
    89                     'APP-55555': FakeAccessCode('APP-55555', True),
    90                     'APP-66666': FakeAccessCode('APP-66666', True, False),
    91                     'APP-77777': FakeAccessCode('APP-77777', False, False),
     78                    'APP-33333': FakeAccessCode('APP-33333', 'used'),
     79                    'APP-44444': FakeAccessCode('APP-44444', 'used'),
     80                    'APP-55555': FakeAccessCode('APP-55555', 'used'),
     81                    'APP-66666': FakeAccessCode('APP-66666', 'disabled'),
     82                    'APP-77777': FakeAccessCode('APP-77777', 'disabled'),
    9283                    })
    9384            }
     
    166157            dict(accesscode='APP-77777'))
    167158        assert result is None
     159
    168160        return
    169161
Note: See TracChangeset for help on using the changeset viewer.