This should be done in the view as it needs to be called once for each assignment. See my comment here:

https://github.com/bellotastudios/gradecraft-development/issues/301#issuecomment-23888128