1 | #-*- mode: python; mode: fold -*- |
---|
2 | from Globals import InitializeClass |
---|
3 | from AccessControl import ClassSecurityInfo |
---|
4 | |
---|
5 | from Products.CMFCore.utils import UniqueObject, getToolByName |
---|
6 | from Products.CMFCore.permissions import View |
---|
7 | from Products.CMFCore.permissions import ModifyPortalContent |
---|
8 | from Products.CPSCore.CPSBase import CPSBase_adder, CPSBaseFolder |
---|
9 | #from Products.CPSCore.CPSBase import CPSBaseDocument as BaseDocument |
---|
10 | from Products.CPSDocument.CPSDocument import CPSDocument |
---|
11 | from Products.CPSCore.CPSBase import CPSBaseBTreeFolder as BaseBTreeFolder |
---|
12 | |
---|
13 | class StudentsFolder(BaseBTreeFolder): ###( |
---|
14 | """ |
---|
15 | WAeUP container for the various WAeUP containers data |
---|
16 | """ |
---|
17 | meta_type = 'Students Folder' |
---|
18 | portal_type = meta_type |
---|
19 | security = ClassSecurityInfo() |
---|
20 | |
---|
21 | security.declarePublic("doCheckAdmission") |
---|
22 | def doCheckAdmission(self,type_name,datamodel): |
---|
23 | "the admission callback" |
---|
24 | ## class CPSUnrestrictedUser(UnrestrictedUser): |
---|
25 | ## """Unrestricted user that still has an id. |
---|
26 | ## |
---|
27 | ## Taken from CPSMembershipTool |
---|
28 | ## """ |
---|
29 | ## |
---|
30 | ## def getId(self): |
---|
31 | ## """Return the ID of the user.""" |
---|
32 | ## return self.getUserName() |
---|
33 | print type_name |
---|
34 | print datamodel |
---|
35 | return self.REQUEST.RESPONSE.redirect("%s" % self.absolute_url()) |
---|
36 | mtool = getToolByName(self, 'portal_membership') |
---|
37 | username = "%s" % datamodel.get('reg_nr') |
---|
38 | print username |
---|
39 | member=mtool.getMemberById("S%s" % username) |
---|
40 | print member |
---|
41 | from AccessControl.SecurityManagement import newSecurityManager |
---|
42 | newSecurityManager(None,member.__of__(mtool.acl_users)) |
---|
43 | # datamodel is passed so that flexti can initialize the object. |
---|
44 | #datamodel.set('lastname','Meier') |
---|
45 | student = getattr(self,username) |
---|
46 | student.invokeFactory('StudentPersonal', '%s' % username) |
---|
47 | ob = getattr(student, id) |
---|
48 | ##context.notifyCPSDocumentCreation(ob=ob) |
---|
49 | return ob |
---|
50 | |
---|
51 | InitializeClass(StudentsFolder) |
---|
52 | |
---|
53 | def addStudentsFolder(container, id, REQUEST=None, **kw): |
---|
54 | """Add a Student.""" |
---|
55 | ob = StudentsFolder(id, **kw) |
---|
56 | return CPSBase_adder(container, ob, REQUEST=REQUEST) |
---|
57 | ### |
---|
58 | ###) |
---|
59 | |
---|
60 | |
---|
61 | student_fti = { ###( |
---|
62 | 'title': 'WAeUP Student', |
---|
63 | 'description': '', |
---|
64 | 'content_icon': 'student.gif', |
---|
65 | 'content_meta_type': 'Student', |
---|
66 | 'factory': 'addStudent', |
---|
67 | 'immediate_view': 'cpsdocument_view', |
---|
68 | 'global_allow': True, |
---|
69 | 'filter_content_types': True, |
---|
70 | 'allowed_content_types': ('Jamb','StudentPersonal'), |
---|
71 | 'allow_discussion': False, |
---|
72 | 'actions': ( |
---|
73 | {'id': 'view', |
---|
74 | 'name': 'action_view', |
---|
75 | 'action': 'string:${object_url}/student_index_html', |
---|
76 | #'action': 'string:${object_url}/cpsdocument_view', |
---|
77 | 'condition': '', |
---|
78 | 'permission': ('View',), |
---|
79 | 'category': 'object', |
---|
80 | 'visible': True,}, |
---|
81 | {'id': 'new_content', |
---|
82 | 'name': 'Add Data', |
---|
83 | 'action': 'string:${object_url}/folder_factories', |
---|
84 | 'condition': "python:1 or len(object.contentItems()) == 0 ", |
---|
85 | 'permission': ('Modify portal content',), |
---|
86 | 'category': 'object', |
---|
87 | 'visible': True,}, |
---|
88 | {'id': 'contents', |
---|
89 | 'name': 'action_folder_contents', |
---|
90 | 'action': 'string:${object_url}/folder_contents', |
---|
91 | 'condition': "python:1 or object.getTypeInfo().cps_proxy_type != 'document'", |
---|
92 | 'permission': ('Modify portal content',), |
---|
93 | 'category': 'object', |
---|
94 | 'visible': True,}, |
---|
95 | {'id': 'edit', |
---|
96 | 'name': 'action_edit', |
---|
97 | 'action': 'string:${object_url}/cpsdocument_edit_form', |
---|
98 | 'condition': '', |
---|
99 | 'permission': ('Modify portal content',), |
---|
100 | 'category': 'object', |
---|
101 | 'visible': True,}, |
---|
102 | ) |
---|
103 | } |
---|
104 | |
---|
105 | ###) |
---|
106 | |
---|
107 | class Student(CPSDocument): ###( |
---|
108 | """ |
---|
109 | WAeUP Student container for the various student data |
---|
110 | """ |
---|
111 | meta_type = 'Student' |
---|
112 | portal_type = meta_type |
---|
113 | security = ClassSecurityInfo() |
---|
114 | |
---|
115 | security.declarePublic("test") |
---|
116 | def test(self): |
---|
117 | """test""" |
---|
118 | return self.REQUEST |
---|
119 | |
---|
120 | InitializeClass(Student) |
---|
121 | |
---|
122 | def addStudent(container, id, REQUEST=None, **kw): |
---|
123 | """Add a Student.""" |
---|
124 | ob = Student(id, **kw) |
---|
125 | return CPSBase_adder(container, ob, REQUEST=REQUEST) |
---|
126 | |
---|
127 | ###) |
---|