'Toggle favorite stars on Slices and Dashboard'

@expose(u'/favstar/<class_name>/<obj_id>/<action>/')
def favstar(self, class_name, obj_id, action):

    session = db.session()
    FavStar = models.FavStar
    count = 0
    favs = session.query(FavStar).filter_by(class_name=class_name, obj_id=obj_id, user_id=g.user.get_id()).all()
    if (action == u'select'):
        if (not favs):
            session.add(FavStar(class_name=class_name, obj_id=obj_id, user_id=g.user.get_id(), dttm=datetime.now()))
        count = 1
    elif (action == u'unselect'):
        for fav in favs:
            session.delete(fav)
    else:
        count = len(favs)
    session.commit()
    return json_success(json.dumps({u'count': count}))
