summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/toaster/toastergui/templatetags
diff options
context:
space:
mode:
authorElliot Smith <elliot.smith@intel.com>2015-10-02 08:14:42 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-10-16 14:59:59 +0100
commitda4c6144f1125ac94f1ba515f97a433a983b7662 (patch)
tree09f40037ea1bf5eca452d648aeeb8fa070540a9a /bitbake/lib/toaster/toastergui/templatetags
parentef6fc2bc1a4eeafdf5eda112ffb72bfed24b85d5 (diff)
downloadpoky-da4c6144f1125ac94f1ba515f97a433a983b7662.tar.gz
bitbake: toaster: Make the builds view the project page for "command line builds"
Command line builds don't have configuration or layers which can be manipulated in Toaster, so these pages shouldn't be visible. However, the configuration page is the default page for the project view (/project/X/), which isn't correct for the command line builds project. Modify all project page links across the application so that the command line builds project (aka the "default" project) always displays the builds tab. Add a project_url tag for templates which contains the logic determining where the URL for a project links to, based on whether it is the default project or not. [YOCTO #8231] (Bitbake rev: 3ea10f4c16a557e94781251f6776b13acb8e9eba) Signed-off-by: Elliot Smith <elliot.smith@intel.com> Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: brian avery <avery.brian@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/toaster/toastergui/templatetags')
-rw-r--r--bitbake/lib/toaster/toastergui/templatetags/project_url_tag.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/bitbake/lib/toaster/toastergui/templatetags/project_url_tag.py b/bitbake/lib/toaster/toastergui/templatetags/project_url_tag.py
new file mode 100644
index 0000000000..04770ac6a8
--- /dev/null
+++ b/bitbake/lib/toaster/toastergui/templatetags/project_url_tag.py
@@ -0,0 +1,34 @@
1from django import template
2from django.core.urlresolvers import reverse
3
4register = template.Library()
5
6def project_url(parser, token):
7 """
8 Create a URL for a project's main page;
9 for non-default projects, this is the configuration page;
10 for the default project, this is the project builds page
11 """
12 try:
13 tag_name, project = token.split_contents()
14 except ValueError:
15 raise template.TemplateSyntaxError(
16 "%s tag requires exactly one argument" % tag_name
17 )
18 return ProjectUrlNode(project)
19
20class ProjectUrlNode(template.Node):
21 def __init__(self, project):
22 self.project = template.Variable(project)
23
24 def render(self, context):
25 try:
26 project = self.project.resolve(context)
27 if project.is_default:
28 return reverse('projectbuilds', args=(project.id,))
29 else:
30 return reverse('project', args=(project.id,))
31 except template.VariableDoesNotExist:
32 return ''
33
34register.tag('project_url', project_url)