UI: Improve multi OS display #205

Merged
Oleg-Komarov merged 40 commits from ui/multi-os into main 2024-07-16 07:24:07 +02:00
3 changed files with 22 additions and 21 deletions
Showing only changes of commit 90eb4fc246 - Show all commits

View File

@ -813,7 +813,7 @@ class Version(CreatedModifiedMixin, TrackChangesMixin, models.Model):
'url': self.get_download_url(file), 'url': self.get_download_url(file),
} }
] ]
platform2file = {} platform_slug2file = {}
for file in files: for file in files:
platforms = file.get_platforms() platforms = file.get_platforms()
if not platforms: if not platforms:
@ -821,16 +821,17 @@ class Version(CreatedModifiedMixin, TrackChangesMixin, models.Model):
f'data error: Version pk={self.pk} has multiple files, but File pk={file.pk} ' f'data error: Version pk={self.pk} has multiple files, but File pk={file.pk} '
f'is not platform-specific' f'is not platform-specific'
) )
for platform in platforms: for platform_slug in platforms:
platform2file[platform] = file platform_slug2file[platform_slug] = file
all_platforms_by_slug = {p.slug: p for p in Platform.objects.all()}
return [ return [
{ {
'name': self._get_download_name(file), 'name': self._get_download_name(file),
'platform': p, 'platform': all_platforms_by_slug.get(platform_slug),
'size': file.size_bytes, 'size': file.size_bytes,
'url': self.get_download_url(file), 'url': self.get_download_url(file),
} }
for p, file in platform2file.items() for platform_slug, file in platform_slug2file.items()
] ]
def get_build_list(self) -> List[dict]: def get_build_list(self) -> List[dict]:

View File

@ -288,15 +288,15 @@
<div class="text-center"> <div class="text-center">
<strong> <strong>
{% with platform=download_item.platform %} {% with platform=download_item.platform %}
{% if platform == "linux-x64" %} {% if platform.slug == "linux-x64" %}
Linux Linux
{% elif platform == "macos-arm64" %} {% elif platform.slug == "macos-arm64" %}
macOS <span class="fw-normal"> - Apple Silicon</span> macOS <span class="fw-normal"> - Apple Silicon</span>
{% elif platform == "macos-x64" %} {% elif platform.slug == "macos-x64" %}
macOS <span class="fw-normal"> - Intel</span> macOS <span class="fw-normal"> - Intel</span>
{% elif platform == "windows-arm64" %} {% elif platform.slug == "windows-arm64" %}
Windows <span class="fw-normal"> - ARM</span> Windows <span class="fw-normal"> - ARM</span>
{% elif platform == "windows-x64" %} {% elif platform.slug == "windows-x64" %}
Windows Windows
{% endif %} {% endif %}
{% endwith %} {% endwith %}
@ -321,15 +321,15 @@
<a class="d-flex dropdown-item justify-content-between" download="{{ download_item.name }}" href="{{ request.scheme }}://{{ request.get_host }}{{ download_item.url }}"> <a class="d-flex dropdown-item justify-content-between" download="{{ download_item.name }}" href="{{ request.scheme }}://{{ request.get_host }}{{ download_item.url }}">
<span> <span>
{% with platform=download_item.platform %} {% with platform=download_item.platform %}
{% if platform == "linux-x64" %} {% if platform.slug == "linux-x64" %}
<i class="i-linux"></i> Linux <i class="i-linux"></i> Linux
{% elif platform == "macos-arm64" %} {% elif platform.slug == "macos-arm64" %}
<i class="i-macos"></i> macOS <span class="ms-2 text-muted">Apple Silicon</span> <i class="i-macos"></i> macOS <span class="ms-2 text-muted">Apple Silicon</span>
{% elif platform == "macos-x64" %} {% elif platform.slug == "macos-x64" %}
<i class="i-macos"></i> macOS <span class="ms-2 text-muted">Intel</span> <i class="i-macos"></i> macOS <span class="ms-2 text-muted">Intel</span>
{% elif platform == "windows-arm64" %} {% elif platform.slug == "windows-arm64" %}
<i class="i-windows"></i> Windows <span class="ms-2 text-muted">ARM</span> <i class="i-windows"></i> Windows <span class="ms-2 text-muted">ARM</span>
{% elif platform == "windows-x64" %} {% elif platform.slug == "windows-x64" %}
<i class="i-windows"></i> Windows <i class="i-windows"></i> Windows
{% endif %} {% endif %}
{% endwith %} {% endwith %}
@ -348,7 +348,7 @@
<div class="btn-col text-center"> <div class="btn-col text-center">
{% for download_item in download_list %} {% for download_item in download_list %}
<a class="btn btn-flex btn-accent" href="{{ request.scheme }}://{{ request.get_host }}{{ download_item.url }}" download="{{ download_item.name }}"> <a class="btn btn-flex btn-accent" href="{{ request.scheme }}://{{ request.get_host }}{{ download_item.url }}" download="{{ download_item.name }}">
<i class="i-download"></i><span>{% trans 'Download' %} {{ extension.get_type_display }} {{ download_item.platform }}</span> <i class="i-download"></i><span>{% trans 'Download' %} {{ extension.get_type_display }} {{ download_item.platform.slug }}</span>
</a> </a>
<small class="mt-3">...and <a class="text-underline text-primary text-center" href="https://docs.blender.org/manual/en/dev/editors/preferences/extensions.html#install" target="_blank">Install from Disk</a></small> <small class="mt-3">...and <a class="text-underline text-primary text-center" href="https://docs.blender.org/manual/en/dev/editors/preferences/extensions.html#install" target="_blank">Install from Disk</a></small>
{% endfor %} {% endfor %}

View File

@ -118,15 +118,15 @@
<a href="{{ download_item.url }}" download="{{ download_item.name }}" class="btn btn-primary btn-block text-start"> <a href="{{ download_item.url }}" download="{{ download_item.name }}" class="btn btn-primary btn-block text-start">
<span> <span>
{% with platform=download_item.platform %} {% with platform=download_item.platform %}
{% if platform == "linux-x64" %} {% if platform.slug == "linux-x64" %}
<i class="i-linux me-1"></i> Linux <i class="i-linux me-1"></i> Linux
{% elif platform == "macos-arm64" %} {% elif platform.slug == "macos-arm64" %}
<i class="i-macos me-1"></i> macOS Apple Silicon <i class="i-macos me-1"></i> macOS Apple Silicon
{% elif platform == "macos-x64" %} {% elif platform.slug == "macos-x64" %}
<i class="i-macos me-1"></i> macOS Intel <i class="i-macos me-1"></i> macOS Intel
{% elif platform == "windows-arm64" %} {% elif platform.slug == "windows-arm64" %}
<i class="i-windows me-1"></i> Windows ARM <i class="i-windows me-1"></i> Windows ARM
{% elif platform == "windows-x64" %} {% elif platform.slug == "windows-x64" %}
<i class="i-windows me-1"></i> Windows <i class="i-windows me-1"></i> Windows
{% endif %} {% endif %}
{% endwith %} {% endwith %}