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:
-rw-r--r--blenderkit/__init__.py4
-rw-r--r--blenderkit/bkit_oauth.py1
-rw-r--r--blenderkit/download.py2
-rw-r--r--blenderkit/ratings.py1
-rw-r--r--blenderkit/search.py12
-rw-r--r--blenderkit/ui_panels.py17
-rw-r--r--blenderkit/upload.py6
-rw-r--r--blenderkit/utils.py7
8 files changed, 45 insertions, 5 deletions
diff --git a/blenderkit/__init__.py b/blenderkit/__init__.py
index c6ced37d..575538f8 100644
--- a/blenderkit/__init__.py
+++ b/blenderkit/__init__.py
@@ -17,12 +17,12 @@
# ##### END GPL LICENSE BLOCK #####
bl_info = {
- "name": "BlenderKit Asset Library",
+ "name": "BlenderKit Online Asset Library",
"author": "Vilem Duha, Petr Dlouhy",
"version": (1, 0, 30),
"blender": (2, 82, 0),
"location": "View3D > Properties > BlenderKit",
- "description": "Online BlenderKit library (materials, models, brushes and more)",
+ "description": "Online BlenderKit library (materials, models, brushes and more). Connects to the internet.",
"warning": "",
"doc_url": "{BLENDER_MANUAL_URL}/addons/add_mesh/blenderkit.html",
"category": "3D View",
diff --git a/blenderkit/bkit_oauth.py b/blenderkit/bkit_oauth.py
index d56629e5..4d2f09dc 100644
--- a/blenderkit/bkit_oauth.py
+++ b/blenderkit/bkit_oauth.py
@@ -139,6 +139,7 @@ class Logout(bpy.types.Operator):
preferences.login_attempt = False
preferences.api_key_refresh = ''
preferences.api_key = ''
+ del (bpy.context.window_manager['bkit profile'])
return {'FINISHED'}
diff --git a/blenderkit/download.py b/blenderkit/download.py
index 31b6bae0..feed4e95 100644
--- a/blenderkit/download.py
+++ b/blenderkit/download.py
@@ -770,6 +770,8 @@ def get_download_url(asset_data, scene_id, api_key, tcom=None):
data = {
'scene_uuid': scene_id
}
+ r = None
+
try:
r = rerequests.get(asset_data['download_url'], params=data, headers=headers)
except Exception as e:
diff --git a/blenderkit/ratings.py b/blenderkit/ratings.py
index 2a6b95b0..c6ae4f8c 100644
--- a/blenderkit/ratings.py
+++ b/blenderkit/ratings.py
@@ -109,6 +109,7 @@ def get_rating(asset_id):
def update_ratings_quality(self, context):
user_preferences = bpy.context.preferences.addons['blenderkit'].preferences
api_key = user_preferences.api_key
+
headers = utils.get_headers(api_key)
asset = self.id_data
bkit_ratings = asset.bkit_ratings
diff --git a/blenderkit/search.py b/blenderkit/search.py
index 8406e47d..a51ff063 100644
--- a/blenderkit/search.py
+++ b/blenderkit/search.py
@@ -156,7 +156,7 @@ def timer_update():
preferences = bpy.context.preferences.addons['blenderkit'].preferences
if first_time: # first time
first_time = False
- if preferences.show_on_start or preferences.first_run:
+ if preferences.show_on_start:
# TODO here it should check if there are some results, and only open assetbar if this is the case, not search.
# if bpy.context.scene.get('search results') is None:
search()
@@ -167,6 +167,10 @@ def timer_update():
ui.add_report(text='BlenderKit Tip: ' + random.choice(rtips), timeout=12, color=colors.GREEN)
return 3.0
+ if preferences.first_run:
+ search()
+ preferences.first_run = False
+
check_clipboard()
global search_threads
@@ -765,7 +769,11 @@ class Searcher(threading.Thread):
if query.get('query') is None and query.get('category_subtree') == None:
# assumes no keywords and no category, thus an empty search that is triggered on start.
# orders by last core file upload
- requeststring += '+order:-last_upload'
+ if query.get('verification_status') == 'uploaded':
+ #for validators, sort uploaded from oldest
+ requeststring += '+order:created'
+ else:
+ requeststring += '+order:-last_upload'
elif query.get('author_id') is not None and utils.profile_is_validator():
requeststring += '+order:-created'
diff --git a/blenderkit/ui_panels.py b/blenderkit/ui_panels.py
index 1dbc7ab5..0dfa54ff 100644
--- a/blenderkit/ui_panels.py
+++ b/blenderkit/ui_panels.py
@@ -73,6 +73,11 @@ def draw_ratings(layout, context):
# this function should run only when asset was already checked to be existing
if asset == None:
return;
+
+ if not utils.user_logged_in():
+ label_multiline(layout, text='Please login or sign up '
+ 'to rate assets.')
+ return
bkit_ratings = asset.bkit_ratings
ratings.draw_rating(layout, bkit_ratings, 'rating_quality', 'Quality')
@@ -89,6 +94,14 @@ def draw_ratings(layout, context):
# op = row.operator("object.blenderkit_rating_upload", text="Send rating", icon='URL')
# return op
+def draw_not_logged_in(source):
+ title = "User not logged in"
+ def draw_message(source, context):
+ layout = source.layout
+ label_multiline(layout, text='Please login or sign up '
+ 'to upload files.')
+ draw_login_buttons(layout)
+ bpy.context.window_manager.popup_menu(draw_message, title=title, icon='INFO')
def draw_upload_common(layout, props, asset_type, context):
op = layout.operator("wm.url_open", text="Read upload instructions",
@@ -919,8 +932,10 @@ class OBJECT_MT_blenderkit_asset_menu(bpy.types.Menu):
op = layout.operator('view3d.blenderkit_search', text='Search Similar')
op.keywords = asset_data['name'] + ' ' + asset_data['description'] + ' ' + ' '.join(asset_data['tags'])
if asset_data.get('canDownload') != 0:
- if bpy.context.view_layer.objects.active is not None and ui_props.asset_type == 'MODEL':
+ if len(bpy.context.selected_objects)>0 and ui_props.asset_type == 'MODEL':
aob = bpy.context.active_object
+ if aob is None:
+ aob = bpy.context.selected_objects[0]
op = layout.operator('scene.blenderkit_download', text='Replace Active Models')
op.asset_type = ui_props.asset_type
op.asset_index = ui_props.active_index
diff --git a/blenderkit/upload.py b/blenderkit/upload.py
index 980fbf7f..2d38808a 100644
--- a/blenderkit/upload.py
+++ b/blenderkit/upload.py
@@ -750,6 +750,8 @@ class UploadOperator(Operator):
return result
+
+
def draw(self, context):
props = utils.get_upload_props()
layout = self.layout
@@ -774,6 +776,10 @@ class UploadOperator(Operator):
def invoke(self, context, event):
props = utils.get_upload_props()
+ if not utils.user_logged_in():
+ ui_panels.draw_not_logged_in(self)
+ return {'CANCELLED'}
+
if props.is_private == 'PUBLIC':
return context.window_manager.invoke_props_dialog(self)
else:
diff --git a/blenderkit/utils.py b/blenderkit/utils.py
index b9bd17f1..92e61de0 100644
--- a/blenderkit/utils.py
+++ b/blenderkit/utils.py
@@ -546,6 +546,13 @@ def dict_to_params(inputs, parameters=None):
return parameters
+def user_logged_in():
+ a = bpy.context.window_manager.get('bkit profile')
+ if a is not None:
+ return True
+ return False
+
+
def profile_is_validator():
a = bpy.context.window_manager.get('bkit profile')
if a is not None and a['user'].get('exmenu'):