Attract multi edit: Edit multiple tasks/shots/assets at the same time
For the user: Ctrl + L-Mouse to select multiple tasks/shots/assets and then edit the nodes as before. When multiple items are selected a chain icon can be seen in editor next to the fields. If the chain is broken it indicates that the values are not the same on all the selected items. When a field has been edited it will be marked with a green background color. The items are saved one by one in parallel. This means that one item could fail to be saved, while the others get updated. For developers: The editor and activities has been ported to Vue. The table and has been updated to support multi select. MultiEditEngine is the core of the multi edit. It keeps track of what values differs and what has been edited.
This commit is contained in:
@@ -6,7 +6,7 @@ import pymongo.errors
|
||||
import werkzeug.exceptions as wz_exceptions
|
||||
from flask import current_app, Blueprint, request
|
||||
|
||||
from pillar.api.nodes import eve_hooks, comments
|
||||
from pillar.api.nodes import eve_hooks, comments, activities
|
||||
from pillar.api.utils import str2id, jsonify
|
||||
from pillar.api.utils.authorization import check_permissions, require_login
|
||||
from pillar.web.utils import pretty_date
|
||||
@@ -86,6 +86,12 @@ def post_node_comment_vote(node_path: str, comment_path: str):
|
||||
return comments.post_node_comment_vote(node_id, comment_id, vote)
|
||||
|
||||
|
||||
@blueprint.route('/<string(length=24):node_path>/activities', methods=['GET'])
|
||||
def activities_for_node(node_path: str):
|
||||
node_id = str2id(node_path)
|
||||
return jsonify(activities.for_node(node_id))
|
||||
|
||||
|
||||
@blueprint.route('/tagged/')
|
||||
@blueprint.route('/tagged/<tag>')
|
||||
def tagged(tag=''):
|
||||
@@ -264,3 +270,5 @@ def setup_app(app, url_prefix):
|
||||
app.on_deleted_item_nodes += eve_hooks.after_deleting_node
|
||||
|
||||
app.register_api_blueprint(blueprint, url_prefix=url_prefix)
|
||||
|
||||
activities.setup_app(app)
|
||||
|
43
pillar/api/nodes/activities.py
Normal file
43
pillar/api/nodes/activities.py
Normal file
@@ -0,0 +1,43 @@
|
||||
from eve.methods import get
|
||||
|
||||
from pillar.api.utils import gravatar
|
||||
|
||||
|
||||
def for_node(node_id):
|
||||
activities, _, _, status, _ =\
|
||||
get('activities',
|
||||
{
|
||||
'$or': [
|
||||
{'object_type': 'node',
|
||||
'object': node_id},
|
||||
{'context_object_type': 'node',
|
||||
'context_object': node_id},
|
||||
],
|
||||
},)
|
||||
|
||||
for act in activities['_items']:
|
||||
act['actor_user'] = _user_info(act['actor_user'])
|
||||
|
||||
return activities
|
||||
|
||||
|
||||
def _user_info(user_id):
|
||||
users, _, _, status, _ = get('users', {'_id': user_id})
|
||||
if len(users['_items']) > 0:
|
||||
user = users['_items'][0]
|
||||
user['gravatar'] = gravatar(user['email'])
|
||||
|
||||
public_fields = {'full_name', 'username', 'gravatar'}
|
||||
for field in list(user.keys()):
|
||||
if field not in public_fields:
|
||||
del user[field]
|
||||
|
||||
return user
|
||||
return {}
|
||||
|
||||
|
||||
def setup_app(app):
|
||||
global _user_info
|
||||
|
||||
decorator = app.cache.memoize(timeout=300, make_name='%s.public_user_info' % __name__)
|
||||
_user_info = decorator(_user_info)
|
@@ -223,7 +223,8 @@ def doc_diff(doc1, doc2, *, falsey_is_equal=True, superkey: str = None):
|
||||
function won't report differences between DoesNotExist, False, '', and 0.
|
||||
"""
|
||||
|
||||
private_keys = {'_id', '_etag', '_deleted', '_updated', '_created'}
|
||||
def is_private(key):
|
||||
return str(key).startswith('_')
|
||||
|
||||
def combine_key(some_key):
|
||||
"""Combine this key with the superkey.
|
||||
@@ -244,7 +245,7 @@ def doc_diff(doc1, doc2, *, falsey_is_equal=True, superkey: str = None):
|
||||
|
||||
if isinstance(doc1, dict) and isinstance(doc2, dict):
|
||||
for key in set(doc1.keys()).union(set(doc2.keys())):
|
||||
if key in private_keys:
|
||||
if is_private(key):
|
||||
continue
|
||||
|
||||
val1 = doc1.get(key, DoesNotExist)
|
||||
|
Reference in New Issue
Block a user