Revision 270dd48d snf-astakos-app/astakos/im/widgets.py

b/snf-astakos-app/astakos/im/widgets.py
36 36
from django import forms
37 37
from django.utils.safestring import mark_safe
38 38
from django.utils import simplejson as json
39
from django.utils.translation import ugettext as _
39 40

  
40 41
from astakos.im.settings import RECAPTCHA_PUBLIC_KEY, RECAPTCHA_OPTIONS, \
41 42
        RECAPTCHA_USE_SSL
......
61 62
    is_hidden=True
62 63
    def render(self, *args, **kwargs):
63 64
        return ''
65

  
66
class ApprovalTermsWidget(forms.CheckboxInput):
67
    """
68
    A CheckboxInput class with a link to the approval terms.
69
    """
70
    def __init__(self, attrs=None, check_test=bool, terms_uri='', terms_label=_('Read the terms')):
71
        super(ApprovalTermsWidget, self).__init__(attrs, check_test)
72
        self.uri = terms_uri
73
        self.label = terms_label
74
    
75
    def render(self, name, value, attrs=None):
76
        html = super(ApprovalTermsWidget, self).render(name, value, attrs)
77
        return html + mark_safe('<a href=%s target="_blank">%s</a>' % (self.uri, self.label))

Also available in: Unified diff