Changeset 6403 for main


Ignore:
Timestamp:
18 Jun 2011, 06:03:36 (13 years ago)
Author:
Henrik Bettermann
Message:

Comment out the code which refers to iold invalidation and disabling methods. Make all tests work again.

Location:
main/waeup.sirp/branches/accesscodes-with-workflow/src/waeup/sirp
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.sirp/branches/accesscodes-with-workflow/src/waeup/sirp/accesscodes/accesscodes.py

    r6387 r6403  
    6666        self.entry_num = entry_num
    6767        self.num = num
    68         self.invalidated_num = 0
    69         self.disabled_num = 0
     68        #self.invalidated_num = 0
     69        #self.disabled_num = 0
    7070        self._entries = list()
    7171        self._acids = OIBTree()
     
    124124        return
    125125
    126     def invalidate(self, ac_id, student_id=None):
    127         """Invalidate the AC with ID ``ac_id``.
    128         """
    129         num = self._acids[ac_id]
    130         self.invalidated_num += 1
    131 
    132     def disable(self, ac_id, user_id=None):
    133         """Disable the AC with ID ``ac_id``.
    134 
    135         ``user_id`` is the user ID of the user triggering the
    136         process. Already disabled ACs are left untouched.
    137         """
    138         num = self._acids[ac_id]
    139         ac = self.getAccessCode(ac_id)
    140         if ac._disabled == True:
    141             return
    142         self.disabled_num += 1
    143 
    144     def enable(self, ac_id):
    145         """(Re-)enable the AC with ID ``ac_id``.
    146 
    147         This leaves the given AC in state ``unused``. Already enabled
    148         ACs are left untouched.
    149         """
    150         num = self._acids[ac_id]
    151         self.disabled_num -= 1
     126    #def invalidate(self, ac_id, student_id=None):
     127    #    """Invalidate the AC with ID ``ac_id``.
     128    #    """
     129    #    num = self._acids[ac_id]
     130    #    self.invalidated_num += 1
     131
     132    #def disable(self, ac_id, user_id=None):
     133    #    """Disable the AC with ID ``ac_id``.
     134
     135    #    ``user_id`` is the user ID of the user triggering the
     136    #    process. Already disabled ACs are left untouched.
     137    #    """
     138    #    num = self._acids[ac_id]
     139    #    ac = self.getAccessCode(ac_id)
     140    #    if ac._disabled == True:
     141    #        return
     142    #    self.disabled_num += 1
     143
     144    #def enable(self, ac_id):
     145    #    """(Re-)enable the AC with ID ``ac_id``.
     146
     147    #    This leaves the given AC in state ``unused``. Already enabled
     148    #    ACs are left untouched.
     149    #    """
     150    #    num = self._acids[ac_id]
     151    #    self.disabled_num -= 1
    152152
    153153    def createCSVLogFile(self):
     
    314314        return None
    315315
    316     def disable(self, ac_id, user_id):
    317         """Disable the AC with ID ``ac_id``.
    318 
    319         ``user_id`` is the user ID of the user triggering the
    320         process. Already disabled ACs are left untouched.
    321         """
    322         ac = self.getAccessCode(ac_id)
    323         if ac is None:
    324             return
    325         ac.__parent__.disable(ac_id, user_id)
    326         return
    327 
    328     def enable(self, ac_id):
    329         """(Re-)enable the AC with ID ``ac_id``.
    330 
    331         This leaves the given AC in state ``unused``. Already enabled
    332         ACs are left untouched.
    333         """
    334         ac = self.getAccessCode(ac_id)
    335         if ac is None:
    336             return
    337         ac.__parent__.enable(ac_id)
    338         return
    339 
    340     def invalidate(self, ac_id):
    341         """Invalidate the AC with ID ``ac_id``.
    342         """
    343         ac = self.getAccessCode(ac_id)
    344         if ac is None:
    345             return
    346         ac.__parent__.invalidate(ac_id)
    347         return
     316    #def disable(self, ac_id, user_id):
     317    #    """Disable the AC with ID ``ac_id``.
     318
     319    #    ``user_id`` is the user ID of the user triggering the
     320    #    process. Already disabled ACs are left untouched.
     321    #    """
     322    #    ac = self.getAccessCode(ac_id)
     323    #    if ac is None:
     324    #        return
     325    #    ac.__parent__.disable(ac_id, user_id)
     326    #    return
     327
     328    #def enable(self, ac_id):
     329    #    """(Re-)enable the AC with ID ``ac_id``.
     330
     331    #    This leaves the given AC in state ``unused``. Already enabled
     332    #    ACs are left untouched.
     333    #    """
     334    #    ac = self.getAccessCode(ac_id)
     335    #    if ac is None:
     336    #        return
     337    #    ac.__parent__.enable(ac_id)
     338    #    return
     339
     340    #def invalidate(self, ac_id):
     341    #    """Invalidate the AC with ID ``ac_id``.
     342    #    """
     343    #    ac = self.getAccessCode(ac_id)
     344    #    if ac is None:
     345    #        return
     346    #    ac.__parent__.invalidate(ac_id)
     347    #    return
    348348
    349349
  • main/waeup.sirp/branches/accesscodes-with-workflow/src/waeup/sirp/accesscodes/browser.py

    r6388 r6403  
    121121            self.searchresults = []
    122122            for result in searchresults:
    123                 status = u'unused'
    124                 if result.disabled is True:
    125                     status = u'disabled by %s on %s' % (
    126                         result.student_id,
    127                         result.invalidation_date.strftime('%c')
    128                         )
    129                 elif result.invalidation_date is not None:
    130                     status = u'invalidated by %s on %s' % (
    131                         result.student_id,
    132                         result.invalidation_date.strftime('%c')
    133                         )
     123                #status = u'unused'
     124                #if result.disabled is True:
     125                #    status = u'disabled by %s on %s' % (
     126                #        result.student_id,
     127                #        result.invalidation_date.strftime('%c')
     128                #        )
     129                #elif result.invalidation_date is not None:
     130                #    status = u'invalidated by %s on %s' % (
     131                #        result.student_id,
     132                #        result.invalidation_date.strftime('%c')
     133                #        )
    134134                entry = dict(
    135135                    serial = result.batch_serial,
    136                     code = result.representation,
    137                     status = status)
     136                    code = result.representation)
     137                    #status = status)
    138138                self.searchresults.append(entry)
    139139        if entries is None:
     
    141141        if isinstance(entries, basestring):
    142142            entries = [entries]
    143         for entry in entries:
    144             if disable is not None:
    145                 self.context.disable(entry, self.request.principal.id)
    146                 self.flash('disabled %s' % entry)
    147             elif enable is not None:
    148                 self.context.enable(entry)
    149                 self.flash('(re-)enabled %s' % entry)
     143        #for entry in entries:
     144        #    if disable is not None:
     145        #        self.context.disable(entry, self.request.principal.id)
     146        #        self.flash('disabled %s' % entry)
     147        #    elif enable is not None:
     148        #        self.context.enable(entry)
     149        #        self.flash('(re-)enabled %s' % entry)
    150150        return
    151151
  • main/waeup.sirp/branches/accesscodes-with-workflow/src/waeup/sirp/accesscodes/browser.txt

    r5423 r6403  
    112112    ...
    113113    ...5
    114     .../
    115     ...0
    116114    ...
    117115    ...12.12...
     
    139137    >>> browser.getControl(name='form.cost').value = '19.12'
    140138    >>> browser.getControl('Create batch').click()
    141 
    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)
    147139
    148140Creating Archive Files
     
    311303    ...                             sorted(os.listdir(ac_storage))[-2])
    312304    >>> print open(archive_file, 'rb').read()
    313     "prefix","serial","ac","student","date"
     305    "prefix","serial","ac","date"
    314306    "BLA","19.12","1","3"
    315     "BLA","0","BLA-1-<10-DIGITS>","","..."
    316     "BLA","1","BLA-1-<10-DIGITS>","",""
    317     "BLA","2","BLA-1-<10-DIGITS>","",""
     307    "BLA","0","BLA-1-<10-DIGITS>"
     308    "BLA","1","BLA-1-<10-DIGITS>"
     309    "BLA","2","BLA-1-<10-DIGITS>"
    318310
    319311Clean up:
  • main/waeup.sirp/branches/accesscodes-with-workflow/src/waeup/sirp/accesscodes/browser_templates/batchcontainer.pt

    r5931 r6403  
    1010      <tr>
    1111        <th>&nbsp;</th>
    12         <th>Prefix</th><th>Entries/(invalidated)</th><th>Cost</th>
     12        <th>Prefix</th><th>Entries</th><th>Cost</th>
    1313        <th>Created</th><th>Creator</th>
    1414      </tr>
     
    2828        <td>
    2929          <span tal:replace="batch/entry_num">1012</span>
    30           /
    31           <span tal:replace="batch/invalidated_num">512</span>
    3230        </td>
    3331        <td tal:content="batch/cost">12.12</td>
  • main/waeup.sirp/branches/accesscodes-with-workflow/src/waeup/sirp/accesscodes/browser_templates/searchpage.pt

    r5918 r6403  
    2020  <div tal:condition="view/searchresults">
    2121    <h3>Search Results</h3>
    22     <table>
     22    <table class = "zebra">
    2323      <thead>
    2424        <tr>
     
    2828      </thead>
    2929      <tbody>
    30         <tr tal:repeat="item view/searchresults"
    31             tal:attributes="class python: repeat['item'].odd() and 'even' or 'odd'">
     30        <tr tal:repeat="item view/searchresults">
    3231          <td><input type="checkbox" name="entries"
    3332                     tal:attributes="value item/code" /></td>
    3433          <td tal:content="item/serial">1</td>
    3534          <td tal:content="item/code">APP-1-1234567890</td>
    36           <td tal:content="item/status">unused</td>
    3735        </tr>
    3836      </tbody>
  • main/waeup.sirp/branches/accesscodes-with-workflow/src/waeup/sirp/accesscodes/interfaces.py

    r5098 r6403  
    1212        )
    1313    batch_prefix = schema.TextLine(
    14         title = u'Prefix inside batch',
     14        title = u'Batch prefix',
    1515        )
    1616    batch_num = schema.Int(
     
    2424        default = 0.0, min = 0.0,
    2525        )
    26     invalidation_date = schema.Datetime(
    27         title = u'Datetime of invalidation',
    28         required = False,
    29         default = None,
    30         )
    31     student_id = schema.TextLine(
    32         title = u'Student ID or registration number',
    33         required = False,
    34         default = None,
    35         )
     26    #invalidation_date = schema.Datetime(
     27    #    title = u'Datetime of invalidation',
     28    #    required = False,
     29    #    default = None,
     30    #    )
     31    #student_id = schema.TextLine(
     32    #    title = u'Student ID or registration number',
     33    #    required = False,
     34    #    default = None,
     35    #    )
    3636    representation = schema.TextLine(
    3737        title = u'Complete title of access code',
  • main/waeup.sirp/branches/accesscodes-with-workflow/src/waeup/sirp/accesscodes/workflow.py

    r6359 r6403  
    3535DISABLED = 'disabled'
    3636
    37 def invalidate_action(wf, context):
    38     batch = getattr(context, '__parent__', None)
    39     if batch is None:
    40         return
    41     pin = context.representation
    42     batch.invalidate(pin)
    43     return
     37#def invalidate_action(wf, context):
     38#    batch = getattr(context, '__parent__', None)
     39#    if batch is None:
     40#        return
     41#    pin = context.representation
     42#    batch.invalidate(pin)
     43#    return
    4444
    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)
    51     return
     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)
     51#    return
    5252
    53 def reenable_action(wf, context):
    54     batch = getattr(context, '__parent__', None)
    55     if batch is None:
    56         return
    57     pin = context.representation
    58     batch.enable(pin)
    59     return
     53#def reenable_action(wf, context):
     54#    batch = getattr(context, '__parent__', None)
     55#    if batch is None:
     56#        return
     57#    pin = context.representation
     58#    batch.enable(pin)
     59#    return
    6060
    6161ACCESSCODE_TRANSITIONS = (
     
    7171        title = 'Use PIN',
    7272        source = INITIALIZED,
    73         destination = USED,
    74         action = invalidate_action),
     73        destination = USED),
     74        #action = invalidate_action),
    7575
    7676    Transition(
     
    7878        title = 'Disable unused PIN',
    7979        source = INITIALIZED,
    80         destination = DISABLED,
    81         action = disable_action),
     80        destination = DISABLED),
     81        #action = disable_action),
    8282
    8383    Transition(
     
    8585        title = 'Disable used PIN',
    8686        source = USED,
    87         destination = DISABLED,
    88         action = disable_action),
     87        destination = DISABLED),
     88        #action = disable_action),
    8989
    9090    Transition(
     
    9292        title = 'Reenable disabled PIN',
    9393        source = DISABLED,
    94         destination = INITIALIZED,
    95         action = reenable_action),
     94        destination = INITIALIZED),
     95        #action = reenable_action),
    9696    )
    9797
  • main/waeup.sirp/branches/accesscodes-with-workflow/src/waeup/sirp/applicants/browser.py

    r6397 r6403  
    562562            code = course_admitted.code
    563563            return '<a href="%s">%s - %s</a>' %(url,code,title)
    564         return 'not yet admitted'
     564        return ''
    565565
    566566class PDFActionButton(ManageActionButton):
  • main/waeup.sirp/branches/accesscodes-with-workflow/src/waeup/sirp/applicants/tests/test_authentication.py

    r6179 r6403  
    5151class FakeAccessCode(object):
    5252    def __init__(self, repr, inv_date=None, disabled=False):
    53         self.invalidation_date = inv_date
     53        #self.invalidation_date = inv_date
    5454        self.representation = repr
    55         self.disabled = disabled
     55        #self.disabled = disabled
    5656
    5757class FakeInvAccessCode(object):
     
    8282            'APP': FakeBatch({
    8383                    'APP-12345': FakeAccessCode('APP-12345'),
    84                     'APP-54321': FakeAccessCode('APP-54321', True),
     84                    #'APP-54321': FakeAccessCode('APP-54321', True),
    8585                    'APP-11111': FakeAccessCode('APP-11111'),
    8686                    '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),
     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),
    9292                    })
    9393            }
     
    151151        # Possible cases, where formal correct authentication
    152152        # data is not valid:
    153         result = self.plugin.authenticateCredentials(
    154             dict(accesscode='APP-33333'))
    155         assert result is None
    156 
    157         result = self.plugin.authenticateCredentials(
    158             dict(accesscode='APP-55555'))
    159         assert result is None
    160 
    161         result = self.plugin.authenticateCredentials(
    162             dict(accesscode='APP-66666'))
    163         assert result is None
    164 
    165         result = self.plugin.authenticateCredentials(
    166             dict(accesscode='APP-77777'))
    167         assert result is None
    168         return
     153        #result = self.plugin.authenticateCredentials(
     154        #    dict(accesscode='APP-33333'))
     155        #assert result is None
     156
     157        #esult = self.plugin.authenticateCredentials(
     158        #   dict(accesscode='APP-55555'))
     159        #assert result is None
     160
     161        #result = self.plugin.authenticateCredentials(
     162        #    dict(accesscode='APP-66666'))
     163        #assert result is None
     164
     165        #result = self.plugin.authenticateCredentials(
     166        #    dict(accesscode='APP-77777'))
     167        #assert result is None
     168        #return
    169169
    170170    def test_valid_credentials(self):
     
    181181        assert result is not None
    182182
    183         result = self.plugin.authenticateCredentials(
    184             dict(accesscode='APP-54321'))
    185         assert result is not None
     183        #result = self.plugin.authenticateCredentials(
     184        #    dict(accesscode='APP-54321'))
     185        #assert result is not None
    186186
    187187        # check the `principalInfo` method of authenticator
Note: See TracChangeset for help on using the changeset viewer.