source: WAeUP_SRP/base/skins/waeup_pins/enable_pins.py @ 3387

Last change on this file since 3387 was 3385, checked in by joachim, 17 years ago

fix for #516 enable now works without disabling first.
pins can now be entered with - and leading or trailing spaces
for search.

  • Property svn:keywords set to Id
File size: 1.1 KB
Line 
1## Script (Python) "enable_pins"
2##bind container=container
3##bind context=context
4##bind namespace=
5##bind script=script
6##bind subpath=traverse_subpath
7##parameters=REQUEST,ids=[]
8##title=
9##
10# $Id: enable_pins.py 3385 2008-03-27 14:03:10Z joachim $
11"""
12enable pins
13"""
14import DateTime
15current = DateTime.DateTime().strftime("%d-%m-%y_%H_%M_%S")
16import logging
17logger = logging.getLogger('Skins.enable_pins')
18
19request = REQUEST
20wftool = context.portal_workflow
21mtool = context.portal_membership
22member = mtool.getAuthenticatedMember()
23#from Products.zdb import set_trace
24#set_trace()
25
26if not ids:
27    return
28
29pincat = context.portal_pins
30for pid in ids:
31    serial,prefix = pid.split("_")
32    res = pincat(prefix_batch=prefix,
33                 serial=int(serial))
34    if len(res) != 1:
35        continue
36    rec = res[0]
37    uid = rec.pin
38    student_id = rec.student
39    # if not rec.student.startswith('disabled'):
40    #     continue
41    dict = {"pin": uid,
42            "student": ""
43            }
44    pincat.modifyRecord(**dict)
45    logger.info('%s enabled pin %s for student %s' % (member,uid,student_id))
46return request.RESPONSE.redirect("%s/campus/pins/search_pins" % context.portal_url())
Note: See TracBrowser for help on using the repository browser.