Added pillar.api.utils.utcnow() which returns a datetime for 'now'

This replaces pillar.web.utils.datetime_now() and can be used in a wider
setting (since we don't import web stuff in the api, but we do vice versa).
This commit is contained in:
2018-02-13 14:36:05 +01:00
parent d0520484bb
commit f2888069db
15 changed files with 41 additions and 52 deletions

View File

@@ -1,12 +1,11 @@
import copy
import logging
import datetime
from bson import ObjectId, tz_util
from bson import ObjectId
from eve.methods.get import get
from flask import Blueprint, current_app, request
from pillar.api import utils
from pillar.api.utils import authentication, authorization
from pillar.api.utils import authentication, authorization, utcnow
from werkzeug import exceptions as wz_exceptions
from pillar.api.projects import utils as proj_utils
@@ -282,7 +281,7 @@ def is_home_project(project_id, user_id):
def mark_node_updated(node_id):
"""Uses pymongo to set the node's _updated to "now"."""
now = datetime.datetime.now(tz=tz_util.utc)
now = utcnow()
nodes_coll = current_app.data.driver.db['nodes']
return nodes_coll.update_one({'_id': node_id},