From 44302b6623ca2b7b25605de6f944091644db3b03 Mon Sep 17 00:00:00 2001 From: Francesco Siddi Date: Mon, 5 Oct 2015 19:55:56 +0200 Subject: [PATCH] Introducing the comment node_type --- pillar/manage.py | 76 ++++++++++++++++++++++++++++++++++++++++++++-- pillar/settings.py | 1 - 2 files changed, 74 insertions(+), 3 deletions(-) diff --git a/pillar/manage.py b/pillar/manage.py index 043cdc37..80562ce2 100644 --- a/pillar/manage.py +++ b/pillar/manage.py @@ -658,7 +658,6 @@ def populate_node_types(old_ids={}): 'backend': { 'type': 'string', }, - }, 'form_schema': { 'subdir': {}, @@ -670,6 +669,77 @@ def populate_node_types(old_ids={}): } } + node_type_comment = { + 'name': 'comment', + 'description': 'Comments for asset asset nodes, pages, etc.', + 'dyn_schema': { + # The actual comment content (initially Markdown format) + 'content': { + 'type': 'string', + 'minlength': 5, + }, + 'status': { + 'type': 'string', + 'allowed': [ + 'published', + 'deleted', + 'flagged', + 'edited' + ], + }, + # Total count of positive ratings (updated at every rating action) + 'rating_positive': { + 'type': 'integer', + }, + # Total count of negative ratings (updated at every rating action) + 'rating_negative': { + 'type': 'integer', + }, + # Collection of ratings, keyed by user + 'ratings': { + 'type': 'dict', + 'schema': { + 'user': { + 'type': 'objectid' + }, + 'is_positive': { + 'type': 'boolean' + }, + # Weight of the rating based on user rep and the context. + # Currently we have the following weights: + # - 1 auto null + # - 2 manual null + # - 3 auto valid + # - 4 manual valid + 'weight': { + 'type': 'integer' + } + } + }, + 'confidence': { + 'type': 'float' + } + + }, + 'form_schema': { + 'content': {}, + 'status': {}, + 'rating_positive': {}, + 'rating_negative': {}, + 'ratings': { + 'schema': { + 'user': {}, + 'is_positive': {}, + 'weight': {} + } + }, + 'confidence': {} + }, + 'parent': { + 'node_types': ['asset',] + } + } + from pymongo import MongoClient client = MongoClient(MONGO_HOST, 27017) @@ -686,6 +756,7 @@ def populate_node_types(old_ids={}): return node_type_dict def upgrade(node_type, old_ids): + print("Node {0}".format(node_type['name'])) node_name = node_type['name'] if node_name in old_ids: node_type = mix_node_type(old_ids[node_name], node_type) @@ -695,7 +766,7 @@ def populate_node_types(old_ids={}): db.node_types.insert(node_type) else: print("Making the node") - print node_type + print(node_type) post_item('node_types', node_type) # upgrade(shot_node_type, old_ids) @@ -706,6 +777,7 @@ def populate_node_types(old_ids={}): upgrade(project_node_type, old_ids) upgrade(asset_node_type, old_ids) upgrade(node_type_storage, old_ids) + upgrade(node_type_comment, old_ids) @manager.command diff --git a/pillar/settings.py b/pillar/settings.py index e476dacc..a4bde787 100644 --- a/pillar/settings.py +++ b/pillar/settings.py @@ -144,7 +144,6 @@ organizations_schema = { } } - nodes_schema = { 'name': { 'type': 'string',