only include "create doc" link if appropriate

This commit is contained in:
Frédéric Péters 2012-01-17 10:56:24 +01:00
parent 158428aadc
commit 424b6d3004
2 changed files with 11 additions and 3 deletions

View File

@ -1,7 +1,8 @@
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:tal="http://xml.zope.org/namespaces/tal"
tal:omit-tag=""
tal:define="href view/href">
tal:define="href view/href;
create_href view/create_href">
<a id="" class="" href="#" tal:condition="href"
tal:attributes="id view/id;
class view/klass;
@ -20,6 +21,9 @@
onkeydown view/onkeydown;
onkeyup view/onkeyup"><tal:block
condition="view/value" content="view/value"
/></a><span tal:condition="not: href" tal:content="view/value"></span>
<a tal:condition="not: href" tal:attributes="href view/create_href">(créer document)</a>
/></a>
<tal:block tal:condition="not: href">
<span tal:condition="not: href" tal:content="view/value"></span>
<a tal:condition="create_href" tal:attributes="href view/create_href">(créer document)</a>
</tal:block>
</html>

View File

@ -300,6 +300,10 @@ class MailIdWidget(TextWidget):
def create_href(self):
form_url = self.request.getURL()
from themis.config.utils import get_document_type_for_mail
document_type = get_document_type_for_mail(self.context)
if not document_type:
return None
return "%s/++widget++%s/@@createDoc" % (form_url, self.name)