def render(self, name, value, attrs=None): """Render the custom widget.""" substitutions = { 'input_text': self.input_text, 'clear_template': '', 'clear_checkbox_label': self.clear_checkbox_label, } template = '%(input)s' substitutions['input'] = Input.render(self, name, value, attrs) if value and hasattr(value, "url"): template = ('%(initial)s %(clear_template)s<br />%(input_text)s: ' '%(input)s') substitutions['initial'] = ( '<img class="img-responsive" src="%s" alt="%s"/>' % ( escape(value.url), escape(force_unicode(value)))) if not self.is_required: checkbox_name = self.clear_checkbox_name(name) checkbox_id = self.clear_checkbox_id(checkbox_name) substitutions['clear_checkbox_name'] = conditional_escape( checkbox_name) substitutions['clear_checkbox_id'] = conditional_escape( checkbox_id) substitutions['clear'] = CheckboxInput().render( checkbox_name, False, attrs={'id': checkbox_id}) substitutions['clear_template'] = \ self.template_with_clear % substitutions return mark_safe(template % substitutions)
def render(self, name, value, attrs=None): substitutions = { 'initial_text': self.initial_text, 'input_text': self.input_text, 'clear_template': '', 'clear_checkbox_label': '', } template = '%(input)s' substitutions['input'] = Input.render(self, name, value, attrs) clear_template = '<div class="remove-image"><div class="remove-image btn btn-primary">Remove image</div></div><div class="image-removed">Image removed. Please click Submit to save your changes.</div>' + self.template_with_clear if value and hasattr(value, "url"): template = self.template_with_initial substitutions['initial'] = ('<div class="logo-image-container"><img class="logo-image" src="%s" alt="%s"/></div>' % (escape(value.url), escape(force_unicode(value)))) if not self.is_required: checkbox_name = self.clear_checkbox_name(name) checkbox_id = self.clear_checkbox_id(checkbox_name) substitutions['clear_checkbox_name'] = conditional_escape(checkbox_name) substitutions['clear_checkbox_id'] = conditional_escape(checkbox_id) substitutions['clear'] = CheckboxInput().render(checkbox_name, False, attrs={'id': checkbox_id}) substitutions['clear_template'] = clear_template % substitutions return mark_safe(template % substitutions)
def render(self, name, value, attrs=None): substitutions = { #uncomment to get 'Currently' 'initial_text': "", # self.initial_text, #'input_text': self.input_text, 'clear_template': '', #'clear_checkbox_label': self.clear_checkbox_label, } template = '%(input)s' substitutions['input'] = Input.render(self, name, value, attrs) if value and hasattr(value, "url"): #template = self.template_with_initial substitutions['initial'] = ( '<img src="%s" alt="%s" width="80" height="80"/>' % (escape(value.url), escape(force_text(value)))) if not self.is_required: checkbox_name = self.clear_checkbox_name(name) checkbox_id = self.clear_checkbox_id(checkbox_name) substitutions['clear_checkbox_name'] = conditional_escape( checkbox_name) substitutions['clear_checkbox_id'] = conditional_escape( checkbox_id) substitutions['clear'] = CheckboxInput().render( checkbox_name, False, attrs={'id': checkbox_id}) substitutions['clear_template'] = (self.template_with_clear % substitutions) return mark_safe(template % substitutions)
def render(self, name, value, attrs=None): substitutions = { #uncomment to get 'Currently' 'initial_text': "", # self.initial_text, 'input_text': self.input_text, 'clear_template': '', 'clear_checkbox_label': self.clear_checkbox_label, } template = '%(input)s' substitutions['input'] = Input.render(self, name, value, attrs) if value and hasattr(value, "url"): template = self.template_with_initial substitutions['initial'] = ( '<img src="%s" alt="%s"/>' % (escape(value.url), escape(force_unicode(value)))) if not self.is_required: checkbox_name = self.clear_checkbox_name(name) checkbox_id = self.clear_checkbox_id(checkbox_name) substitutions['clear_checkbox_name'] = conditional_escape( checkbox_name) substitutions['clear_checkbox_id'] = conditional_escape( checkbox_id) substitutions['clear'] = CheckboxInput().render( checkbox_name, False, attrs={'id': checkbox_id}) substitutions[ 'clear_template'] = self.template_with_clear % substitutions return mark_safe(template % substitutions)
def render(self, name, value, attrs=None): """Render the custom widget.""" substitutions = { 'input_text': self.input_text, 'clear_template': '', 'clear_checkbox_label': self.clear_checkbox_label, } template = '%(input)s' substitutions['input'] = Input.render(self, name, value, attrs) if value and hasattr(value, "url"): template = ('%(initial)s %(clear_template)s<br />%(input_text)s: ' '%(input)s') substitutions['initial'] = ( '<img class="img-responsive" src="%s" alt="%s"/>' % (escape(value.url), escape(force_unicode(value)))) if not self.is_required: checkbox_name = self.clear_checkbox_name(name) checkbox_id = self.clear_checkbox_id(checkbox_name) substitutions['clear_checkbox_name'] = conditional_escape( checkbox_name) substitutions['clear_checkbox_id'] = conditional_escape( checkbox_id) substitutions['clear'] = CheckboxInput().render( checkbox_name, False, attrs={'id': checkbox_id}) substitutions['clear_template'] = \ self.template_with_clear % substitutions return mark_safe(template % substitutions)
def render(self, name, value, attrs=None): id_for_label = self.id_for_label(attrs.get('id')) substitutions = { 'initial_text': self.initial_text, 'input_text': self.input_text, 'clear_template': '', 'clear_checkbox_label': self.clear_checkbox_label, # We need the id, so that clicking in the image triggers the "Open file" native window 'id_for_label': id_for_label, # 'img_id': id_for_label + '_img', 'initial': self.format_value(value), } template = '%(input)s' substitutions['input'] = Input.render( self, name, value, attrs) # call Input.render directly if self.is_initial(value): template = self.template_with_initial # substitutions.update(self.get_template_substitution_values(value)) if not self.is_required: checkbox_name = self.clear_checkbox_name(name) checkbox_id = self.clear_checkbox_id(checkbox_name) substitutions['clear_checkbox_name'] = conditional_escape( checkbox_name) substitutions['clear_checkbox_id'] = conditional_escape( checkbox_id) substitutions['clear'] = CheckboxInput().render( checkbox_name, False, attrs={'id': checkbox_id}) substitutions[ 'clear_template'] = self.template_with_clear % substitutions # substitutions['initial'] = conditional_escape(self.format_value(value)) return mark_safe(template % substitutions)
def render(self, name, value, attrs=None): substitutions = { 'initial_text': self.initial_text, 'input_text': self.input_text, 'clear_template': '', 'clear_checkbox_label': '', } template = '%(input)s' substitutions['input'] = Input.render(self, name, value, attrs) return mark_safe(template % substitutions)
def render(self, name, value, attrs=None): substitutions = { 'initial_text': 'Current choice', 'input_text': self.input_text, 'clear_template': '', 'clear_checkbox_label': self.clear_checkbox_label, } template = '%(input)s' substitutions['input'] = Input.render(self, name, value, attrs) if value and hasattr(value, "url"): template = self.template_with_initial substitutions['initial'] = ('<img src="%s%s" alt="%s"/>' % (SUBSITE, escape(value.url), escape(force_unicode(value)))) if not self.is_required: checkbox_name = self.clear_checkbox_name(name) checkbox_id = self.clear_checkbox_id(checkbox_name) substitutions['clear_checkbox_name'] = conditional_escape(checkbox_name) substitutions['clear_checkbox_id'] = conditional_escape(checkbox_id) substitutions['clear'] = CheckboxInput().render(checkbox_name, False, attrs={'id': checkbox_id}) substitutions['clear_template'] = self.template_with_clear % substitutions return mark_safe(template % substitutions)
def render(self, name, value, attrs=None): substitutions = { #uncomment to get 'Currently' 'input_text': self.input_text, 'clear_template': '', 'clear_checkbox_label': self.clear_checkbox_label, } template = """%(input)s""" substitutions['input'] = Input.render(self, name, value, attrs) if value and hasattr(value, "url"): template = """ <div class="row"> <div class="span3"> %(input)s </div> </div> """ clear_template = """ Clear: %(clear)s """ substitutions['initial'] = '' if not self.is_required: checkbox_name = self.clear_checkbox_name(name) checkbox_id = self.clear_checkbox_id(checkbox_name) substitutions['clear_checkbox_name'] = conditional_escape( checkbox_name) substitutions['clear_checkbox_id'] = conditional_escape( checkbox_id) substitutions['clear'] = '' substitutions['clear_template'] = '' return mark_safe(template % substitutions)