# Path: goflow/apptools/models.py
# class ImageButton(models.Model):
#     '''
#     Mapping object between an "action" and an "Icon".
#     
#     ImageButton objects have also a textual field: label.
#     '''
#     action = models.SlugField(primary_key=True)
#     label = models.CharField(max_length=100)
#     icon = models.ForeignKey(Icon)
#     
#     @allow_tags
#     def graphic(self):
#         '''
#         generates an *img* html tag for html rendering
#         '''
#         return '<img name="image-%s" src="%s">' % (self.pk, self.icon.url)
#     
#     @allow_tags
#     def graphic_input(self):
#         '''
#         generates an *input* html tag with type=image for html rendering
#         '''
#         return '<input type=image name=image src="%s" value="%s" title="%s">' % (self.icon.url, self.pk, self.label)
#     
#     def __unicode__(self):
#         return self.label


from django.template import Library
from goflow.apptools.models import ImageButton
    if 'cancel_value' in context: sub_context['cancel_value'] = context['cancel_value']
    return sub_context
input_buttons = register.inclusion_tag("goflow/apptools/input_buttons.html", takes_context=True)(input_buttons)

@register.simple_tag
def image_button(action):
    '''
    This will insert submit image buttons in application templates.
    
    Usage::

        {% for value in ok_values %}
            {% image_button value %}
        {% endfor %}
        
        {% image_button cancel_value %}

    ok_values
        sequence of actions corresponding to transition conditions.
        Example: when the image button with the *edit* action is pressed,
        the transition such as *transition.condition = 'edit'* will be
        cadidate for workitem forwarding.

    cancel_value
        action correponding to cancel.
    
    An *action* (like *edit*, *new*, *exit*, ...) is a "slug" mapped to
    an image, or more exactly an *Icon* model; this mapping is implemented
    with *ImageButton* model.
    '''

# Path: goflow/apptools/models.py
# class ImageButton(models.Model):
#     '''
#     Mapping object between an "action" and an "Icon".
#     
#     ImageButton objects have also a textual field: label.
#     '''
#     action = models.SlugField(primary_key=True)
#     label = models.CharField(max_length=100)
#     icon = models.ForeignKey(Icon)
#     
#     @allow_tags
#     def graphic(self):
#         '''
#         generates an *img* html tag for html rendering
#         '''
#         return '<img name="image-%s" src="%s">' % (self.pk, self.icon.url)
#     
#     @allow_tags
#     def graphic_input(self):
#         '''
#         generates an *input* html tag with type=image for html rendering
#         '''
#         return '<input type=image name=image src="%s" value="%s" title="%s">' % (self.icon.url, self.pk, self.label)
#     
#     def __unicode__(self):
#         return self.label


# Path: goflow/apptools/templatetags/apptools_lib.py
from django.template import Library
from goflow.apptools.models import ImageButton

    if 'cancel_value' in context: sub_context['cancel_value'] = context['cancel_value']
    return sub_context
input_buttons = register.inclusion_tag("goflow/apptools/input_buttons.html", takes_context=True)(input_buttons)

@register.simple_tag
def image_button(action):
    '''
    This will insert submit image buttons in application templates.
    
    Usage::

        {% for value in ok_values %}
            {% image_button value %}
        {% endfor %}
        
        {% image_button cancel_value %}

    ok_values
        sequence of actions corresponding to transition conditions.
        Example: when the image button with the *edit* action is pressed,
        the transition such as *transition.condition = 'edit'* will be
        cadidate for workitem forwarding.

    cancel_value
        action correponding to cancel.
    
    An *action* (like *edit*, *new*, *exit*, ...) is a "slug" mapped to
    an image, or more exactly an *Icon* model; this mapping is implemented
    with *ImageButton* model.
    '''

    return ImageButton.objects.get(action=action).graphic_input()