%endfor
%endif
%def>
<%def name="savebox(cancel_url, save_text=None, save_value='save')">
<%
save_text = save_text if save_text is not None else _("Save")
%>
%if cancel_url is not None:
${_("or")}
${_("cancel")}
%endif
%def>
<%def name="form_watch(entity, checked=False)">
%if can.watch.create():
<%
if entity:
checked = checked or (h.find_watch(entity) is not None)
%>
%endif
%def>
<%def name="watch(entity, id=None, show_skip=True)">
## FIXME: turn into an ajax call
%if c.user:
<%
if isinstance(entity, model.Page):
follow_text = _("Follow Norm")
elif isinstance(entity, model.Instance):
follow_text = _("Follow Instance")
elif isinstance(entity, model.Proposal):
follow_text = _("Follow Proposal")
elif isinstance(entity, model.Milestone):
follow_text = _("Follow Milestone")
elif isinstance(entity, model.User):
follow_text = _("Follow User")
elif isinstance(entity, model.Comment):
follow_text = _("Follow Comment")
elif isinstance(entity, model.Tag):
follow_text = _("Follow Tag")
else:
log.error('Unknown entity for watch button: %s' % entity)
if id is None:
id_attr = ''
else:
id_attr = 'id=%s'%id
skip = False
watch = h.find_watch(entity)
if watch and can.watch.delete(watch):
css_cls = "active"
text = _('Following')
hover_text = _('Unfollow')
tooltip = _('Disable email notifications.')
href = h.base_url('/watch/delete?%s' % h.url_token(),
query_params={'watch': str(watch.id)})
elif not watch and can.watch.create():
css_cls = ""
text = hover_text = follow_text
tooltip = _('Receive email notifications if changes occur.')
href = h.base_url('/watch/create?%s' % h.url_token(),
query_params={'ref': str(h.make_watch(entity))})
else:
skip = True
%>
%if skip:
%if show_skip:
<%doc>
placeholder div to fill the space if we cannot render a widget.
FIXME: What if a user is authenticated, but is not allowed
to watch/unwatch
%doc>
%def>
<%def name="category_select(id, toplevel_question, categories, selected=None)">
<% h.need.select_hierarchy %>
%def>
<%def name="proposal_sort_order(name, sorting_orders, include_empty=True, default=None)">
%def>
## Makes sure the rebindCameFrom javascript function is only called if the patched target wouldn't also lead to a 403.
## If the rebindCameFrom function isn't called, we usually (in these cases) redirect to the page we came from.
<%def name="add_patch_camefrom_class()">${u'' if c.instance and c.instance.requires_valid_email() else u'patch_camefrom'}%def>