Balt
unread,Jun 8, 2009, 3:13:29 AM6/8/09Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to TurboGears
Hi all,
I've got a fastdatagrid object and would like to work with only a
subset of the data. Currently, it lets everyone edit/view the entire
"events" table in the database. I would like it to only display the
events that belong to the logged in user. Some details:
from events.kid, this is how the data is displayed:
${list_widget.display(data, show_actions=True,
show_add_link=True,
delete_link_msg='Are you sure you want to
delete this event?',
add_link_title='Add Event')}
from controllers.py
events = DataController(
sql_class = Course,
list_widget = FastDataGrid(fields=[
('Name', 'course_name'),
('Provider', 'user'),
('Course Type', 'course_type'),
('Maximum Participants', 'max_participants'),
('Date', 'date'),
('Venue', 'venue')
]),
list_template = 'kco.templates.events')
and the class is defined in model.py:
class Course(SQLObject):
user = ForeignKey('User')
course_name = UnicodeCol(alternateID=True, length=255)
course_type = ForeignKey('CourseType')
max_participants = IntCol()
date = DateTimeCol()
venue = UnicodeCol(length=255)
I would have thought that the DataController knows some sort of query
argument, but it appears not so. One idea then was to implement this
on the SQLObject level by defining the statement inside the
DataController constructor sql_class = Course.select(user.q.$
{tg.identity.user.user_name}) but that doesn't work.
Does anyone know how this can be accomplished?
Cheers
- Balt