def home(): # Verify these queries; probably redirect if they fail. organization = Organization.objects(id=session["organization_id"]).first() events = Event.objects(organization=organization) number_of_events = events.count() members = Member.objects(organization=organization) number_of_members = members.count() return render_template('client/home.html', **locals())
def detail(member_id): try: member = Member.objects(id=member_id).first() if member != None: events = Event.objects(attendees__in=[member]) return render_template("members/detail.html", member=member, events=events, auth=is_authenticated()) except: pass return render_template("error/404.html"), 404
def check_in(event_id): form = EventCheckinForm(request.form) message = "" if request.method == 'POST' and form.validate(): try: # TODO: Fix this. It's a little bit janky. event = Event.objects(id=event_id).first() if event != None: member = Member.objects(name=form.name.data, organization=event.organization).first() if member == None: member = Member(name=form.name.data, organization=event.organization) member.save() event = Event.objects(id=event_id, attendees__nin=[member]).first() if event != None: event.attendees.append(member) event.save() message = "Successfully checked in." else: message = "You have already checked in to this event." except: return render_template("error/404.html"), 404 return render_template("events/check_in.html", form=form, message=message)
def members(): organization = Organization.objects(id=session["organization_id"]).first() members = Member.objects(organization=organization) return render_template('client/members.html', members=members)