From a605acb856f213c51f8faeff3c31a332114ded55 Mon Sep 17 00:00:00 2001 From: Eibriel Date: Tue, 14 Apr 2015 12:04:50 -0300 Subject: [PATCH] Adding support for Dictionaries on Forms WIP converting datetime string to datetime --- attract/application/__init__.py | 11 +++++++++++ attract/manage.py | 6 ++++++ 2 files changed, 17 insertions(+) diff --git a/attract/application/__init__.py b/attract/application/__init__.py index ae8af7ac..d783e9af 100644 --- a/attract/application/__init__.py +++ b/attract/application/__init__.py @@ -14,6 +14,10 @@ from bson import ObjectId from datetime import datetime from datetime import timedelta + +RFC1123_DATE_FORMAT = '%a, %d %b %Y %H:%M:%S GMT' + + class SystemUtility(): def __new__(cls, *args, **kwargs): raise TypeError("Base class may not be instantiated") @@ -126,6 +130,13 @@ class ValidateCustomFields(Validator): lookup['_id'] = ObjectId(self.document['node_type']) node_type = node_types.find_one(lookup) + # TODO make this REAL! + try: + value['time']['start'] = datetime.strptime( + value['time']['start'], RFC1123_DATE_FORMAT) + except: + pass + v = Validator(node_type['dyn_schema']) val = v.validate(value) if val: diff --git a/attract/manage.py b/attract/manage.py index cf993242..a7549240 100644 --- a/attract/manage.py +++ b/attract/manage.py @@ -132,9 +132,15 @@ def populate_node_types(old_ids={}): "schema": { "users": { "type": "list", + "schema": { + "type": "string", + } }, "groups": { "type": "list", + "schema": { + "type": "string", + } } } },