예제 #1
0
 def put(self):
     args = event_parser.parse_args()
     event = Event.query.get_by_tag(args.tag)
     event.name = args.name
     event.description = args.description
     event.venue = Venue.query.get_by_name(args.venue["name"])
     event.time = args.time
     event.date = args.date
     event.image = args.image
     event.gests = map(lambda gest: gest["username"], args.gests)
     event.requirement = map(lambda req: Requirement(name=req["name"],quantity=req["quantity"]), args.requirement)
     event.capacity = args.capacity
     event.visibility = Visibility.query.get(args.visibility)
     event.save()
     log.info("Edita un Evento con: {'tag':'%s'}" % event.tag)
     return event, 201
예제 #2
0
 def post(self):
     args = event_parser.parse_args()
     newEvent = Event(
         tag = args.tag,
         name = args.name,
         description = args.description,
         venue = Venue.query.get_by_name(args.venue["name"]),
         time = args.time,
         date = args.date,
         image = args.image,
         gests = map(lambda gest: gest["username"], args.gests),
         requirement = map(lambda req: Requirement(name=req["name"],quantity=req["quantity"]), args.requirement),
         capacity = args.capacity,
         visibility = Visibility.query.get(args.visibility),
         owner = currentUser()
     )
     newEvent.save()
     log.info("Crea un Evento con: {'tag':'%s'}" % newEvent.tag)
     return newEvent, 201