def create(): form = CreateEventForm(request.form) if request.method == 'POST' and form.validate(): organization = Organization.objects(id=session["organization_id"]).first() new_event = Event(name=form.name.data, organization=organization) new_event.save() return redirect(url_for('client.events')) return render_template('events/create.html', form=form)
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(event_id): try: event = Event.objects(id=event_id).first() if event != None: return render_template("events/detail.html", event=event, auth=is_authenticated()) except: pass return render_template("error/404.html"), 404
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 post_events(): """ This is the summary defined in yaml file First line is the summary All following lines until the hyphens is added to description the format of the first lines until 3 hyphens will be not yaml compliant but everything below the 3 hyphens should be. --- tags: - event parameters: - in: query name: name type: string required: true description: "The name of the Event" - in: query name: organizer type: string required: true description: "The ObjectId of the organizer for the Event" - in: body name: dates schema: type: array items: $ref: "#/definitions/EventDate" description: "The number of items to retrieve" responses: 200: description: Many Event items schema: type: array items: $ref: "#/definitions/Event" """ event = { 'name': request.args.get('name'), 'organizer': request.args.get('organizer'), 'dates': request.get_json(silent=True) } document = Event.deserialize(event) document.save() return jsonify('magic')
def get_events(): """ This is the summary defined in yaml file First line is the summary All following lines until the hyphens is added to description the format of the first lines until 3 hyphens will be not yaml compliant but everything below the 3 hyphens should be. --- tags: - event responses: 200: description: Many Event items schema: type: array items: $ref: "#/definitions/Event" """ results = [Event.serialize(event) for event in Event.objects] return jsonify(results)
def post(self): """ Register a new event """ try: event = Event( name=request.json.get('name'), location=request.json.get('location'), start_time=datetime.strptime(request.json.get('start_time'), '%Y-%m-%dT%H:%M:%S'), end_time=datetime.strptime(request.json.get('end_time'), '%Y-%m-%dT%H:%M:%S'), email=request.json.get('email')) db.session.add(event) db.session.commit() return event, 201 except IntegrityError: db.session.rollback() raise BadRequest( "Event is existing or event name can not be duplicated.")
def remove_event(): # 临时调班 e = Event.get_by_id(g.data['id']) e.delete() return trueReturn()
def edit_event(): e = Event.get_by_id(g.data['id']) e.edit_event(g.user, g.data['name'], g.data['frequency'], g.data['offset'], g.data['start'], g.data['end'], g.data['timenode']) return trueReturn()
def new_event(): Event.new_event(g.user, g.data['name'], g.data['frequency'], g.data['offset'], g.data['start'], g.data['end'], g.data['timenode']) return trueReturn()
def events(): organization = Organization.objects(id=session["organization_id"]).first() events = Event.objects(organization=organization) return render_template('client/events.html', events=events)
def redirect_to_judge_event(code): event = Event().getEventByCode(code) papers = Paper().getAllPapers() return render_template("judge-events.html", event=event, papers=papers)
def redirect_event_page(code): event = Event().getEventByCode(code) papers = Paper().getAllPapers() return render_template("admin-events.html", event=event, papers=papers)