source: WAeUP_SRP/trunk/skins/waeup_pins/disable_pins.py @ 4049

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

show psm

  • Property svn:keywords set to Id
File size: 1.2 KB
Line 
1## Script (Python) "disable_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: disable_pins.py 3398 2008-04-01 06:28:21Z henrik $
11"""
12disable pins
13"""
14import DateTime
15current = DateTime.DateTime().strftime("%d-%m-%y_%H_%M_%S")
16import logging
17logger = logging.getLogger('Skins.disable_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    uid = res[0].pin
38    student_id = res[0].student
39    dict = {"pin": uid,
40            "student": "disabled by %s on %s" % (member,current)
41            }
42    pincat.modifyRecord(**dict)
43    logger.info('%s disabled pin %s (%s)' % (member,uid,student_id))
44return redirect("%s/campus/pins/search_pins?portal_status_message=PIN %s has been successfully disabled!" % (context.portal_url(),uid))
Note: See TracBrowser for help on using the repository browser.