[1877] | 1 | #-*- mode: python; mode: fold -*- |
---|
| 2 | # (C) Copyright 2005 The WAeUP group <http://www.waeup.org> |
---|
| 3 | # Author: Joachim Schmitz (js@aixtraware.de) |
---|
| 4 | # |
---|
| 5 | # This program is free software; you can redistribute it and/or modify |
---|
| 6 | # it under the terms of the GNU General Public License version 2 as published |
---|
| 7 | # by the Free Software Foundation. |
---|
| 8 | # |
---|
| 9 | # This program is distributed in the hope that it will be useful, |
---|
| 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 12 | # GNU General Public License for more details. |
---|
| 13 | # |
---|
| 14 | # You should have received a copy of the GNU General Public License |
---|
| 15 | # along with this program; if not, write to the Free Software |
---|
| 16 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
---|
| 17 | # 02111-1307, USA. |
---|
| 18 | # |
---|
| 19 | # $Id: SetupDemoDB.py 1877 2007-06-11 12:36:10Z joachim $ |
---|
| 20 | """ |
---|
| 21 | remove Data from live db to make a demodb |
---|
| 22 | """ |
---|
| 23 | import random |
---|
| 24 | |
---|
| 25 | def removeStudents(self): |
---|
| 26 | "remove nearly all students to form a lightweight demodb" |
---|
| 27 | context = self.uniben |
---|
| 28 | wftool = context.portal_workflow |
---|
| 29 | mtool = context.portal_membership |
---|
| 30 | member = mtool.getAuthenticatedMember() |
---|
| 31 | roles = member.getRolesInContext(context) |
---|
| 32 | stdir = context.portal_directories.students |
---|
| 33 | students_catalog = context.students_catalog |
---|
| 34 | all = students_catalog() |
---|
| 35 | sample = random.sample(all,len(all) - 1000) |
---|
| 36 | #import pdb;pdb.set_trace() |
---|
| 37 | for s in sample: |
---|
| 38 | if s.matric_no: |
---|
| 39 | context.deleteStudentByMatricNo(s.matric_no) |
---|
| 40 | elif s.jamb_reg_no: |
---|
| 41 | context.deleteStudentByRegNo(s.jamb_reg_no) |
---|