Skip to content
Snippets Groups Projects
Commit 04b7b345 authored by Samuel GAIST's avatar Samuel GAIST
Browse files

[toolchains][views] Fix handling of description and error

With python 3 we get bytes, ensure we are working on strings.
parent ab82f9ae
No related branches found
No related tags found
2 merge requests!2551.4.x,!249Web fixes
......@@ -32,11 +32,13 @@ from django.contrib.auth.decorators import login_required
from django.conf import settings
from django.contrib.auth.models import User
from django.db.models.functions import Coalesce
from django.utils import six
from .models import Toolchain
from ..team.models import Team
from ..reports.models import Report
from ..common.texts import Messages
from ..common.utils import ensure_string
from ..ui.templatetags.markup import restructuredtext
from beat.core import prototypes
......@@ -72,7 +74,7 @@ def create(request, name=None):
previous_version = previous_versions[0]
description = previous_version.description
description = ensure_string(previous_version.description)
parameters['toolchain_version'] = previous_version.version + 1
parameters['declaration'] = previous_version.declaration_string.replace('\n', '')
......@@ -103,7 +105,8 @@ def fork(request, author, name, version):
version=int(version)
)
description = fork_of.description
description = ensure_string(fork_of.description)
errors = ensure_string(fork_of.errors)
parameters = {'toolchain_author': request.user.username,
'toolchain_name': name,
......@@ -112,7 +115,7 @@ def fork(request, author, name, version):
'declaration': fork_of.declaration_string.replace('\n', ''),
'short_description': fork_of.short_description,
'description': description.replace('\n', '\\n'),
'errors': fork_of.errors.replace('\n', '\\n') if fork_of.errors is not None else '',
'errors': errors.replace('\n', '\\n'),
'edition': False,
'messages': Messages,
}
......@@ -139,7 +142,8 @@ def edit(request, author, name, version):
version=int(version)
)
description = toolchain.description
description = ensure_string(toolchain.description)
errors = ensure_string(toolchain.errors)
# Render the page
return render(request,
......@@ -151,7 +155,7 @@ def edit(request, author, name, version):
'short_description': toolchain.short_description,
'description': description.replace('\n', '\\n'),
'html_description': restructuredtext(description).replace('\n', ''),
'errors': toolchain.errors.replace('\n', '\\n') if toolchain.errors is not None else '',
'errors': errors.replace('\n', '\\n'),
'edition': True,
'messages': Messages,
})
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment