Commit 5143ea9 [frontend] fix openSUSE name displaying + slight refactoring

6 files Authored and Committed by clime 12 days ago
[frontend] fix openSUSE name displaying + slight refactoring

    
 1 @@ -841,13 +841,6 @@
 2           return "{}-{}".format(self.os_release, self.os_version)
 3   
 4       @property
 5 -     def name_release_human(self):
 6 -         """
 7 -         Textual representation of name of this or release
 8 -         """
 9 -         return "{} {}".format(self.os_release, self.os_version)
10 - 
11 -     @property
12       def os(self):
13           """
14           Textual representation of the operating system name
 1 @@ -144,23 +144,24 @@
 2     {{ build_state_text(module.status | module_state_from_num) }}
 3   {% endmacro %}
 4   
 5 - {% macro chroot_to_os_logo(chroot) %}
 6 -   {% if chroot.logo %}
 7 -     <img style="height:1.8em" src="{{ url_for('static', filename="chroot_logodir/"+chroot.logo) }}" />
 8 -   {% endif %}
 9 -   {% if chroot.os_release == 'epel' %}
10 -     Epel for CentOS {{ chroot.os_version }}
11 -   {% elif chroot.os_release == 'opensuse-leap' %}
12 -     openSUSE Leap {{ chroot.os_version }}
13 -   {% elif chroot.os_release == 'opensuse' and chroot.os_version == 'tumbleweed' %}
14 + {% macro os_logo(logo_name) %}
15 +     {% if logo_name %}
16 +       <img style="height:1.8em" src="{{ url_for('static', filename="chroot_logodir/"+logo_name) }}" />
17 +     {% endif %}
18 + {% endmacro %}
19 + 
20 + {% macro friendly_os_name(os_release, os_version=None) %}
21 +   {% if os_release == 'epel' %}
22 +     Epel for CentOS {{ os_version }}
23 +   {% elif os_release == 'opensuse-leap' %}
24 +     openSUSE Leap {{ os_version }}
25 +   {% elif os_release == 'opensuse' and os_version == 'tumbleweed' %}
26       openSUSE Tumbleweed
27     {% else %}
28 -     {{ chroot.os_release | capitalize }} {{ chroot.os_version }}
29 +     {{ os_release | capitalize }} {{ os_version }}
30     {% endif %}
31   {% endmacro %}
32   
33 - 
34 - 
35   {% macro alert(message, type=None) %}
36     {% set alert_class_map = {
37           "error": "alert-danger",
 1 @@ -1,7 +1,7 @@
 2   {% extends "coprs/detail.html" %}
 3   
 4   {% from "coprs/_coprs_forms.html" import copr_legal_flag_form with context %}
 5 - {% from "_helpers.html" import chroot_to_os_logo, copr_name, copr_url, build_href, repo_file_href %}
 6 + {% from "_helpers.html" import os_logo, friendly_os_name, copr_name, copr_url, build_href, repo_file_href %}
 7   
 8   {% set selected_tab = "overview" %}
 9   
10 @@ -48,7 +48,8 @@
11         {% for repo in repos_info_list %}
12           <tr>
13             <td>
14 -             {{ chroot_to_os_logo(repo) }}
15 +             {{ os_logo(repo.logo) }}
16 +             {{ friendly_os_name(repo.os_release, repo.os_version) }}
17             </td>
18             <td>
19               {% for arch in repo.arch_list %}
20 @@ -61,7 +62,7 @@
21             </td>
22             <td class="rightmost">
23               <a class="btn btn-default btn-margin" href="{{ repo_file_href(copr, repo) }}">
24 -               <span class="pficon pficon-save"></span> {{ repo.name_release_human|capitalize }}
25 +               <span class="pficon pficon-save"></span> {{ friendly_os_name(repo.os_release, repo.os_version) }}
26               </a>
27               <small class="text-muted"> ({{ repo.dl_stat }} downloads) </small>
28             </td>
 1 @@ -2,7 +2,7 @@
 2   {% block title %}Project List{% endblock %}
 3   {% block header %}Project List{% endblock %}
 4   {% from "_helpers.html" import render_pagination, copr_details_href, copr_name, user_projects_panel %}
 5 - {% from "_helpers.html" import recent_builds_panel, task_queue_panel %}
 6 + {% from "_helpers.html" import recent_builds_panel, task_queue_panel, friendly_os_name %}
 7   {%block main_menu_projects %}active{% endblock %}
 8   {% block body %}
 9   <div class="row">
10 @@ -21,7 +21,7 @@
11             <ul class="list-inline text-muted">
12             {% for os in copr.active_chroots_grouped %}
13               <li>
14 -               <strong>{{os[0]|capitalize}}:</strong>
15 +               <strong>{{ friendly_os_name(os[0].split()[0], os[0].split()[1]) }}:</strong>
16                 <small>
17                 {% for arch in os[1] %}
18                   {{arch}}{% if not loop.last %}, {% endif %}
 1 @@ -2,7 +2,7 @@
 2   {% block title %}Project List{% endblock %}
 3   {% block header %}Project List{% endblock %}
 4   {% from "_helpers.html" import render_pagination, copr_details_href, copr_name, user_projects_panel %}
 5 - {% from "_helpers.html" import recent_builds_panel, task_queue_panel, recent_blog_panel %}
 6 + {% from "_helpers.html" import recent_builds_panel, task_queue_panel, recent_blog_panel, friendly_os_name %}
 7   {%block main_menu_projects %}active{% endblock %}
 8   {% block body %}
 9   <div class="row">
10 @@ -22,11 +22,11 @@
11               <ul class="list-inline text-muted">
12               {% for os in copr.active_chroots_grouped %}
13                 <li>
14 -                 <strong>{{os[0]|capitalize}}:</strong>
15 +                 <strong>{{ friendly_os_name(os[0].split()[0], os[0].split()[1]) }}:</strong>
16                   <small>
17                   {% for arch in os[1] %}
18 -                   {{arch}}{% if not loop.last %}, {% endif %}
19 -                 {%endfor%}
20 +                   {{ arch }}{% if not loop.last %}, {% endif %}
21 +                 {% endfor %}
22                   </small>
23                 </li>
24               {% endfor %}
1 @@ -326,7 +326,6 @@
2   
3               repos_info[chroot.name_release] = {
4                   "name_release": chroot.name_release,
5 -                 "name_release_human": chroot.name_release_human,
6                   "os_release": chroot.os_release,
7                   "os_version": chroot.os_version,
8                   "logo": logo,