feat: admin client repository init on connection to an empty server

This commit is contained in:
Swann 2020-06-16 15:19:38 +02:00
parent e9029b1414
commit a201ae4ea6
No known key found for this signature in database
GPG Key ID: 5E0D936BD280E963
3 changed files with 16 additions and 15 deletions

@ -1 +1 @@
Subproject commit f3678045141af7a5ed8f59c26f2ae26983d05a8a
Subproject commit a2c7a4e8d979c668d6446134410a9cbda767b94d

View File

@ -139,9 +139,7 @@ class SessionStartOperator(bpy.types.Operator):
utils.clean_scene()
# regular client, no password needed
admin_pass = None
else:
for scene in bpy.data.scenes:
client.add(scene)
try:
client.connect(
id=settings.username,
@ -213,9 +211,10 @@ class SessionInitOperator(bpy.types.Operator):
utils.clean_scene()
for scene in bpy.data.scenes:
scene_uuid = client.add(scene)
client.commit(scene_uuid)
client.push(scene_uuid)
client.add(scene)
client.init()
return {"FINISHED"}

View File

@ -288,7 +288,7 @@ class SESSION_PT_user(bpy.types.Panel):
@classmethod
def poll(cls, context):
return operators.client and operators.client.state['STATE'] == 2
return operators.client and operators.client.state['STATE'] in [STATE_ACTIVE, STATE_LOBBY]
def draw(self, context):
layout = self.layout
@ -478,7 +478,7 @@ def draw_property(context, parent, property_uuid, level=0):
detail_item_box.label(text="", icon="DECORATE_LOCKED")
class SESSION_PT_outliner(bpy.types.Panel):
class SESSION_PT_repository(bpy.types.Panel):
bl_idname = "MULTIUSER_PROPERTIES_PT_panel"
bl_label = "Repository"
bl_space_type = 'VIEW_3D'
@ -489,7 +489,7 @@ class SESSION_PT_outliner(bpy.types.Panel):
def poll(cls, context):
return hasattr(context.window_manager, 'session') and \
operators.client and \
operators.client.state['STATE'] == 2
operators.client.state['STATE'] in [STATE_ACTIVE, STATE_LOBBY]
def draw_header(self, context):
self.layout.label(text="", icon='OUTLINER_OB_GROUP_INSTANCE')
@ -500,11 +500,13 @@ class SESSION_PT_outliner(bpy.types.Panel):
# Filters
settings = utils.get_preferences()
runtime_settings = context.window_manager.session
usr = operators.client.online_users.get(settings.username)
is_repository_init = operators.client.list()
session = operators.client
usr = session.online_users.get(settings.username)
row = layout.row()
if is_repository_init:
if session.state['STATE'] == STATE_ACTIVE:
flow = layout.grid_flow(
row_major=True,
columns=0,
@ -540,7 +542,7 @@ class SESSION_PT_outliner(bpy.types.Panel):
else:
row.label(text="Empty")
elif usr and usr['admin']:
elif session.state['STATE'] == STATE_LOBBY and usr and usr['admin']:
row.operator("session.init", icon='TOOL_SETTINGS', text="Init")
else:
row.label(text="Waiting for init")
@ -554,7 +556,7 @@ classes = (
SESSION_PT_settings_replication,
SESSION_PT_user,
SESSION_PT_services,
SESSION_PT_outliner,
SESSION_PT_repository,
)