BlenderKit: several fixes - oauth errors

authentication errors
drag drop on cameras/lights threw an error
undo push message
Ready status for validation status search
This commit is contained in:
Vilém Duha 2020-02-03 22:33:34 +01:00
parent 168f144256
commit 8b659917ba
6 changed files with 9 additions and 7 deletions

View File

@ -474,13 +474,13 @@ class BlenderKitCommonSearchProps(object):
('ALL', 'All', 'All'),
('UPLOADING', 'Uploading', 'Uploading'),
('UPLOADED', 'Uploaded', 'Uploaded'),
('READY', 'Ready for V.', 'Ready for validation (deprecated since 2.8)'),
('VALIDATED', 'Validated', 'Calidated'),
('ON_HOLD', 'On Hold', 'On Hold'),
('REJECTED', 'Rejected', 'Rejected'),
('DELETED', 'Deleted', 'Deleted'),
),
default='ALL',
update=search.search_update,
)

View File

@ -78,7 +78,7 @@ def refresh_token(api_key_refresh, url):
auth_token, refresh_token, oauth_response = authenticator.get_refreshed_token(api_key_refresh)
if auth_token is not None and refresh_token is not None:
tasks_queue.add_task((write_tokens, (auth_token, refresh_token, oauth_response)))
return auth_token, refresh_token
return auth_token, refresh_token, oauth_response
def write_tokens(auth_token, refresh_token, oauth_response):

View File

@ -441,7 +441,7 @@ def append_asset(asset_data, **kwargs): # downloaders=[], location=None,
scene['assets rated'][id] = scene['assets rated'].get(id, False)
parent['asset_data'] = asset_data # TODO remove this??? should write to blenderkit Props?
bpy.ops.wm.undo_push_context()
bpy.ops.wm.undo_push_context(message = 'add %s to scene'% asset_data['name'])
# moving reporting to on save.
# report_use_success(asset_data['id'])

View File

@ -54,7 +54,7 @@ def rerequest(method, url, **kwargs):
if rdata.get('detail') == 'Invalid token.':
user_preferences = bpy.context.preferences.addons['blenderkit'].preferences
if user_preferences.api_key != '':
if user_preferences.enable_oauth:
if user_preferences.enable_oauth and user_preferences.api_key_refresh != '':
tasks_queue.add_task((ui.add_report, (
'refreshing token. If this fails, please login in BlenderKit Login panel.', 10)))
refresh_url = paths.get_bkit_url()

View File

@ -247,7 +247,6 @@ def timer_update(): # TODO might get moved to handle all blenderkit stuff.
'author_id': str(r['author']['id']),
# 'author': r['author']['firstName'] + ' ' + r['author']['lastName']
# 'description': r['description'],
'author': r['author'],
}
asset_data['downloaded'] = 0

View File

@ -1575,7 +1575,8 @@ class AssetBarOperator(bpy.types.Operator):
else:
# first, test if object can have material applied.
if object is not None and not object.is_library_indirect:
#TODO add other types here if droppable.
if object is None or object.is_library_indirect and object.type =='MESH' :
target_object = object.name
# create final mesh to extract correct material slot
depsgraph = bpy.context.evaluated_depsgraph_get()
@ -1778,6 +1779,8 @@ class UndoWithContext(bpy.types.Operator):
# def modal(self, context, event):
# return {'RUNNING_MODAL'}
message = StringProperty('Undo Message', default = 'BlenderKit operation')
def execute(self, context):
C_dict = bpy.context.copy()
C_dict.update(region='WINDOW')
@ -1785,7 +1788,7 @@ class UndoWithContext(bpy.types.Operator):
w, a, r = get_largest_3dview()
override = {'window': w, 'screen': w.screen, 'area': a, 'region': r}
C_dict.update(override)
bpy.ops.ed.undo_push(C_dict, 'INVOKE_REGION_WIN')
bpy.ops.ed.undo_push(C_dict, 'INVOKE_REGION_WIN', message = self.message)
return {'FINISHED'}