diff options
Diffstat (limited to 'bitbake/lib/toaster/toastergui/tables.py')
-rw-r--r-- | bitbake/lib/toaster/toastergui/tables.py | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/bitbake/lib/toaster/toastergui/tables.py b/bitbake/lib/toaster/toastergui/tables.py index e2d23c1e81..dca2fa2913 100644 --- a/bitbake/lib/toaster/toastergui/tables.py +++ b/bitbake/lib/toaster/toastergui/tables.py | |||
@@ -23,6 +23,7 @@ from toastergui.widgets import ToasterTable | |||
23 | from orm.models import Recipe, ProjectLayer, Layer_Version, Machine, Project | 23 | from orm.models import Recipe, ProjectLayer, Layer_Version, Machine, Project |
24 | from orm.models import CustomImageRecipe, Package, Target, Build, LogMessage, Task | 24 | from orm.models import CustomImageRecipe, Package, Target, Build, LogMessage, Task |
25 | from orm.models import CustomImagePackage, Package_DependencyManager | 25 | from orm.models import CustomImagePackage, Package_DependencyManager |
26 | from orm.models import Distro | ||
26 | from django.db.models import Q, Max, Sum, Count, When, Case, Value, IntegerField | 27 | from django.db.models import Q, Max, Sum, Count, When, Case, Value, IntegerField |
27 | from django.conf.urls import url | 28 | from django.conf.urls import url |
28 | from django.core.urlresolvers import reverse, resolve | 29 | from django.core.urlresolvers import reverse, resolve |
@@ -1536,3 +1537,93 @@ class ProjectBuildsTable(BuildsTable): | |||
1536 | context['build_in_progress_none_completed'] = False | 1537 | context['build_in_progress_none_completed'] = False |
1537 | 1538 | ||
1538 | return context | 1539 | return context |
1540 | |||
1541 | |||
1542 | class DistrosTable(ToasterTable): | ||
1543 | """Table of Distros in Toaster""" | ||
1544 | |||
1545 | def __init__(self, *args, **kwargs): | ||
1546 | super(DistrosTable, self).__init__(*args, **kwargs) | ||
1547 | self.empty_state = "Toaster has no distro information for this project. Sadly, distro information cannot be obtained from builds, so this page will remain empty." | ||
1548 | self.title = "Compatible Distros" | ||
1549 | self.default_orderby = "name" | ||
1550 | |||
1551 | def get_context_data(self, **kwargs): | ||
1552 | context = super(DistrosTable, self).get_context_data(**kwargs) | ||
1553 | context['project'] = Project.objects.get(pk=kwargs['pid']) | ||
1554 | return context | ||
1555 | |||
1556 | def setup_filters(self, *args, **kwargs): | ||
1557 | project = Project.objects.get(pk=kwargs['pid']) | ||
1558 | |||
1559 | in_current_project_filter = TableFilter( | ||
1560 | "in_current_project", | ||
1561 | "Filter by project Distros" | ||
1562 | ) | ||
1563 | |||
1564 | in_project_action = TableFilterActionToggle( | ||
1565 | "in_project", | ||
1566 | "Distro provided by layers added to this project", | ||
1567 | ProjectFilters.in_project(self.project_layers) | ||
1568 | ) | ||
1569 | |||
1570 | not_in_project_action = TableFilterActionToggle( | ||
1571 | "not_in_project", | ||
1572 | "Distros provided by layers not added to this project", | ||
1573 | ProjectFilters.not_in_project(self.project_layers) | ||
1574 | ) | ||
1575 | |||
1576 | in_current_project_filter.add_action(in_project_action) | ||
1577 | in_current_project_filter.add_action(not_in_project_action) | ||
1578 | self.add_filter(in_current_project_filter) | ||
1579 | |||
1580 | def setup_queryset(self, *args, **kwargs): | ||
1581 | prj = Project.objects.get(pk = kwargs['pid']) | ||
1582 | self.queryset = prj.get_all_compatible_distros() | ||
1583 | self.queryset = self.queryset.order_by(self.default_orderby) | ||
1584 | |||
1585 | self.static_context_extra['current_layers'] = \ | ||
1586 | self.project_layers = \ | ||
1587 | prj.get_project_layer_versions(pk=True) | ||
1588 | |||
1589 | def setup_columns(self, *args, **kwargs): | ||
1590 | |||
1591 | self.add_column(title="Distro", | ||
1592 | hideable=False, | ||
1593 | orderable=True, | ||
1594 | field_name="name") | ||
1595 | |||
1596 | self.add_column(title="Description", | ||
1597 | field_name="description") | ||
1598 | |||
1599 | layer_link_template = ''' | ||
1600 | <a href="{% url 'layerdetails' extra.pid data.layer_version.id %}"> | ||
1601 | {{data.layer_version.layer.name}}</a> | ||
1602 | ''' | ||
1603 | |||
1604 | self.add_column(title="Layer", | ||
1605 | static_data_name="layer_version__layer__name", | ||
1606 | static_data_template=layer_link_template, | ||
1607 | orderable=True) | ||
1608 | |||
1609 | self.add_column(title="Git revision", | ||
1610 | help_text="The Git branch, tag or commit. For the layers from the OpenEmbedded layer source, the revision is always the branch compatible with the Yocto Project version you selected for this project", | ||
1611 | hidden=True, | ||
1612 | field_name="layer_version__get_vcs_reference") | ||
1613 | |||
1614 | wrtemplate_file_template = '''<code>conf/machine/{{data.name}}.conf</code> | ||
1615 | <a href="{{data.get_vcs_machine_file_link_url}}" target="_blank"><span class="glyphicon glyphicon-new-window"></i></a>''' | ||
1616 | |||
1617 | self.add_column(title="Distro file", | ||
1618 | hidden=True, | ||
1619 | static_data_name="templatefile", | ||
1620 | static_data_template=wrtemplate_file_template) | ||
1621 | |||
1622 | |||
1623 | self.add_column(title="Select", | ||
1624 | help_text="Sets the selected distro to the project", | ||
1625 | hideable=False, | ||
1626 | filter_name="in_current_project", | ||
1627 | static_data_name="add-del-layers", | ||
1628 | static_data_template='{% include "distro_btn.html" %}') | ||
1629 | |||