Improve validation messages #196
@ -59,6 +59,13 @@
|
||||
{% include "common/components/field.html" with field=form.source label='File' classes="js-agree-with-terms-trigger js-submit-form-file-input" %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% if form.errors %}
|
||||
<div>
|
||||
To catch and prevent most of these errors, it is recommended to build your extension using the <a class="text-underline" href="https://docs.blender.org/manual/en/dev/advanced/extensions/command_line_arguments.html#subcommand-build">command-line tool</a>.
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<div class="row">
|
||||
<div class="col mx-4 mt-4">
|
||||
{% include "common/components/field.html" with field=form.agreed_with_terms classes="js-agree-with-terms-trigger js-agree-with-terms-checkbox" %}
|
||||
|
@ -34,13 +34,13 @@ class FileForm(forms.ModelForm):
|
||||
'The manifest file should be at the top level of the archive, or one level deep.'
|
||||
),
|
||||
# TODO: surface TOML parsing errors?
|
||||
'invalid_manifest_toml': _('Could not parse the manifest file.'),
|
||||
'invalid_missing_init': _('An add-on should have an __init__.py file.'),
|
||||
'missing_or_multiple_theme_xml': _('A theme should have exactly one XML file.'),
|
||||
'invalid_manifest_toml': _('Manifest file contains invalid code.'),
|
||||
'invalid_missing_init': mark_safe(_('Add-on file missing: <strong>__init__.py</strong>.')),
|
||||
'missing_or_multiple_theme_xml': mark_safe(_('Themes can only contain <strong>one XML file</strong>.')),
|
||||
'invalid_zip_archive': msg_only_zip_files,
|
||||
'missing_manifest_toml': _('The manifest file is missing.'),
|
||||
'missing_wheel': _('A declared wheel is missing in the zip file, expected path: %(path)s'),
|
||||
'forbidden_filepaths': _('Archive contains forbidden files or directories: %(paths)s'),
|
||||
'missing_wheel': _('Python wheel missing: %(path)s'), # TODO <strong>%(path)s</strong>
|
||||
'forbidden_filepaths': _('Archive contains forbidden files or directories: %(paths)s'), #TODO <strong>%(paths)s</strong>
|
||||
}
|
||||
|
||||
class Meta:
|
||||
|
@ -173,7 +173,10 @@ def validate_file_list(toml_content, manifest_filepath, file_list):
|
||||
"""Check the files in in the archive against manifest."""
|
||||
error_codes = []
|
||||
type_slug = toml_content['type']
|
||||
if type_slug == 'theme':
|
||||
found_forbidden_filepaths = find_forbidden_filepaths(file_list)
|
||||
|
||||
# Special treatment for Mac, so the same problem (__MACOSX folders) doesn't lead to two errors showing.
|
||||
if type_slug == 'theme' and '__MACOSX/' not in found_forbidden_filepaths:
|
||||
dfelinto marked this conversation as resolved
Outdated
|
||||
theme_xmls = filter_paths_by_ext(file_list, '.xml')
|
||||
if len(list(theme_xmls)) != 1:
|
||||
error_codes.append('missing_or_multiple_theme_xml')
|
||||
@ -192,7 +195,6 @@ def validate_file_list(toml_content, manifest_filepath, file_list):
|
||||
error_codes.append(
|
||||
{'code': 'missing_wheel', 'params': {'path': expected_wheel_path}}
|
||||
)
|
||||
found_forbidden_filepaths = find_forbidden_filepaths(file_list)
|
||||
if found_forbidden_filepaths:
|
||||
error_codes.append(
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user
let's restructure this check a bit to prevent possible confusion in the future:
i.e. let's move the
and '__MACOSX/' not in found_forbidden_filepaths
part to theif len(list(theme_xmls)) != 1
lineand it's better to move the
found_forbidden_filepaths
logic closer to the variable declaration - i.e. let's move the whole block up, not just the variable declaration