Commit 26ccd7d6 authored by Cédric Bonhomme's avatar Cédric Bonhomme

New test for the insertion of epcis event. It is now possible to lists all aggregated events.

parent d4f39b12
......@@ -37,8 +37,9 @@ class EPCISEvent(Document):
"""
Defines the model for an EPCIS event.
"""
oid = ObjectIdField(default=bson.objectid.ObjectId , primary_key=True)
data = DictField()
insetion_date = DateTimeField(required=True)
insetion_date = DateTimeField(required=True, default=datetime.now)
def __str__(self):
return 'ECISEvent: %s' % self.data
\ No newline at end of file
#! /usr/bin/env python
# -*- coding: utf-8 -*-
from xmltodict import parse
from flask import request, jsonify
from flask.ext.restful import Resource, Response, reqparse
......@@ -17,12 +18,17 @@ class EPCISEventAPI(Resource):
def get(self):
"""
"""
return jsonify({})
result = models.EPCISEvent.objects()
epcis_events = [epcis_event.data for epcis_event in result]
return jsonify(result="ok", epcis_events=epcis_events)
def put(self):
"""
"""
pass
xml_epcis_event = request.data
json_epcis_event = parse(xml_epcis_event)
models.EPCISEvent(data=json_epcis_event).save()
return json_epcis_event
def post(self):
"""
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment