[45] | 1 | from Globals import InitializeClass |
---|
| 2 | from AccessControl import ClassSecurityInfo |
---|
| 3 | |
---|
[47] | 4 | from Products.CMFCore.utils import UniqueObject, getToolByName |
---|
[45] | 5 | from Products.CMFCore.permissions import View |
---|
| 6 | from Products.CMFCore.permissions import ModifyPortalContent |
---|
| 7 | from Products.CPSCore.CPSBase import CPSBase_adder, CPSBaseFolder |
---|
[47] | 8 | #from Products.CPSCore.CPSBase import CPSBaseDocument as BaseDocument |
---|
| 9 | from Products.CPSDocument.CPSDocument import CPSDocument |
---|
[45] | 10 | from Products.CPSCore.CPSBase import CPSBaseBTreeFolder as BaseBTreeFolder |
---|
| 11 | |
---|
| 12 | # |
---|
| 13 | # The StudentsFolder |
---|
| 14 | # |
---|
| 15 | class StudentsFolder(BaseBTreeFolder): |
---|
| 16 | """ |
---|
| 17 | WAeUP container for the various WAeUP containers data |
---|
| 18 | """ |
---|
| 19 | meta_type = 'Students Folder' |
---|
| 20 | portal_type = meta_type |
---|
| 21 | security = ClassSecurityInfo() |
---|
| 22 | |
---|
[47] | 23 | security.declarePublic("doCheckAdmission") |
---|
| 24 | def doCheckAdmission(self,type_name,datamodel): |
---|
| 25 | "the admission callback" |
---|
| 26 | ## class CPSUnrestrictedUser(UnrestrictedUser): |
---|
| 27 | ## """Unrestricted user that still has an id. |
---|
| 28 | ## |
---|
| 29 | ## Taken from CPSMembershipTool |
---|
| 30 | ## """ |
---|
| 31 | ## |
---|
| 32 | ## def getId(self): |
---|
| 33 | ## """Return the ID of the user.""" |
---|
| 34 | ## return self.getUserName() |
---|
| 35 | print type_name |
---|
| 36 | print datamodel |
---|
| 37 | return self.REQUEST.RESPONSE.redirect("%s" % self.absolute_url()) |
---|
| 38 | mtool = getToolByName(self, 'portal_membership') |
---|
| 39 | username = "%s" % datamodel.get('reg_nr') |
---|
| 40 | print username |
---|
| 41 | member=mtool.getMemberById("S%s" % username) |
---|
| 42 | print member |
---|
| 43 | from AccessControl.SecurityManagement import newSecurityManager |
---|
| 44 | newSecurityManager(None,member.__of__(mtool.acl_users)) |
---|
| 45 | # datamodel is passed so that flexti can initialize the object. |
---|
| 46 | #datamodel.set('lastname','Meier') |
---|
| 47 | student = getattr(self,username) |
---|
| 48 | student.invokeFactory('StudentPersonal', '%s' % username) |
---|
| 49 | ob = getattr(student, id) |
---|
| 50 | ##context.notifyCPSDocumentCreation(ob=ob) |
---|
| 51 | return ob |
---|
| 52 | |
---|
[45] | 53 | InitializeClass(StudentsFolder) |
---|
| 54 | |
---|
| 55 | def addStudentsFolder(container, id, REQUEST=None, **kw): |
---|
| 56 | """Add a Student.""" |
---|
| 57 | ob = StudentsFolder(id, **kw) |
---|
| 58 | return CPSBase_adder(container, ob, REQUEST=REQUEST) |
---|
| 59 | ### |
---|
| 60 | ### The Student |
---|
| 61 | ### |
---|
[47] | 62 | ##class Student(CPSDocument): |
---|
[45] | 63 | ## """ |
---|
| 64 | ## WAeUP Student container for the various student data |
---|
| 65 | ## """ |
---|
[47] | 66 | #### meta_type = 'Student' |
---|
| 67 | #### portal_type = meta_type |
---|
[45] | 68 | ## security = ClassSecurityInfo() |
---|
| 69 | ## |
---|
[47] | 70 | ## security.declarePublic("test") |
---|
| 71 | ## def test(self): |
---|
| 72 | ## """test""" |
---|
| 73 | ## return self.REQUEST |
---|
| 74 | ## |
---|
[45] | 75 | ##InitializeClass(Student) |
---|
[47] | 76 | # |
---|
[45] | 77 | ##def addStudent(container, id, REQUEST=None, **kw): |
---|
| 78 | ## """Add a Student.""" |
---|
| 79 | ## ob = Student(id, **kw) |
---|
| 80 | ## return CPSBase_adder(container, ob, REQUEST=REQUEST) |
---|