Project

General

Profile

« Previous | Next » 

Revision 5c851a65

Added by Frédéric Péters over 13 years ago

add confirmation dialog before strongbox item removal

View differences:

extra/modules/myspace.ptl
164 164
                '<td class="expiration">-</td>'
165 165
            '<td class="actions">'
166 166
            ' [<a href="download?id=%s">%s</a>] ' % (sffile.id, _('download'))
167
            '[<a href="remove?id=%s">%s</a>] ' % (sffile.id, _('remove'))
167
            '[<a rel="popup" href="remove?id=%s">%s</a>] ' % (sffile.id, _('remove'))
168 168
            '</td>'
169 169
            '</tr>'
170 170

  
......
267 267
        sffile.store()
268 268
        return redirect('.')
269 269

  
270
    def remove(self):
270
    def remove [html] (self):
271 271
        id = get_request().form.get('id')
272 272
        if not id:
273 273
            raise errors.TraversalError()
......
277 277
            raise errors.TraversalError()
278 278
        if str(sffile.user_id) != str(get_request().user.id):
279 279
            raise errors.TraversalError()
280
        sffile.remove_self()
281
        sffile.remove_file()
282
        return redirect('.')
280

  
281
        form = Form(enctype='multipart/form-data')
282
        form.add_hidden('id', get_request().form.get('id'))
283
        form.widgets.append(HtmlWidget('<p>%s</p>' % _(
284
                        'You are about to irrevocably delete this item from your strongbox.')))
285
        form.add_submit('submit', _('Submit'))
286
        form.add_submit('cancel', _('Cancel'))
287
        if form.get_submit() == 'cancel':
288
            return redirect('.')
289
        if not form.is_submitted() or form.has_errors():
290
            if sffile.type_id:
291
                '<h2>%s</h2>' % _('Deleting %s: %s') % (
292
                        (StrongboxType.get(sffile.type_id).label, sffile.get_display_name()))
293
            else:
294
                '<h2>%s</h2>' % _('Deleting %s') % sffile.get_display_name()
295
            form.render()
296
        else:
297
            sffile.remove_self()
298
            sffile.remove_file()
299
            return redirect('.')
283 300

  
284 301
    def pick [html] (self):
285 302
        field_id = str(get_request().form.get('id'))

Also available in: Unified diff