UI: Improve multi OS display #205
@ -64,10 +64,12 @@ class Platform(CreatedModifiedMixin, models.Model):
|
|||||||
def get_by_slug(cls, slug: str):
|
def get_by_slug(cls, slug: str):
|
||||||
return cls.objects.filter(slug=slug).first()
|
return cls.objects.filter(slug=slug).first()
|
||||||
|
|
||||||
|
@property
|
||||||
def name_first_word(self):
|
def name_first_word(self):
|
||||||
"""Used for presentation in download_list."""
|
"""Used for presentation in download_list."""
|
||||||
return self.name.split(None, 1)[0]
|
return self.name.split(None, 1)[0]
|
||||||
|
|
||||||
|
@property
|
||||||
def name_rest(self):
|
def name_rest(self):
|
||||||
"""Used for presentation in download_list."""
|
"""Used for presentation in download_list."""
|
||||||
parts = self.name.split(None, 1)
|
parts = self.name.split(None, 1)
|
||||||
@ -718,6 +720,18 @@ class Version(CreatedModifiedMixin, TrackChangesMixin, models.Model):
|
|||||||
return file
|
return file
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
def get_supported_platforms(self):
|
||||||
|
supported_platforms = {}
|
||||||
|
for platform in self.platforms.all():
|
||||||
|
architectures = supported_platforms.get(platform.name_first_word, [])
|
||||||
|
architectures.append(platform.name_rest)
|
||||||
|
supported_platforms[platform.name_first_word] = architectures
|
||||||
|
result = []
|
||||||
|
for platform, architectures in sorted(supported_platforms.items()):
|
||||||
|
item = {'name': platform, 'architectures': architectures}
|
||||||
|
result.append(item)
|
||||||
|
return result
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_listed(self):
|
def is_listed(self):
|
||||||
# To be public, at least one version file must have a public status.
|
# To be public, at least one version file must have a public status.
|
||||||
|
@ -1,16 +1,18 @@
|
|||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
|
|
||||||
{% if version.platforms.all %}
|
{% with supported_platforms=version.get_supported_platforms %}
|
||||||
|
{% if supported_platforms %}
|
||||||
<div class="dl-row">
|
<div class="dl-row">
|
||||||
<div class="dl-col">
|
<div class="dl-col">
|
||||||
<dt>{% trans "Supported Platforms" %}</dt>
|
<dt>{% trans "Supported Platforms" %}</dt>
|
||||||
<dd>
|
<dd>
|
||||||
<ul class="list-style-none mb-0 ps-0">
|
<ul class="list-style-none mb-0 ps-0">
|
||||||
{% for p in version.platforms.all|dictsortreversed:"slug" %}
|
{% for item in supported_platforms|dictsortreversed:"name" %}
|
||||||
<li><i class="i-{{ p.name_first_word|lower }}"></i> {{p.name_first_word}} <span class="text-muted">{{ p.name_rest }}</span></li>
|
<li><i class="i-{{ item.name|lower }}"></i> {{ item.name }} <span class="text-muted">{{ item.architectures|join:', ' }}</span></li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
</dd>
|
</dd>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% endwith %}
|
||||||
|
Loading…
Reference in New Issue
Block a user