source: WAeUP_SRP/branches/uli/skins/waeup_default/waeup_document_create_do.py @ 17952

Last change on this file since 17952 was 1366, checked in by joachim, 18 years ago

M profiles/default/schemas/certificate_course.xml
make level searchable
M profiles/default/layouts/course.xml
add code to course layout to allow creation
M skins/waeup_default/waeup_edit.py
M skins/waeup_default/waeup_document_create_do.py
M skins/waeup_custom/folder_delete.py
fix that courses_catalog also get updated
M skins/waeup_academics/courses_view.pt
M skins/waeup_academics/getCoursesInfo.py
use courses catalog.

  • Property svn:keywords set to Id
File size: 1.5 KB
Line 
1##parameters=type_name, datamodel
2# $Id: waeup_document_create_do.py 1366 2007-01-27 15:40:19Z joachim $
3"""
4Create an empty object in the context according to the datamodel.
5
6Datamodel may be examined to create a suitable id.
7
8Returns the created object (usually a proxy).
9"""
10from Products.CMFCore.utils import getToolByName
11request = context.REQUEST
12if type_name in ("StudyLevel","StudentStudyLevel"):
13    id = datamodel.get('code')
14else:
15    id = datamodel.get('code').upper()
16    datamodel.set('code',id)
17##if not id:
18##    id = 'my ' + type_name
19##id = context.computeId(compute_from=id) # XXX shouldn't use a skin
20##
21language = datamodel.get('Language')
22if not language:
23    ts = getToolByName(context, 'translation_service')
24    language = ts.getSelectedLanguage()
25
26ttool = getToolByName(context, 'portal_types')
27ti = ttool[type_name]
28allow_discussion = ti.allowDiscussion()
29
30# Datamodel is passed so that flexti can initialize the object.
31new_id = context.invokeFactory(type_name, id, datamodel=datamodel,
32                               language=language,
33                               allow_discussion=allow_discussion)
34if new_id is not None:
35    id = new_id
36if type_name == "Course":
37    d = {}
38    ptl = request.get('PATH_TRANSLATED').split('/')
39    ai = ptl.index('academics')
40    d['faculty'] = ptl[ai+1]
41    d['department'] = ptl[ai+2]
42    from_dm = ('code','title','semester','credits',)
43    for f in from_dm:
44        d[f] = datamodel.get(f)
45    context.courses_catalog.addRecord(**d)
46ob = getattr(context, id)
47ob.getContent().edit(mapping=datamodel)
48
49context.notifyCPSDocumentCreation(ob=ob) # BBB obsolete in CPS 3.5.0
50
51return ob
Note: See TracBrowser for help on using the repository browser.