def unitedit():
    """
    edit a unit details
    """
    unit = db.unit(request.args(0)) or redirect(URL('index'))
    crud.settings.delete_next = URL('course', args=unit.course)
    form = crud.update(db.unit, unit.id, next=URL('unit',
args=unit.id))
    return dict(form=form)

If the user ticks the 'delete' box then submits the form, then they
are redirected to the 'unit' page, which drops them back to the index
page.
The code for the function 'crud.update' does not look at the variable
'crud.settings.delete_next' at all, as far as I can see.

I have found a solution, of sorts, which is to use the 'ondelete'
function to set a session variable with the 'courseid', which is then
checked by the 'unit' page which does an extra redirect to the course
page (after deleting the session variable).

Davo

On Aug 11, 2:13 pm, mdipierro <mdipie...@cs.depaul.edu> wrote:
> Can you post an example? This
>
> crud.settings.delete_next
>
> should work.
>
> Massimo
>
> On Aug 11, 3:18 am, davosmith <d...@davosmith.co.uk> wrote:
>
>
>
>
>
>
>
> > I have a series of linked database tables:
>
> > 'course' which contains several 'units' which contain several
> > 'topics'.
>
> > On the 'unit' page, I display the details of the unit, a list of
> > topics and a link to edit the unit details.
>
> > When you click on the edit link, a crud.update form is created, which
> > sends the user back to the 'unit' page, once the update is complete.
>
> > The problem is, that if the user deletes the record for the unit, then
> > they need to be redirected to the 'course' page, rather than the
> > 'unit' page (as this unit no longer exists to be displayed).
>
> > After looking through the source code, I can't find any way of doing
> > this - 'crud.settings.delete_next' is ignored in the crud.update form
> > and trying to alter the value of 'next' inside the 'ondelete'
> > function, will not work as the value of 'next' has already been copied
> > into a local variable by that point in the crud.update function.
>
> > Does anyone have any helpful suggestions?

Reply via email to