From 18b843223df65b40bf77cb3c57a3824e2812647b Mon Sep 17 00:00:00 2001 From: Vilem Duha <vilem.duha@gmail.com> Date: Tue, 28 May 2019 15:25:00 +0200 Subject: [PATCH] BlenderKit: Change private flag to be an ENUM, so it can be expanded. checks for private quota separately obviously still not computed on production server. show profile panel --- blenderkit/__init__.py | 18 +++++++++++++++--- blenderkit/search.py | 4 +++- blenderkit/ui_panels.py | 29 ++++++++++++++--------------- blenderkit/upload.py | 4 ++-- 4 files changed, 34 insertions(+), 21 deletions(-) diff --git a/blenderkit/__init__.py b/blenderkit/__init__.py index 003008b48..07062b03c 100644 --- a/blenderkit/__init__.py +++ b/blenderkit/__init__.py @@ -449,10 +449,22 @@ class BlenderKitCommonUploadProps(object): default='royalty_free', description='License. Please read our help for choosing the right licenses', ) - is_private: BoolProperty(name="Asset is Private", - description="If not marked private, your asset will go into the validation process automatically\n" + + is_private: EnumProperty( + name="Thumbnail Style", + items=( + ('PRIVATE', 'Private', "You asset will be hidden to public. The private assets are limited by a quota."), + ('PUBLIC', 'Public', '"Your asset will go into the validation process automatically') + ), + description="If not marked private, your asset will go into the validation process automatically\n" "Private assets are limited by quota.", - default=False) + default="PUBLIC", + ) + + # is_private: BoolProperty(name="Asset is Private", + # description="If not marked private, your asset will go into the validation process automatically\n" + # "Private assets are limited by quota.", + # default=False) is_free: BoolProperty(name="Free for Everyone", description="You consent you want to release this asset as free for everyone", diff --git a/blenderkit/search.py b/blenderkit/search.py index 2ab0ec524..e95cbee16 100644 --- a/blenderkit/search.py +++ b/blenderkit/search.py @@ -576,9 +576,11 @@ def write_profile(adata): # we have to convert to MB here, numbers too big for python int type if user.get('sumAssetFilesSize') is not None: user['sumAssetFilesSize'] /= (1024 * 1024) + if user.get('sumPrivateAssetFilesSize') is not None: user['sumPrivateAssetFilesSize'] /= (1024 * 1024) + if user.get('remainingPrivateQuota') is not None: user['remainingPrivateQuota'] /= (1024 * 1024) - + bpy.context.window_manager['bkit profile'] = adata diff --git a/blenderkit/ui_panels.py b/blenderkit/ui_panels.py index 759e9c238..552516a41 100644 --- a/blenderkit/ui_panels.py +++ b/blenderkit/ui_panels.py @@ -134,8 +134,8 @@ def draw_upload_common(layout, props, asset_type, context): if asset_type == 'MODEL' and props.subcategory != '': # by now block this for other asset types. layout.prop(props, 'subcategory') - layout.prop(props, 'is_private') - if not props.is_private: + layout.prop(props, 'is_private', expand=True) + if props.is_private == 'PUBLIC': layout.prop(props, 'license') @@ -394,10 +394,8 @@ class VIEW3D_PT_blenderkit_profile(Panel): @classmethod def poll(cls, context): - user_preferences = bpy.context.preferences.addons['blenderkit'].preferences - if user_preferences.enable_oauth: - return True - return False + + return True def draw(self, context): # draw asset properties here @@ -411,9 +409,9 @@ class VIEW3D_PT_blenderkit_profile(Panel): return if len(user_preferences.api_key) < 20: - layout.operator("wm.blenderkit_login", text="Login/ Sign up", - icon='URL') - + if user_preferences.enable_oauth: + layout.operator("wm.blenderkit_login", text="Login/ Sign up", + icon='URL') else: me = bpy.context.window_manager.get('bkit profile') if me is not None: @@ -426,8 +424,9 @@ class VIEW3D_PT_blenderkit_profile(Panel): layout.label(text='Remaining private storage: %i Mb' % (me['remainingPrivateQuota'])) layout.operator("wm.url_open", text="See my uploads", icon='URL').url = paths.BLENDERKIT_USER_ASSETS - layout.operator("wm.blenderkit_logout", text="Logout", - icon='URL') + if user_preferences.enable_oauth: + layout.operator("wm.blenderkit_logout", text="Logout", + icon='URL') def draw_panel_model_rating(self, context): @@ -802,11 +801,11 @@ class VIEW3D_PT_blenderkit_downloads(Panel): row.label(text=asset_data['name']) row.label(text=str(int(tcom.progress)) + ' %') row.operator('scene.blenderkit_download_kill', text='', icon='CANCEL') - if tcom.passargs.get('retry_counter',0)>0: + if tcom.passargs.get('retry_counter', 0) > 0: row = layout.row() - row.label(text = 'failed. retrying ... ', icon='ERROR') - row.label(text = str(tcom.passargs["retry_counter"])) - + row.label(text='failed. retrying ... ', icon='ERROR') + row.label(text=str(tcom.passargs["retry_counter"])) + layout.separator() diff --git a/blenderkit/upload.py b/blenderkit/upload.py index 06afd1ef6..30e707d9a 100644 --- a/blenderkit/upload.py +++ b/blenderkit/upload.py @@ -446,7 +446,7 @@ def get_upload_data(self, context, asset_type): upload_data["category"] = props.subcategory upload_data["license"] = props.license upload_data["isFree"] = props.is_free - upload_data["isPrivate"] = props.is_private + upload_data["isPrivate"] = props.is_private == 'PRIVATE' upload_data["token"] = user_preferences.api_key if props.asset_base_id != '': @@ -503,7 +503,7 @@ def get_upload_location(props): def check_storage_quota(props): - if not props.is_private: + if props.is_private =='PUBLIC': return True profile = bpy.context.window_manager.get('bkit profile') -- GitLab