Looks good. This assumes you you created the table_name+'_archive'
according to crud.archive.


On 2 Lug, 04:09, selecta <[email protected]> wrote:
> How do I display the edit history?
>
> For example I want to preserve the original creator and see who edited
> it. How I understand this right now I would add the following fields
> to each table that is archived
>
> Field('created_by',default=auth.user_id,update=auth.user_id,writable=False),
> Field('edited_by',default=auth.user_id,update=auth.user_id,writable=False),
> Field('created_on',default=request.now,update=request.now,writable=False)
>
> and then get the history with
>
> table_name = 'example'
> current_record = record
> history = []
> while current_record:
>   current_record = db(getattr(db,table_name+"_archive").current_record
> ==current_record.id).select().first()
>   history.insert(0, current_record)
>
> and then display the history with something like
> versions: {{= ' '.join(["v%s (%s %s)"%(i, record.edited_by,
> record.created_on) for i,record in enumerate(history)]}}
>
> is this right?

Reply via email to