I think all of this logic should happen in the view, not the model.  This code has nothing to do with the model, and everything to do with how the model is presented.