ok, the below now works, except for the part where it returns to parent
controller (highlighted yellow).
Seems like there needs to be a way for the child controller to remember the
grandparent vars.
CHILD CONTROLLER - after form is filled, wants to redirect to parent
controller with the correct vars.
def edit_object_comment():
db.SuperObjectComment.superObjectID.readable = True
db.SuperObjectComment.superObjectID.writable = False
comment_id = request.args(0) or redirect(URL('view_suggestions'))
form = SQLFORM(db.SuperObjectComment, comment_id, next=(URL('default',
'comment_on_an_object')), _class='formstyle')
if form.process().accepted:
response.flash = 'form accepted'
redirect(URL('comment_on_an_object',
vars=dict(filter=db.SuperObjectComment.superObjectID,
id=db.SuperObjectComment.id)))
elif form.errors:
response.flash = 'form has errors'
return dict(form=form)
GRANDPARENT CONTROLLER sends this to the parent. Child controller needs to
figure out how to go to parent controller too.
dict(header='Comments', body=lambda row: A('Comments',_class="btn
btn-mini", _href=URL('comment_on_an_object', vars=dict(filter=row.objectID,
id=row.id))))
PARENT CONTROLLER
def comment_on_an_object():
is_owner = (lambda row: row.created_by == auth.user_id) if auth.user
else False
db.SuperObjectComment.superObjectID.default = request.get_vars.filter
db.SuperObjectComment.superObjectID.readable = False
db.SuperObjectComment.superObjectID.writable = False
commentsHeader=db.SuperObject(request.get_vars.filter)
form = crud.create(db.SuperObjectComment)
objectComments = db(db.SuperObjectComment.superObjectID ==
request.get_vars.filter).select()
return locals()
PARENT HTML
{{extend 'layout.html'}}
<font size=+3>
Comments<input style="margin:0px 0px 0px 80px" type="button"
onclick="history.go(-1);" value="Back"></font>
<h1 style="margin:60px 40px 40px 40px">
{{=(commentsHeader.objectDisplayName)}}</h1>
<table><!--- big table that contains two tables that run down the whole
length of page. One on left is comments. Table on right contains ads or
other types of info -->
<tr> <td> <!-- this table on left -->
<table class="table table-striped">
{{for objectComment in objectComments:}}
<tr>
<td
style="color:gray;font-size:80%">{{=prettydate(objectComment.created_on)}}</td>
<td>{{=A(objectComment.created_by.first_name,
_href=URL('default','view_user_profile', args=objectComment.created_by))}}
{{=A(objectComment.created_by.last_name,
_href=URL('default','view_user_profile',
args=objectComment.created_by))}}</td>
<td>{{=MARKMIN(objectComment.superObjectComment)}}</td>
<td> {{if auth.user_id == objectComment.created_by:}}
{{=A(objectComment.created_by.first_name,
_href=URL('default','view_user_profile', args=objectComment.created_by),
_class='btn btn-min')}}</td>
{{pass}}
<td> {{if auth.user_id == objectComment.created_by:}} {{=A("Edit me",
_href=URL('default','edit_object_comment', args=objectComment.id),
_class='btn btn-min')}}</td>
{{pass}}
</tr>
{{pass}}
</table>
<hr>
<h4>{{=form}}</h4>
</td> <!-- this end table on left.><td> <!-- this starts table on right -->
</tr>
</table>
<input style="margin:70px" type="button" onclick="history.go(-1);"
value="Back">
I'm hoping someone can explain how to phrase the syntax in yellow so that
the the real vars are produced instead of the pseudo code.
thanks,
Alex Glaros
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.