The proper way to get a display-able value
in Django is to use a model method instead of clutter
the template with if/else.
[YOCTO #5641]
(Bitbake rev:
bb21b71dab70db163b804c7ebf27b85c59a39112)
Signed-off-by: Alexandru DAMIAN <alexandru.damian@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
def get_related_setscene(self):
return Task.objects.related_setscene(self)
+ def get_executed_display(self):
+ if self.task_executed:
+ return "Executed"
+ return "Not Executed"
+
build = models.ForeignKey(Build, related_name='task_build')
order = models.IntegerField(null=True)
task_executed = models.BooleanField(default=False) # True means Executed, False means Not/Executed
<i class="icon-question-sign get-help hover-help" title="This task fetches the source code"></i>
</td>
- {% if task.task_executed %}
- <td><a {{ task|task_color }} href="{% url "task" build.pk task.pk %}">Executed</a></td>
- {% else %}
- <td><a {{ task|task_color }} href="{% url "task" build.pk task.pk %}">Prebuilt</a></td>
- {% endif %}
+ <td><a {{ task|task_color }} href="{% url "task" build.pk task.pk %}">{{task.get_executed_display}}</a></td>
<td><a {{ task|task_color }} href="{% url "task" build.pk task.pk %}">{{task.get_outcome_display}}</a></td>
<td>
<a href="{%url "task" build.pk task.pk%} ">{{task.task_name}}</a>
</td>
<td class="executed">
- <a href="{%url "task" build.pk task.pk%} ">
- {% if task.task_executed %}
- Executed
- {% else %}
- Not executed
- {% endif %}
- </a>
+ <a href="{%url "task" build.pk task.pk%} ">{{task.get_executed_display}}</a>
</td>
<td class="outcome">
<a href="{%url "task" build.pk task.pk%} ">{{task.get_outcome_display}}</a>