source: WAeUP_SRP/trunk/skins/waeup_pins/enable_pins.py @ 16536

Last change on this file since 16536 was 3399, checked in by Henrik Bettermann, 17 years ago

logging message changed

  • Property svn:keywords set to Id
File size: 1.2 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 3399 2008-04-01 06:32:22Z henrik $
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
20redirect = request.RESPONSE.redirect
21wftool = context.portal_workflow
22mtool = context.portal_membership
23member = mtool.getAuthenticatedMember()
24#from Products.zdb import set_trace
25#set_trace()
26
27if not ids:
28    return
29
30pincat = context.portal_pins
31for pid in ids:
32    serial,prefix = pid.split("_")
33    res = pincat(prefix_batch=prefix,
34                 serial=int(serial))
35    if len(res) != 1:
36        continue
37    rec = res[0]
38    uid = rec.pin
39    student_id = rec.student
40    # if not rec.student.startswith('disabled'):
41    #     continue
42    dict = {"pin": uid,
43            "student": ""
44            }
45    pincat.modifyRecord(**dict)
46    logger.info('%s enabled pin %s (%s)' % (member,uid,student_id))
47return redirect("%s/campus/pins/search_pins?portal_status_message=PIN %s has been successfully (re-)enabled!" % (context.portal_url(),uid))
Note: See TracBrowser for help on using the repository browser.