Node 'user' property now defaults to the current user ID.

This commit is contained in:
2016-07-06 15:19:28 +02:00
parent 447473303a
commit d95004e62e
3 changed files with 53 additions and 2 deletions

View File

@@ -1,7 +1,7 @@
import logging
from bson import ObjectId
from flask import current_app
from flask import current_app, g
from werkzeug.exceptions import UnprocessableEntity
from application.modules import file_storage
@@ -116,6 +116,9 @@ def before_inserting_nodes(items):
if project:
item['project'] = project['_id']
# Default the 'user' property to the current user.
item.setdefault('user', g.current_user['user_id'])
def after_inserting_nodes(items):
for item in items:

View File

@@ -304,7 +304,6 @@ nodes_schema = {
},
'user': {
'type': 'objectid',
'required': True,
'data_relation': {
'resource': 'users',
'field': '_id',