Hi David,

I added the custom tag and pushed it yesterday:

http://git.yoctoproject.org/cgit/cgit.cgi/poky-contrib/commit/?h=ravi/all-tasks-feature&id=c04cbe928b0796a1a770399df7d10c7f7cb66ce7

You can see the usage of the tag here:

http://git.yoctoproject.org/cgit/cgit.cgi/poky-contrib/commit/?h=ravi/all-tasks-feature&id=844be60f5c5a73623a56a14689d9bbe6ee29a541

For the tag to be used, the projecttags has to be loaded in the file by calling:

{% load projecttags %}


Thanks,
Ravi
________________________________________
From: [email protected] [[email protected]] On 
Behalf Of Reyna, David [[email protected]]
Sent: Wednesday, January 15, 2014 1:34 AM
To: Damian, Alexandru
Cc: [email protected]
Subject: Re: [Toaster] DRY RUN [Review Request] 4299 "recipes: View detailed 
information about a recipe"

Hi Alex,

There is something seriously fragile about Django tags and filters.

1) When I try to use “simple_tag”, all I get is “Invalid block tag: 
'task_outcome_highlight', expected 'empty' or 'endfor', even for the most 
trivial tag:

@register.filter
def task_outcome_highlight(task)
    return 'class=error'

...and...

{% task_outcome_highlight task %}

2) I then tried filters. I first used a filter out of the Djago docs, and it 
worked.

WORKS:

@register.filter(name='cut')
def cut(value, arg):
    """Removes all values of arg from the given string"""
    return value.replace(arg, '')

...and...

{{ "1230456"|cut:"0" }}

3) However, if I make change to that filter, for example changing its name, I 
get nothing but filter format errors.

FAILS (when renamed to "cu"):

@register.filter(name='cu')
def cu (value, arg):
    """Removes all values of arg from the given string"""
    return value.replace(arg, '')

...and...

{{ "1230456"|cu:"0" }}

4) I have tried stopping and starting the server. If I rename the filter back 
to "cut", it will start working again.

I have spent hours on something that should be done in 10 minutes.

- David

========================

From: Damian, Alexandru [mailto:[email protected]]
Sent: Monday, January 13, 2014 5:43 AM
To: Reyna, David
Cc: Lerner, Dave; [email protected]
Subject: Re: [Toaster] DRY RUN [Review Request] 4299 "recipes: View detailed 
information about a recipe"

Hi,

I have comments about the content of the patch, as well.
a). models.py; I am not very fond of having display code in the models, because 
it breaks the MVC separation. The display code should live in the templates, 
e.g.

    {% if task.outcome == Task.OUTCOME_FAILED %}class=error{% elif %} ... 
{%endif%}
If this is repeated elsewhere, like in this particular case, you should define 
a new tag in ./bitbake/lib/toaster/toastergui/templatetags/projecttags.py that 
returns the code:
@register.simple_tag
def task_outcome_highlight(task):
    if task.outcome == Task.OUTCOME_EXISTING:
        ret = ''
  .... etc ...
and then use it in the template:  {% task_outcome_highlight task %}
b). html format; please don't use tabs; use 4-space instead of a tab; this 
makes for a nice consistency with the HTML code, and fits the HTML code in page 
better.

c). recipe.html; please extend "basebuildpage.html" which fills in the 
breadcrumb and all the layout for viewing pages in a build context. see 
configvars.html for an example.
d). recipes.html; the latest versions of the basetable_top will automatically 
generate correct table header based on the context description; please don't 
include your own table header, but edit the page context  to correctly set the 
table data; see the build view / build.html as a how-to guide.
Hope this helps,
Alex



_______________________________________________
toaster mailing list
[email protected]
https://lists.yoctoproject.org/listinfo/toaster
_______________________________________________
toaster mailing list
[email protected]
https://lists.yoctoproject.org/listinfo/toaster

Reply via email to