source: trunk/skins/lemill/script_editPieces.py @ 1379

Revision 1379, 1.5 KB checked in by jukka, 13 years ago (diff)

Fixed #1115 spent 1h more. Forgot to add the actual validator in last commit, piece mass uploader also fixd, but with irritating feature of not being able to go back and try a better name. (That page nees one more button.)

Line 
1## Script (Python) "delete_resource"
2##bind container=container
3##bind context=context
4##bind namespace=
5##bind script=script
6##parameters=description=''
7##title=Delete resource
8##
9"""Edit several pieces at once"""
10REQUEST=context.REQUEST
11
12lenpieces= int(REQUEST.get('lenpieces'))
13values=[]
14pieces=[]
15d={}
16return_page = REQUEST.SESSION.get('return_page')
17kwargs={}
18# these two come from state.kwargs, not piece_edit form
19edit_page=return_page['edit_page']
20edit_nr=return_page['edit_nr']
21problems=[]
22psm=''
23
24for n in range(lenpieces):
25    d={}
26    d['title'] = REQUEST.get('title_%s' % n)
27    d['description'] = REQUEST.get('description_%s' % n)
28    d['tags'] = REQUEST.get('tags_%s' % n)
29    d['originalAuthor'] = REQUEST.get('originalAuthor_%s' % n)
30    d['rights'] = REQUEST.get('rights_%s' % n)
31    values.append(d)
32    pieces.append(REQUEST.get('uid_%s' % n))
33    problem=context.lemill_tool.savePiece(pieces[n], values[n])
34    if problem:
35        problems.append(problem)
36
37if problems:
38    psm='&portal_status_message=%s' % ' '.join(problems)
39
40
41del REQUEST.SESSION['new_pieces']
42
43if REQUEST.SESSION.has_key('slide_uploader'):
44    n_pieces=REQUEST.SESSION['slide_uploader']
45    del REQUEST.SESSION['slide_uploader']
46    return REQUEST.RESPONSE.redirect(context.absolute_url()+'/slide_uploader?n_pieces=%s%s' % (n_pieces, psm))
47else:   
48    del REQUEST.SESSION['return_page']
49    return REQUEST.RESPONSE.redirect(context.absolute_url()+'/%s?edit=%s#%s%s' % (edit_page, edit_nr, edit_nr, psm))
50   
Note: See TracBrowser for help on using the repository browser.