def dyntrack(self, id, track): u = identity.current.user ret = "Error" try: e = Event.get(id) if track == "true" and e not in u.events: try: att = Attendance.selectBy(user=u, event=e)[0] except IndexError: att = Attendance(user=u, event=e) att.planning_to_go = True ret = "Tracked" if track == "false" and e in u.events: atts = Attendance.selectBy(user=u, event=e) for att in atts: att.destroySelf() ret = "Untracked" except SQLObjectNotFound: pass return ret
def untrack(self, id, viewing="no"): u = identity.current.user try: e = Event.get(id) atts = Attendance.selectBy(user=u, event=e) for att in atts: att.destroySelf() except SQLObjectNotFound: flash("Event not found") redirect("/") if viewing == "no": util.redirect_previous() else: util.redirect("/events/%s" % e.id)
def show(self, user_name): try: u = UserAcct.by_user_name(user_name) artists = u.artists.orderBy(Artist.q.name) venues = u.venues.orderBy(Venue.q.name) attendances = Attendance.selectBy(user=u) viewing_self = False if identity.current.user and identity.current.user.user_name == user_name: viewing_self = True except SQLObjectNotFound: flash("User not found") util.redirect("/") return dict(user=u, artists=artists, venues=venues, attendances=attendances, viewing_self=viewing_self, description=util.desc_format(u.description))
def track(self, id, viewing="no", planning=False, went=False, comment=None): u = identity.current.user try: e = Event.get(id) try: att = Attendance.selectBy(user=u, event=e)[0] except IndexError: att = Attendance(user=u, event=e) att.planning_to_go = planning att.attended = went att.comment = comment except SQLObjectNotFound: flash("Event not found") redirect("/") if viewing == "no": util.redirect_previous() else: util.redirect("/events/%s" % e.id)