source: trunk/skins/lemill/group_create_edit_script.cpy @ 1919

Revision 1919, 1.4 KB checked in by jukka, 12 years ago (diff)

Refactored groups to not use portal_groups. Things should be faster and users from weird sources shouldn't cause so much problems. Not much tested yet, but archetype update and quickinstaller reinstall works fine.

Line 
1## Script (Python) "prefs_group_edit"
2##bind container=container
3##bind context=context
4##bind namespace=
5##bind script=script
6##bind subpath=traverse_subpath
7##parameters=addname=None, groupname=None, addmaterial=None
8##title=Edit user
9##
10from Products.CMFPlone.utils import normalizeString, getToolByName
11from Products.LeMill import LeMillMessageFactory as _
12from Products.CMFPlone import PloneMessageFactory as PMF
13
14REQUEST=context.REQUEST
15msg = PMF(u'No change has been done.')
16userName = context.portal_membership.getAuthenticatedMember().getUserName()
17
18if addname or groupname and not addmaterial:
19    title=REQUEST.get('title', '')
20    tags=REQUEST.get('tags', '')
21    description=REQUEST.get('description','')
22
23if addname:
24    addname=normalizeString(title, context=context)
25    addname=context.community.invokeFactory('GroupBlog',addname)
26    group=context.getGroupById(addname)
27    group.join_group()
28    group.edit(tags=tags, title=title, description=description)
29    msg = _(u"Group has been added.")
30elif groupname and not addmaterial:
31    group=context.getGroupById(groupname)
32    group.edit(tags=tags, title=title, description=description)
33    msg = PMF(u'Changes saved.')
34
35if addmaterial:
36    group.join_group()
37    return REQUEST.RESPONSE.redirect(context.absolute_url())
38
39context.plone_utils.addPortalMessage(msg)
40
41return REQUEST.RESPONSE.redirect(context.community.absolute_url())
Note: See TracBrowser for help on using the repository browser.