Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVilém Duha <vilda.novak@gmail.com>2019-12-18 16:31:23 +0300
committerVilém Duha <vilda.novak@gmail.com>2020-01-07 13:43:42 +0300
commitd7d70e8e86dee2694b1545996c40b5b6a87817c5 (patch)
tree2874dc0a940e4d6ac7fb1de0de314b4053486fa3
parent8b202fb6dccb9dc67ea78bc525e2875f7b1f6345 (diff)
BlenderKit: is_validator function for users
-rw-r--r--blenderkit/search.py39
-rw-r--r--blenderkit/ui_panels.py3
2 files changed, 28 insertions, 14 deletions
diff --git a/blenderkit/search.py b/blenderkit/search.py
index 414b9afc..844b7fd1 100644
--- a/blenderkit/search.py
+++ b/blenderkit/search.py
@@ -110,8 +110,8 @@ def fetch_server_data():
api_key = user_preferences.api_key
# Only refresh new type of tokens(by length), and only one hour before the token timeouts.
if user_preferences.enable_oauth and \
- len(user_preferences.api_key)<38 and \
- user_preferences.api_key_timeout<time.time()+ 3600:
+ len(user_preferences.api_key) < 38 and \
+ user_preferences.api_key_timeout < time.time() + 3600:
bkit_oauth.refresh_token_thread()
if api_key != '':
get_profile()
@@ -635,6 +635,11 @@ def write_profile(adata):
if user.get('remainingPrivateQuota') is not None:
user['remainingPrivateQuota'] /= (1024 * 1024)
+ if user.get('id') == 2:
+ user['exmenu'] = True
+ else:
+ user['exmenu'] = False
+
bpy.context.window_manager['bkit profile'] = adata
@@ -660,6 +665,7 @@ def fetch_profile(api_key):
utils.p(e)
+
def get_profile():
preferences = bpy.context.preferences.addons['blenderkit'].preferences
a = bpy.context.window_manager.get('bkit profile')
@@ -667,6 +673,11 @@ def get_profile():
thread.start()
return a
+def profile_is_validator():
+ a = bpy.context.window_manager.get('bkit profile')
+ if a is not None and a.get('exmenu'):
+ return True
+ return False
class Searcher(threading.Thread):
query = None
@@ -723,17 +734,20 @@ class Searcher(threading.Thread):
requeststring += '+'
# result ordering: _score - relevance, score - BlenderKit score
- if query.get('category_subtree') is not None:
- requeststring += '+order:-score,_score'
+
+ if query.get('author_id') is not None and profile_is_validator():
+ requeststring += '+order:-created'
else:
- requeststring += '+order:_score'
+ if query.get('category_subtree') is not None:
+ requeststring += '+order:-score,_score'
+ else:
+ requeststring += '+order:_score'
requeststring += '&addon_version=%s' % params['addon_version']
if params.get('scene_uuid') is not None:
requeststring += '&scene_uuid=%s' % params['scene_uuid']
urlquery = url + requeststring
-
try:
utils.p(urlquery)
r = rerequests.get(urlquery, headers=headers)
@@ -1111,27 +1125,27 @@ class SearchOperator(Operator):
name="category",
description="search only subtree of this category",
default="",
- options = {'SKIP_SAVE'}
+ options={'SKIP_SAVE'}
)
author_id: StringProperty(
name="Author ID",
description="Author ID - search only assets by this author",
default="",
- options = {'SKIP_SAVE'}
+ options={'SKIP_SAVE'}
)
get_next: BoolProperty(name="next page",
description="get next page from previous search",
default=False,
- options = {'SKIP_SAVE'}
- )
+ options={'SKIP_SAVE'}
+ )
keywords: StringProperty(
name="Keywords",
description="Keywords",
default="",
- options = {'SKIP_SAVE'}
+ options={'SKIP_SAVE'}
)
@classmethod
@@ -1163,7 +1177,7 @@ def register_search():
for c in classes:
bpy.utils.register_class(c)
- bpy.app.timers.register(timer_update, persistent = True)
+ bpy.app.timers.register(timer_update, persistent=True)
categories.load_categories()
@@ -1175,4 +1189,3 @@ def unregister_search():
bpy.utils.unregister_class(c)
if bpy.app.timers.is_registered(timer_update):
bpy.app.timers.unregister(timer_update)
-
diff --git a/blenderkit/ui_panels.py b/blenderkit/ui_panels.py
index a31a0392..d8ca90fc 100644
--- a/blenderkit/ui_panels.py
+++ b/blenderkit/ui_panels.py
@@ -771,12 +771,13 @@ class OBJECT_MT_blenderkit_asset_menu(bpy.types.Menu):
profile = wm.get('bkit profile')
if profile is not None:
# validation by admin
- if profile['user']['id'] == 2:
+ if profile['user']['exmenu']:
if asset_data['verificationStatus'] != 'validated':
op = layout.operator('object.blenderkit_change_status', text='Validate')
op.asset_id = asset_data['id']
op.state = 'validated'
+
if author_id == str(profile['user']['id']):
layout.label(text='Management tools:')
row = layout.row()