Spaces:
Sleeping
Sleeping
drakosfire
commited on
Commit
•
88841c5
1
Parent(s):
1830328
Added employee block with same structure as owner block, worked flawlessly.
Browse files- block_builder.py +50 -1
block_builder.py
CHANGED
@@ -44,6 +44,20 @@ def build_blocks(user_input, block_id):
|
|
44 |
block_id = block_id + 1
|
45 |
list_of_blocks.append(owner_block)
|
46 |
owner_id += 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
return list_of_blocks
|
48 |
|
49 |
# Take in a specific item type and item, and return the html for that item
|
@@ -209,7 +223,8 @@ def build_store_properties_block(store_type,
|
|
209 |
{store_iterables_html}
|
210 |
{store_end_html}"""
|
211 |
return store_properties_block_html
|
212 |
-
|
|
|
213 |
def build_owner_block(owner, owner_id, owner_title_block, block_id):
|
214 |
# Owner block with values : Name, Race, Class, Description, Personality, Secrets, sd-prompt
|
215 |
|
@@ -248,6 +263,40 @@ def build_owner_block(owner, owner_id, owner_title_block, block_id):
|
|
248 |
"""
|
249 |
return owner_block_html
|
250 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
251 |
|
252 |
|
253 |
|
|
|
44 |
block_id = block_id + 1
|
45 |
list_of_blocks.append(owner_block)
|
46 |
owner_id += 1
|
47 |
+
employee_id = 1
|
48 |
+
# Iterate over employees and generate employee image and details block
|
49 |
+
employee_title = "Employee"
|
50 |
+
if len(user_input['store_employees']) > 1:
|
51 |
+
employee_title = "Employees"
|
52 |
+
employee_title_block = f"""<h2 id="employee">{employee_title}</h2>"""
|
53 |
+
for employee in user_input['store_employees']:
|
54 |
+
employee_image_block = build_image_block(employee['sd_prompt'], block_id)
|
55 |
+
block_id = block_id + 1
|
56 |
+
list_of_blocks.append(employee_image_block)
|
57 |
+
employee_block = build_employee_block(employee, employee_id, employee_title_block, block_id)
|
58 |
+
block_id = block_id + 1
|
59 |
+
list_of_blocks.append(employee_block)
|
60 |
+
employee_id += 1
|
61 |
return list_of_blocks
|
62 |
|
63 |
# Take in a specific item type and item, and return the html for that item
|
|
|
223 |
{store_iterables_html}
|
224 |
{store_end_html}"""
|
225 |
return store_properties_block_html
|
226 |
+
|
227 |
+
# Block of owner table
|
228 |
def build_owner_block(owner, owner_id, owner_title_block, block_id):
|
229 |
# Owner block with values : Name, Race, Class, Description, Personality, Secrets, sd-prompt
|
230 |
|
|
|
263 |
"""
|
264 |
return owner_block_html
|
265 |
|
266 |
+
# Block of employee table
|
267 |
+
def build_employee_block(employee, employee_id, employee_title_block, block_id):
|
268 |
+
# Employee block with name, role, species, description, personality, sd-prompt
|
269 |
+
# Process employee values into html
|
270 |
+
employee_name_html = process_into_html('Employee', employee['name'], block_id)
|
271 |
+
employee_role_html = process_into_html('Role', employee['role'], block_id)
|
272 |
+
employee_species_html = process_into_html('Species', employee['species'], block_id)
|
273 |
+
employee_description_html = process_into_html('Description', employee['description'], block_id)
|
274 |
+
employee_personality_html = process_into_html('Personality', employee['personality'], block_id)
|
275 |
+
# Build employee block html
|
276 |
+
|
277 |
+
employee_block_html = f""""""
|
278 |
+
employee_block_html += f"""<div class="block-item" data-block-id="{block_id}">"""
|
279 |
+
if employee_id == 1:
|
280 |
+
employee_block_html += employee_title_block
|
281 |
+
employee_block_html += f"""<h3 id="employee_{employee_id}">{employee['name']}</h3>
|
282 |
+
<table>
|
283 |
+
<thead>
|
284 |
+
<tr>
|
285 |
+
<th align="center"></th>
|
286 |
+
<th align="center"></th>
|
287 |
+
</tr>
|
288 |
+
</thead>
|
289 |
+
<tbody>
|
290 |
+
{employee_name_html}
|
291 |
+
{employee_role_html}
|
292 |
+
{employee_species_html}
|
293 |
+
{employee_description_html}
|
294 |
+
{employee_personality_html}
|
295 |
+
</tbody>
|
296 |
+
</table>
|
297 |
+
</div>
|
298 |
+
"""
|
299 |
+
return employee_block_html
|
300 |
|
301 |
|
302 |
|