Ajout du nom du fichier avant upload.
[Plinn.git] / skins / custom_control / addtoFavorites.py
1 ## Script (Python) "addtoFavorites"
2 ##title=Add item to favourites
3 ##parameters=ajax=''
4
5 #TODO : translate messages
6 #from Products.PlacelessTranslationService.MessageID import MessageIDFactory
7 #_ = MessageIDFactory('plinn')
8 _ = lambda x : lambda : x
9
10 portal = context.portal_url.getPortalObject()
11 ttool = portal.portal_types
12 homeFolder = portal.portal_membership.getHomeFolder()
13
14 if not hasattr(homeFolder, 'Favorites'):
15 ttool.constructContent( 'Plinn Folder', homeFolder, 'Favorites', title=str(_('Favorites')) )
16
17 targetFolder = getattr( homeFolder, 'Favorites' )
18 new_id='fav_' + str(int( context.ZopeTime()))
19 myPath=context.portal_url.getRelativeUrl(context)
20 targetFolder.invokeFactory( 'Favorite', id=new_id, title=context.TitleOrId(), remote_url=myPath)
21
22 context.setStatus(True, 'Favorite added.')
23 context.setRedirect(context, 'object/view', ajax=ajax)