I think you're on the right track. It's a personal thing but I like 
defining my tables in the singular (ie, class, student, attendence).

As Donald indicated, your current model is best suited for each student 
only being in one class (which is fine for elementary school). It would 
work for students taking multiple classes but each student would be 
represented multiple times in DB.

I don't think "default=db.classes.id" is going to work.

You could have some controllers like:

def class_list():
  classes = db(db.classes.id>0).select()
  return dict(classes=classes)

def class():
  class = db.classes(request.args(0, cast=int)) or 
redirect(URL('class_list'))
  students = db(db.students.class_id==class.id).select()
  return dict(class=class, students=students)

def attendance():
  db.attendance.update(class_id=request.vars.class_id, 
student_id=request.vars.student_id, Attend=attendance)
  response.flash = 'Attendance recorded'
  redirect URL('class_list', args=[class_id])

Once you get this working, you could investigate an Ajax approach.
  

-- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to