Importing theme

main
Bob Mottram 2023-02-10 19:41:31 +00:00
parent cc4808d8de
commit 0ee009c6b1
3 changed files with 25 additions and 7 deletions

View File

@ -6177,7 +6177,7 @@ class PubServer(BaseHTTPRequestHandler):
'instanceLogo',
'left_col_image', 'right_col_image',
'importFollows',
'import_theme'
'importTheme'
)
profile_media_types_uploaded = {}
for m_type in profile_media_types:
@ -6210,7 +6210,7 @@ class PubServer(BaseHTTPRequestHandler):
if m_type == 'instanceLogo':
filename_base = \
base_dir + '/accounts/login.temp'
elif m_type == 'import_theme':
elif m_type == 'importTheme':
if not os.path.isdir(base_dir + '/imports'):
os.mkdir(base_dir + '/imports')
filename_base = \
@ -6249,7 +6249,7 @@ class PubServer(BaseHTTPRequestHandler):
nickname)
continue
if m_type == 'import_theme':
if m_type == 'importTheme':
if nickname == admin_nickname or \
is_artist(base_dir, nickname):
if import_theme(base_dir, filename):
@ -7847,6 +7847,24 @@ class PubServer(BaseHTTPRequestHandler):
print('EX: unable to write imported follows ' +
filename_base)
if fields.get('importTheme'):
if not os.path.isdir(base_dir + '/imports'):
os.mkdir(base_dir + '/imports')
filename_base = \
base_dir + '/imports/newtheme.zip'
if os.path.isfile(filename_base):
try:
os.remove(filename_base)
except OSError:
print('EX: _profile_edit unable to delete ' +
filename_base)
if nickname == admin_nickname or \
is_artist(base_dir, nickname):
if import_theme(base_dir, filename_base):
print(nickname + ' uploaded a theme')
else:
print('Only admin or artist can import a theme')
# Save DM allowed instances list.
# The allow list for incoming DMs,
# if the .followDMs flag file exists

View File

@ -1539,8 +1539,8 @@ def _html_edit_profile_graphic_design(base_dir: str, translate: {}) -> str:
graphics_str += \
' <label class="labels">' + \
translate['Import Theme'] + '</label>\n'
graphics_str += ' <input type="file" id="import_theme" '
graphics_str += 'name="import_theme" '
graphics_str += ' <input type="file" id="importTheme" '
graphics_str += 'name="importTheme" '
graphics_str += 'accept="' + THEME_FORMATS + '">\n'
graphics_str += \
' <label class="labels">' + \

View File

@ -333,8 +333,8 @@ def html_theme_designer(base_dir: str,
export_import_str += \
' <label class="labels">' + \
translate['Import Theme'] + '</label>\n'
export_import_str += ' <input type="file" id="import_theme" '
export_import_str += 'name="import_theme" '
export_import_str += ' <input type="file" id="importTheme" '
export_import_str += 'name="importTheme" '
export_import_str += 'accept="' + theme_formats + '">\n'
export_import_str += \
' <label class="labels">' + \