{% extends 'creme_core/bricks/base/list.html' %} {% load i18n creme_bricks creme_ctype polls_tags %} {% load and_op bool has_perm_to print_field mult not_op url from creme_core_tags %} {% block brick_extra_class %}{{block.super}} polls-list-brick polls-form-lines-brick{% endblock %} {% block brick_header_title %} {% brick_header_title title=title icon='poll' %} {% endblock %} {% block brick_header_actions %} {% has_perm_to change object as has_perm %} {% brick_header_action id='add' url='polls__create_form_line'|url:object.id label=_('New question') enabled=has_perm %} {% brick_header_action id='add' url='polls__create_form_section'|url:object.id label=_('New section') enabled=has_perm %} {% endblock %} {% block brick_content %} {% has_perm_to change object as has_perm %} {% ctype_for_naturalkey app_label='polls' model='pollformline' as line_ct %} {% ctype_for_naturalkey app_label='polls' model='pollformsection' as section_ct %} {% for node in nodes %}
{% if node.is_section %}
{% poll_node_number style node %}
{% print_field object=node field='name' %} {% print_field object=node field='body' %}
{% brick_action id='edit' url=node.get_edit_absolute_url label=_('Edit this section') class='poll-action' enabled=has_perm %} {% if not node.has_line %} {% brick_action id='delete' url='creme_core__delete_related_to_entity'|url:section_ct.id __id=node.id label=_('Delete this section') class='poll-action' enabled=has_perm %} {% endif %} {% brick_action id='add' url='polls__create_form_line_in_section'|url:node.id label=_('New question') class='poll-action' enabled=has_perm %} {% brick_action id='add' url='polls__create_child_form_section'|url:node.id label=_('New sub-section') class='poll-action' enabled=has_perm %}
{% elif node.disabled %} {# {% with no_deps=node.get_reversed_conditions|length_is:"0" %} #} {% with no_deps=node.get_reversed_conditions|length|bool|not_op %}
{% if node.number %}
{% poll_node_number style node %}
{% endif %}
{{node.question}}
{{node.poll_line_type.description}}
{% brick_action id='delete' url='creme_core__delete_related_to_entity'|url:line_ct.id __id=node.id label=_('Delete this question') class='poll-action' enabled=has_perm|and_op:no_deps %}
{% endwith %} {% else %} {# {% with number=node.number conditions=node.get_conditions no_deps=node.get_reversed_conditions|length_is:"0" %} #} {% with number=node.number conditions=node.get_conditions no_deps=node.get_reversed_conditions|length|bool|not_op %}
{% if number %}
{% poll_node_number style node %}
{% endif %}
{{node.question}}
{{node.poll_line_type.description}}
{% if number != 1 %}
{% if conditions %} {% translate 'Conditions' %} {% with OR_or_AND=node.verbose_conds_use_or %} {% for condition in conditions %}
{% if not forloop.first %}{{OR_or_AND}} : {% endif %}{% poll_line_condition nodes condition %}
{% endfor %} {% endwith %} {% endif %}
{% url 'polls__edit_form_line_conditions' node.id as edit_conds_url %} {% if conditions %} {% brick_action id='edit' url=edit_conds_url label=_('Edit conditions') class='poll-action' enabled=has_perm %} {% else %} {% brick_action id='add' url=edit_conds_url label=_('Add conditions') class='poll-action' enabled=has_perm %} {% endif %}
{% endif %} {% brick_action id='edit' url=node.get_edit_absolute_url class='poll-action' enabled=has_perm %} {% brick_action id='update' url='polls__disable_form_line'|url:node.id label=_('Disable this question') icon='cancel' confirm=_('Are you sure?') class='poll-action' enabled=has_perm|and_op:no_deps %} {% brick_action id='delete' url='creme_core__delete_related_to_entity'|url:line_ct.id __id=node.id label=_('Delete this question') class='poll-action' enabled=has_perm|and_op:no_deps %}
{% endwith %} {% endif %}
{% empty %}
{% translate 'No question or section for the moment' %}
{% endfor %} {% endblock %}