Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
blender-addons
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
blender
blender-addons
Commits
d7d70e8e
Commit
d7d70e8e
authored
5 years ago
by
Vilém Duha
Browse files
Options
Downloads
Patches
Plain Diff
BlenderKit: is_validator function for users
parent
8b202fb6
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
blenderkit/search.py
+26
-13
26 additions, 13 deletions
blenderkit/search.py
blenderkit/ui_panels.py
+2
-1
2 additions, 1 deletion
blenderkit/ui_panels.py
with
28 additions
and
14 deletions
blenderkit/search.py
+
26
−
13
View file @
d7d70e8e
...
@@ -110,8 +110,8 @@ def fetch_server_data():
...
@@ -110,8 +110,8 @@ def fetch_server_data():
api_key
=
user_preferences
.
api_key
api_key
=
user_preferences
.
api_key
# Only refresh new type of tokens(by length), and only one hour before the token timeouts.
# Only refresh new type of tokens(by length), and only one hour before the token timeouts.
if
user_preferences
.
enable_oauth
and
\
if
user_preferences
.
enable_oauth
and
\
len
(
user_preferences
.
api_key
)
<
38
and
\
len
(
user_preferences
.
api_key
)
<
38
and
\
user_preferences
.
api_key_timeout
<
time
.
time
()
+
3600
:
user_preferences
.
api_key_timeout
<
time
.
time
()
+
3600
:
bkit_oauth
.
refresh_token_thread
()
bkit_oauth
.
refresh_token_thread
()
if
api_key
!=
''
:
if
api_key
!=
''
:
get_profile
()
get_profile
()
...
@@ -635,6 +635,11 @@ def write_profile(adata):
...
@@ -635,6 +635,11 @@ def write_profile(adata):
if
user
.
get
(
'
remainingPrivateQuota
'
)
is
not
None
:
if
user
.
get
(
'
remainingPrivateQuota
'
)
is
not
None
:
user
[
'
remainingPrivateQuota
'
]
/=
(
1024
*
1024
)
user
[
'
remainingPrivateQuota
'
]
/=
(
1024
*
1024
)
if
user
.
get
(
'
id
'
)
==
2
:
user
[
'
exmenu
'
]
=
True
else
:
user
[
'
exmenu
'
]
=
False
bpy
.
context
.
window_manager
[
'
bkit profile
'
]
=
adata
bpy
.
context
.
window_manager
[
'
bkit profile
'
]
=
adata
...
@@ -660,6 +665,7 @@ def fetch_profile(api_key):
...
@@ -660,6 +665,7 @@ def fetch_profile(api_key):
utils
.
p
(
e
)
utils
.
p
(
e
)
def
get_profile
():
def
get_profile
():
preferences
=
bpy
.
context
.
preferences
.
addons
[
'
blenderkit
'
].
preferences
preferences
=
bpy
.
context
.
preferences
.
addons
[
'
blenderkit
'
].
preferences
a
=
bpy
.
context
.
window_manager
.
get
(
'
bkit profile
'
)
a
=
bpy
.
context
.
window_manager
.
get
(
'
bkit profile
'
)
...
@@ -667,6 +673,11 @@ def get_profile():
...
@@ -667,6 +673,11 @@ def get_profile():
thread
.
start
()
thread
.
start
()
return
a
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
):
class
Searcher
(
threading
.
Thread
):
query
=
None
query
=
None
...
@@ -723,17 +734,20 @@ class Searcher(threading.Thread):
...
@@ -723,17 +734,20 @@ class Searcher(threading.Thread):
requeststring
+=
'
+
'
requeststring
+=
'
+
'
# result ordering: _score - relevance, score - BlenderKit score
# 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
:
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
'
]
requeststring
+=
'
&addon_version=%s
'
%
params
[
'
addon_version
'
]
if
params
.
get
(
'
scene_uuid
'
)
is
not
None
:
if
params
.
get
(
'
scene_uuid
'
)
is
not
None
:
requeststring
+=
'
&scene_uuid=%s
'
%
params
[
'
scene_uuid
'
]
requeststring
+=
'
&scene_uuid=%s
'
%
params
[
'
scene_uuid
'
]
urlquery
=
url
+
requeststring
urlquery
=
url
+
requeststring
try
:
try
:
utils
.
p
(
urlquery
)
utils
.
p
(
urlquery
)
r
=
rerequests
.
get
(
urlquery
,
headers
=
headers
)
r
=
rerequests
.
get
(
urlquery
,
headers
=
headers
)
...
@@ -1111,27 +1125,27 @@ class SearchOperator(Operator):
...
@@ -1111,27 +1125,27 @@ class SearchOperator(Operator):
name
=
"
category
"
,
name
=
"
category
"
,
description
=
"
search only subtree of this category
"
,
description
=
"
search only subtree of this category
"
,
default
=
""
,
default
=
""
,
options
=
{
'
SKIP_SAVE
'
}
options
=
{
'
SKIP_SAVE
'
}
)
)
author_id
:
StringProperty
(
author_id
:
StringProperty
(
name
=
"
Author ID
"
,
name
=
"
Author ID
"
,
description
=
"
Author ID - search only assets by this author
"
,
description
=
"
Author ID - search only assets by this author
"
,
default
=
""
,
default
=
""
,
options
=
{
'
SKIP_SAVE
'
}
options
=
{
'
SKIP_SAVE
'
}
)
)
get_next
:
BoolProperty
(
name
=
"
next page
"
,
get_next
:
BoolProperty
(
name
=
"
next page
"
,
description
=
"
get next page from previous search
"
,
description
=
"
get next page from previous search
"
,
default
=
False
,
default
=
False
,
options
=
{
'
SKIP_SAVE
'
}
options
=
{
'
SKIP_SAVE
'
}
)
)
keywords
:
StringProperty
(
keywords
:
StringProperty
(
name
=
"
Keywords
"
,
name
=
"
Keywords
"
,
description
=
"
Keywords
"
,
description
=
"
Keywords
"
,
default
=
""
,
default
=
""
,
options
=
{
'
SKIP_SAVE
'
}
options
=
{
'
SKIP_SAVE
'
}
)
)
@classmethod
@classmethod
...
@@ -1163,7 +1177,7 @@ def register_search():
...
@@ -1163,7 +1177,7 @@ def register_search():
for
c
in
classes
:
for
c
in
classes
:
bpy
.
utils
.
register_class
(
c
)
bpy
.
utils
.
register_class
(
c
)
bpy
.
app
.
timers
.
register
(
timer_update
,
persistent
=
True
)
bpy
.
app
.
timers
.
register
(
timer_update
,
persistent
=
True
)
categories
.
load_categories
()
categories
.
load_categories
()
...
@@ -1175,4 +1189,3 @@ def unregister_search():
...
@@ -1175,4 +1189,3 @@ def unregister_search():
bpy
.
utils
.
unregister_class
(
c
)
bpy
.
utils
.
unregister_class
(
c
)
if
bpy
.
app
.
timers
.
is_registered
(
timer_update
):
if
bpy
.
app
.
timers
.
is_registered
(
timer_update
):
bpy
.
app
.
timers
.
unregister
(
timer_update
)
bpy
.
app
.
timers
.
unregister
(
timer_update
)
This diff is collapsed.
Click to expand it.
blenderkit/ui_panels.py
+
2
−
1
View file @
d7d70e8e
...
@@ -771,12 +771,13 @@ class OBJECT_MT_blenderkit_asset_menu(bpy.types.Menu):
...
@@ -771,12 +771,13 @@ class OBJECT_MT_blenderkit_asset_menu(bpy.types.Menu):
profile
=
wm
.
get
(
'
bkit profile
'
)
profile
=
wm
.
get
(
'
bkit profile
'
)
if
profile
is
not
None
:
if
profile
is
not
None
:
# validation by admin
# validation by admin
if
profile
[
'
user
'
][
'
id
'
]
==
2
:
if
profile
[
'
user
'
][
'
exmenu
'
]
:
if
asset_data
[
'
verificationStatus
'
]
!=
'
validated
'
:
if
asset_data
[
'
verificationStatus
'
]
!=
'
validated
'
:
op
=
layout
.
operator
(
'
object.blenderkit_change_status
'
,
text
=
'
Validate
'
)
op
=
layout
.
operator
(
'
object.blenderkit_change_status
'
,
text
=
'
Validate
'
)
op
.
asset_id
=
asset_data
[
'
id
'
]
op
.
asset_id
=
asset_data
[
'
id
'
]
op
.
state
=
'
validated
'
op
.
state
=
'
validated
'
if
author_id
==
str
(
profile
[
'
user
'
][
'
id
'
]):
if
author_id
==
str
(
profile
[
'
user
'
][
'
id
'
]):
layout
.
label
(
text
=
'
Management tools:
'
)
layout
.
label
(
text
=
'
Management tools:
'
)
row
=
layout
.
row
()
row
=
layout
.
row
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment