def preview_icons(self, obj): families = obj.get_icon_families() format_string = '<li title="{{0}}"><i class="{css_prefix_text}{{0}}"></i></li>'.format(**obj.config_data) return format_html('<div class="preview-iconfont">{}</div>', format_html_join('\n', '<h2>{}</h2><ul>{}</ul>', ((src.title(), format_html_join('', format_string, ((g,) for g in glyphs))) for src, glyphs in families.items())))
def flatatt(attrs): """ Pilfered from `django.forms.utils`: Convert a dictionary of attributes to a single string. The returned string will contain a leading space followed by key="value", XML-style pairs. In the case of a boolean value, the key will appear without a value. Otherwise, the value is formatted through its own dict of `attrs`, which can be useful to parametrize Angular directives. It is assumed that the keys do not need to be XML-escaped. If the passed dictionary is empty, then return an empty string. The result is passed through 'mark_safe' (by way of 'format_html_join'). """ key_value_attrs = [] boolean_attrs = [] for attr, value in attrs.items(): if isinstance(value, bool): if value: boolean_attrs.append((attr,)) else: try: value = value.format(**attrs) except KeyError: pass key_value_attrs.append((attr, value)) return ( format_html_join('', ' {}="{}"', sorted(key_value_attrs)) + format_html_join('', ' {}', sorted(boolean_attrs)) )
def render(self, name, values, attrs): values = self.decompress(values) field_attrs = dict(**attrs) render_fieldsets = [] for fieldset in self.partial_fields: render_fields = [] if not isinstance(fieldset, (list, tuple)): fieldset = [fieldset] for field in fieldset: field_attrs["id"] = "{id}_{0}".format(field.name, **attrs) field_value = values.get(field.name) if isinstance(field_value, six.string_types): field_value = self.html_parser.unescape(field_value) render_fields.append( ( field.name, six.text_type(field.label), field.widget.render(field.name, field_value, field_attrs), six.text_type(field.help_text), ) ) html = format_html_join( "", '<div class="glossary-field glossary_{0}"><h1>{1}</h1><div class="glossary-box">{2}</div><small>{3}</small></div>', render_fields, ) render_fieldsets.append((html,)) return format_html_join("\n", '<div class="glossary-widget">{0}</div>', render_fieldsets)
def get_attendees(self, instance): female_attendees = instance.students.filter(common_profile__college__gender="F") male_attendees = instance.students.filter(common_profile__college__gender="M") female_html = u"<strong>طالبات</strong><ol>\n" + format_html_join( '\n', u'<li>{}</li>', ((student.common_profile.get_ar_full_name(),) for student in female_attendees), ) + u"\n</ol>" male_html = u"<strong>طلاب</strong>\n<ol>\n" + format_html_join( '\n', u'<li>{}</li>', ((student.common_profile.get_ar_full_name(),) for student in male_attendees), ) + u"\n</ol>" return u"<br>" + female_html + male_html
def akismet_data_as_dl(akismet_data): """Format Akismet data as a definition list.""" favorites = ( 'comment_content', 'permalink', 'comment_author', 'comment_author_email') def moderator_sort(key): """Sort data by 1) favorites, 2) data values, 3) headers""" try: fav_order = favorites.index(key) except ValueError: fav_order = len(favorites) is_data = key and key[0] in ascii_lowercase return (fav_order, not is_data, key) if not akismet_data: return SUBMISSION_NOT_AVAILABLE data = json.loads(akismet_data) keys = sorted(data.keys(), key=moderator_sort) out = format_html(u'<dl>\n {}\n</dl>', format_html_join(u'\n ', u'<dt>{}</dt><dd>{}</dd>', ((key, data[key]) for key in keys))) return out
def render(self): return format_html('<div class="form-row">{}</div>', format_html_join('\n', '<div class="field-box"><div class="panel {1}">' '<div class="panel-heading">{2}</div><div class="panel-body">{3}</div>' '</div><div class="label">{0}</div></div>', ((force_text(w), w.choice_value, force_text(self.PANEL_TYPES[w.choice_value]), _("Content")) for w in self) ))
def get_admin_views(app, perms): output = [] STATIC_URL = settings.STATIC_URL for k, v in site._registry.items(): app_name = app.get('app_label', app['name'].lower()) if app_name not in str(k._meta): continue if isinstance(v, AdminViews): for type, name, link, perm in v.output_urls: if perm and not perm in perms: continue if type == 'url': img_url = "%sadmin_views/icons/link.png" % STATIC_URL alt_text = "Link to '%s'" % name else: img_url = "%sadmin_views/icons/view.png" % STATIC_URL alt_text = "Custom admin view '%s'" % name output.append(list(map(u, (img_url, alt_text, link, name)))) output = sorted(output, key=lambda x: x[3]) return format_html_join(u(''), u("""<tr> <th scope="row"> <img src="{}" alt="{}" /> <a href="{}">{}</a></th> <td> </td> <td> </td> </tr> """), output)
def editor_js(): js_files = [ 'global/js/hallo-code-snippet.js', 'global/js/hallo-code-block.js', 'global/js/hallo-tables.js', 'global/js/hallo-quote-snippet.js', 'global/js/hallo-htmledit.js', ] js_includes = format_html_join( '\n', '<script src="{0}{1}"></script>', ((settings.STATIC_URL, filename) for filename in js_files) ) return js_includes + format_html( """ <script> registerHalloPlugin('codesnippet'); registerHalloPlugin('codeblock'); registerHalloPlugin('tables'); registerHalloPlugin('quotesnippet'); registerHalloPlugin('editHtmlButton'); </script> """ )
def render_form(self, value, prefix='', errors=None): if errors: if len(errors) > 1: # We rely on StructBlock.clean throwing a single ValidationError with a specially crafted # 'params' attribute that we can pull apart and distribute to the child blocks raise TypeError('StructBlock.render_form unexpectedly received multiple errors') error_dict = errors.as_data()[0].params else: error_dict = {} child_renderings = [ block.render_form(value.get(name, block.get_default()), prefix="%s-%s" % (prefix, name), errors=error_dict.get(name)) for name, block in self.child_blocks.items() ] list_items = format_html_join('\n', "<li>{0}</li>", [ [child_rendering] for child_rendering in child_renderings ]) if self.label: return format_html('<div class="struct-block"><label>{0}</label> <ul>{1}</ul></div>', self.label, list_items) else: return format_html('<div class="struct-block"><ul>{0}</ul></div>', list_items)
def template_hook_collect(module, hook_name, *args, **kwargs): """ Helper to include in your own templatetag, for static TemplateHooks Example:: import myhooks from hooks.templatetags import template_hook_collect @register.simple_tag(takes_context=True) def hook(context, name, *args, **kwargs): return template_hook_collect(myhooks, name, context, *args, **kwargs) :param module module: Module containing the template hook definitions :param str hook_name: The hook name to be dispatched :param \*args: Positional arguments, will be passed to hook callbacks :param \*\*kwargs: Keyword arguments, will be passed to hook callbacks :return: A concatenation of all callbacks\ responses marked as safe (conditionally) :rtype: str """ try: templatehook = getattr(module, hook_name) except AttributeError: return "" return format_html_join( sep="\n", format_string="{}", args_generator=( (response, ) for response in templatehook(*args, **kwargs) ) )
def search_description(self): def get_value_text(bf): f = bf.field v = self.cleaned_data.get(bf.name) or f.initial if isinstance(f, forms.ChoiceField): return dict(f.choices).get(v) if isinstance(f, forms.DateField) and v is not None: return date_format(v, 'j M Y') if isinstance(f, forms.IntegerField) and v is not None: return str(v) return v or None filters = [] for bound_field in self: if bound_field.name in ('page', 'ordering'): continue value = get_value_text(bound_field) if value is None: continue filters.append((str(bound_field.label).lower(), value)) if filters: filters = format_html_join(', ', _('{} is <strong>{}</strong>'), filters) description = format_html(_('Filtering results: {}.'), filters) else: description = _('Showing all results.') ordering = get_value_text(self['ordering']) if ordering: return format_html('{} {}', description, _('Ordered by %s.') % str(ordering).lower()) return description
def validation_error(request, message, form, buttons=None): if not form.non_field_errors(): # just output the generic "there were validation errors" message, and leave # the per-field highlighting to do the rest detail = '' else: # display the full list of field and non-field validation errors all_errors = [] for field_name, errors in form.errors.items(): if field_name == NON_FIELD_ERRORS: prefix = '' else: try: field_label = form[field_name].label except KeyError: field_label = field_name prefix = "%s: " % field_label for error in errors: all_errors.append(prefix + error) errors_html = format_html_join('\n', '<li>{}</li>', ((e,) for e in all_errors)) detail = format_html("""<ul class="errorlist">{}</ul>""", errors_html) return messages.error(request, render(message, buttons, detail=detail))
def gardens(self, instance): gardens = get_profile(instance).gardens.all() return format_html_join( mark_safe('<br />'), mark_safe('<a href="{1}">{0}</a>'), ((garden, garden.get_absolute_url(),) for garden in gardens), )
def render_basic(self, value, context=None): children = format_html_join( "\n", "<li>{0}</li>", [(self.child_block._render_with_context(child_value, context=context),) for child_value in value], ) return format_html("<ul>{0}</ul>", children)
def translated_slugs(): js_files = [ 'wagtail_modeltranslation/js/wagtail_translated_slugs.js', ] js_includes = format_html_join('\n', '<script src="{0}{1}"></script>', ( (settings.STATIC_URL, filename) for filename in js_files) ) lang_codes = [] for lang in settings.LANGUAGES: lang_codes.append("'%s'" % lang[0]) js_languages = """ <script> var langs=[{langs}]; var default_lang='{default_lang}'; var translate_slugs={translate_slugs}; </script> """.format( langs=", ".join(lang_codes), default_lang=mt_settings.DEFAULT_LANGUAGE, translate_slugs='true' if wmt_settings.TRANSLATE_SLUGS else 'false' ) return format_html(js_languages) + js_includes
def as_ul(self): if not self: return SafeText() first = self[0] if isinstance(first, tuple): valid_list = [] invalid_list = [] for e in self: """ Ignore $pristine errors, as they relate to the original rejected error handling or djng-error bound-field""" if e[2] == '$pristine': continue if e[3] == '$valid': li_format = self.li_format_valid error_list = valid_list elif e[5] == '$message': li_format = self.li_format_bind error_list = invalid_list else: li_format = self.li_format error_list = invalid_list msg_type = e[3].split('.') err_tuple = (e[0], msg_type[0] if len(msg_type) == 1 else msg_type.pop(), e[4], force_text(e[5])) error_list.append(format_html(li_format, *err_tuple)) return mark_safe(format_html(self.ul_format_valid, first[0], first[1], self._get_form_name(first[0]), mark_safe(''.join(valid_list)))) \ + mark_safe(format_html(self.ul_format, first[0], first[1], self._get_form_name(first[0]), mark_safe(''.join(invalid_list)))) return format_html('<ul class="errorlist">{0}</ul>', format_html_join('', '<li>{0}</li>', ((force_text(e),) for e in self)))
def model_index_html(self, request, model, site): fields = self.field_dict(model) if not fields: return '' return format_html('<p class="filter"><strong>View calendar by:</strong> {0}</p>', format_html_join(', ', '<a href="calendars/{0}/">{1}</a>', ((f.name, force_unicode(capfirst(f.verbose_name))) for f in fields.values())))
def paragraph(content, context, before=1, after=1, editable=False, style=None): try: status = context[u"_paragraph_status"] except KeyError: status = Bunch(opened=False, after=0) context[u"_paragraph_status"] = status html = [] if status.opened and before > 0: html.append(format_html(u"</div>")) status.opened = False if not status.opened: spacing = max(before, status.after) attrs = defaultdict(list) if editable: attrs[u"class"].append(u"editable-container") if spacing > 1: attrs[u"style"].append(u"margin-top: {0}ex;".format(spacing)) if style: attrs[u"style"].append(style) html.append(format_html_tag(u"div", attrs)) html.append(u" ") status.opened = True html.append(format_html(u"{0}", content)) if after > 0: html.append(format_html(u"</div>")) status.opened = False status.after = after html = format_html_join(u"", u"{0}", zip(html)) return html
def module_list(context, data, namespace): """ To be used in Sekizai's render_block to postprocess AngularJS module dependenies """ modules = set(m.strip(' "\'') for m in data.split()) text = format_html_join(', ', '"{0}"', ((m,) for m in modules)) return text
def render_data(self, state, review_request): """Return the rendered contents of the column.""" summary = review_request.summary labels = {} if review_request.submitter_id == state.datagrid.request.user.id: if review_request.draft_summary is not None: summary = review_request.draft_summary labels.update({_('Draft'): 'label-draft'}) elif (not review_request.public and review_request.status == ReviewRequest.PENDING_REVIEW): labels.update({_('Draft'): 'label-draft'}) if review_request.status == ReviewRequest.SUBMITTED: labels.update({_('Submitted'): 'label-submitted'}) elif review_request.status == ReviewRequest.DISCARDED: labels.update({_('Discarded'): 'label-discarded'}) display_data = '' if not summary: summary = format_html('<span class="no-summary">{}</span>', _('No Summary')) display_data += format_html_join('', '<label class="{}">{}</label>', ( (labels[label], label) for label, label_class in six.iteritems(labels) )) display_data += format_html('<span>{}</span>', summary) return display_data
def as_ul(self): if not self.data: return '' return format_html( '<ul class="errorlist">{0}</ul>', format_html_join('', '<li>{0}</li>', ((force_text(e),) for e in self)) )
def _clients(self, instance): logger.debug(instance) links = html.format_html_join( ', ', '<a href="/admin/api/client/{}/">{}</a>', ((company.id, company.name) for company in instance.clients.all()) ) return links
def projects_display(self, obj): if obj.project_set: return format_html( "<p>{}</p>", format_html_join(', ', '<a target="_blank" href="{}" title="{}">Project {}</a>', ((reverse('admin:infrastructure_project_change', args=(x.id,)), x, x.id) for x in obj.project_set.all())) ) return None
def render(self): return format_html('<div class="form-row">{}</div>', format_html_join('\n', '<div class="field-box">' '<span class="btn {1}">{2}</span>' '<div class="label">{0}</div></div>', ((force_text(w), w.choice_value, force_text(self.BUTTON_TYPES[w.choice_value])) for w in self) ))
def sources_display(self, obj): if obj.sources: return format_html( "<ul>{}</ul>", format_html_join('\n', '<li>{}</li>', ((x,) for x in obj.sources)) ) return None
def as_ul(self): if not self: return '' return format_html( '<ul class="errorlist">{}</ul>', format_html_join('', '<li>{}{}</li>', self.items()) )
def as_ul(self): if not self: return '' return format_html( '<ul class="errorlist">{0}</ul>', format_html_join('', '<li>{0}{1}</li>', ((k, force_text(v)) for k, v in self.items())) )
def render(self): """Outputs a <ul> for this set of radio fields.""" return format_html( "<ul{0}>\n{1}\n</ul>", flatatt(self.attrs), format_html_join("\n", "<li>{0}</li>", ((force_text(w),) for w in self)), )
def as_ul(self): if not self: return "" return format_html( '<ul class="errorlist">{}</ul>', format_html_join("", "<li>{}{}</li>", ((k, force_text(v)) for k, v in self.items())), )
def render_data(self, state, review_request): """Return the rendered contents of the column.""" bugs = review_request.get_bug_list() repository = review_request.repository local_site_name = None if review_request.local_site: local_site_name = review_request.local_site.name if repository and repository.bug_tracker: links = [] for bug in bugs: try: url = local_site_reverse( 'bug_url', local_site_name=local_site_name, args=[review_request.display_id, bug]) links.append( format_html('<a class="bug" href="{0}">{1}</a>', url, bug)) except NoReverseMatch: links.append(escape(bug)) return ', '.join(links) return format_html_join( ', ', '<span class="bug">{0}</span>', ((bug,) for bug in bugs) )
def formatted_urls(whitelistset): return format_html_join( mark_safe('<br>'), '{}', ((line,) for line in whitelistset.urllist) )
def format_list(generator): return format_html( "<ul>\n{}\n</ul>", format_html_join("\n", "<li>{}</li>", ((str(item), ) for item in generator)), )
def flat_data_attrs(attrs): return format_html_join('', ' data-{0}="{1}"', sorted(attrs.items()))
def render_basic(self, value, context=None): return format_html_join( '\n', '<div class="block-{1}">{0}</div>', [(child.render(context=context), child.block_type) for child in value])
def as_ul(self): if not self: return '<div class="no-actions-msg">No required actions.</div>' return format_html( '<ul class="actions-list">{}</ul>', format_html_join('', '<li>{}</li>', self.values()))
def empty_trash(request): # NB 1: we try to delete the remaining entities (which could not be deleted # because of relationships) when there are errors, while the previous # iteration managed to remove some entities. # It will not work with cyclic references (but it is certainly very unusual). # NB 2: we do not use delete() method of queryset in order to send signals. user = request.user ctype_ids_qs = CremeEntity.objects.filter(is_deleted=True) \ .values_list('entity_type', flat=True) try: # NB: currently only supported by PostGreSQL ctype_ids = [ *ctype_ids_qs.order_by('entity_type_id').distinct('entity_type_id') ] except NotSupportedError: ctype_ids = {*ctype_ids_qs} entity_classes = [ ct.model_class() for ct in map(ContentType.objects.get_for_id, ctype_ids) ] while True: progress = False errors = LimitedList(max_size=50) # NB (#60): 'SELECT FOR UPDATE' in a query using an 'OUTER JOIN' and nullable ids will fail with postgresql (both 9.6 & 10.x). # TODO: This bug may be fixed in django > 2.2 (see https://code.djangoproject.com/ticket/28010) # for entity_class in entity_classes: # paginator = FlowPaginator( # queryset=EntityCredentials.filter( # user, # entity_class.objects.filter(is_deleted=True), # EntityCredentials.DELETE, # ).order_by('id').select_for_update(), # key='id', # per_page=256, # ) # # with atomic(): # for entities_page in paginator.pages(): # for entity in entities_page.object_list: # entity = entity.get_real_entity() for entity_class in entity_classes: paginator = FlowPaginator( queryset=EntityCredentials.filter( user, entity_class.objects.filter(is_deleted=True), EntityCredentials.DELETE, ).order_by('id'), # .select_for_update() key='id', per_page=256, ) for entities_page in paginator.pages(): with atomic(): # NB (#60): Move 'SELECT FOR UPDATE' here for now (see above). for entity in entity_class.objects.filter( pk__in=entities_page.object_list ).select_for_update(): try: entity.delete() except ProtectedError: errors.append( gettext( '«{entity}» can not be deleted because of its dependencies.' ).format(entity=entity.allowed_str(user))) except Exception as e: logger.exception( 'Error when trying to empty the trash') errors.append( gettext( '«{entity}» deletion caused an unexpected error [{error}].' ).format( entity=entity.allowed_str(user), error=e, )) else: progress = True if not errors or not progress: break # TODO: factorise ?? if not errors: status = 200 message = gettext('Operation successfully completed') else: status = 409 error_count = len(errors) additional_count = error_count - errors.max_size message = format_html( '{}<br><ul>{}</ul><br>{}', ngettext( 'The following entity cannot be deleted:', 'The following entities cannot be deleted:', error_count, ), format_html_join('', '<li>{}</li>', ((msg, ) for msg in errors)), '' if additional_count <= 0 else ngettext( '(and {count} other entity)', '(and {count} other entities)', additional_count, ).format(count=additional_count), ) return HttpResponse(message, status=status)
def title(self, obj): links = [(obj.urls[0], obj)] for i, url in enumerate(obj.urls[1:]): links += [(url, str(i + 2).zfill(2))] return format_html_join(mark_safe('<br>'), '<a href="{}">{}</a>', links)
def render(self): """Outputs a <ul> for this set of radio fields.""" return format_html( '<ul>\n{0}\n</ul>', format_html_join('\n', '<li>{0}</li>', [(force_text(w), ) for w in self]))
def registrations(self, obj): return format_html_join( mark_safe('<br>'), '{}', ((localize(timezone.localtime(r.registered_at)), ) for r in obj.registration_set.all()))
bound_field.field.widget.attrs['group'] = groups + " form-control" return bound_field class BootstrapForm(BootstrapFormWrapper, Form): pass class BootstrapModelForm(BootstrapFormWrapper, ModelForm): pass forms.Form = BootstrapForm forms.ModelForm = BootstrapModelForm # monkey patch the ClearableFileInput so it looks better ClearableFileInput.initial_text = 'Currently' ClearableFileInput.input_text = 'Change' ClearableFileInput.clear_checkbox_label = 'Clear' ClearableFileInput.template_with_initial = '%(initial_text)s: %(initial)s %(clear_template)s %(input_text)s: %(input)s' ClearableFileInput.template_with_clear = '<label class="clear-label" for="%(clear_checkbox_id)s">%(clear)s %(clear_checkbox_label)s</label><br />' # monkey patch the ErrorList so it has a bootstrap css class (text-danger) ErrorList.as_ul = lambda self: '' if not self else format_html( '<ul class="errorlist text-danger">{0}</ul>', format_html_join('', '<li>{0}</li>', ((force_text(e), ) for e in self))) # monkey patch BoundFields so that it has an errorgroup attribute that returns # "has-error" or the empty string BoundField.errorgroup = lambda self: "has-error" if self.errors else ""
def _password_validators_help_text_html(password_validators=None): help_texts = password_validators_help_texts(password_validators) help_items = format_html_join('', '<li>{}</li>', ((help_text, ) for help_text in help_texts)) return format_html('<ul>{}</ul>', help_items) if help_items else ''
def render(self): """Outputs a <ul> for this set of radio fields.""" return format_html('<ul{0}>\n{1}\n</ul>', flatatt(self.attrs), format_html_join('\n', '<li>{0}</li>', ((force_unicode(w),) for w in self)))
def as_ul(self): if not self: return '' return format_html('<ul class="errorlist">{}</ul>', format_html_join('', '<li>{}{}</li>', self.items()))
def get_entity_html_attrs(context, entity): return format_html_join(' ', '{}="{}"', entity.get_html_attrs(context).items())
def img_tag(self, extra_attributes=None): if extra_attributes: extra_attributes_string = format_html_join(' ', '{0}="{1}"', extra_attributes.items()) return mark_safe('<img %s %s>' % (self.attrs, extra_attributes_string)) else: return mark_safe('<img %s>' % self.attrs)
def render_basic(self, value, context=None): '''Very simple rendering of the stream block.''' return format_html_join( '\n', '<div class="block-{1}">{0}</div>', [(child.render(context=context), child.block_type) for child in value])
def inline_styles(self): inline_styles = self.plugin_class.get_inline_styles(self) return format_html_join(' ', '{0}: {1};', (s for s in inline_styles.items() if s[1]))
def render_basic(self, value, context=None): return format_html( "<dl>\n{}\n</dl>", format_html_join("\n", " <dt>{}</dt>\n <dd>{}</dd>", value.items()), )
def appeals(self, instance): if getattr(instance, 'appeals').exists(): return format_html_join(mark_safe('<br />'), '{} - {}', ((appeal.code, appeal.name) for appeal in instance.appeals.all())) return mark_safe('<span class="errors">No related appeals</span>')
def include(obj): return format_html_join( '\n', '<pre>{}</pre>', ((r, ) for r in obj.include_regexps.split('\n'))) if obj.field else None
def categories_display(self, obj): cat_list = format_html_join( '\n', "<li>{}</li>", ((c.name,) for c in obj.categories.all().only('name')) ) return format_html("<ul>{}</ul>".format(cat_list))
def render_basic(self, value): children = format_html_join('\n', '<li>{0}</li>', [(self.child_block.render(child_value), ) for child_value in value]) return format_html("<ul>{0}</ul>", children)
def render_basic(self, value): return format_html_join( '\n', '<div class="{1}">{0}</div>', [(force_text(child), child.block_type != 'full_width_container' and 'block-%s block' % child.block_type or '') for child in value])
def render_basic(self, value): return format_html_join( '\n', '<div class="block-{1}">{0}</div>', [(force_text(child), child.block_type) for child in value] )
def module_config(context, data, namespace): configs = [(mark_safe(c),) for c in data.split('\n') if c] text = format_html_join('', '.config({0})', configs) return text
def rooms_report(self, instance): return format_html_join(mark_safe('<br/>'), '{}', ( (line, ) for line in instance.rooms.all() )) or mark_safe( "<span class='errors'>Det finns inga registrerade rum hos denna anläggning</span>" )
def get_tags(self, obj): return format_html_join('\n', "{} <br>", ((t.name, ) for t in obj.tags.all()))
def source_code(self): return format_html_join( mark_safe('<br/>'), '<div> <div>id={}</div> <div>score/full score: {}/{}</div> <div> 【submitted code】</div> <div style="border-style: solid;"> {}</div> </div>', ((i['id'], i['score'], i['full_score'], mark_safe(linebreaks(i['source_code'])),) for i in self.data['program_design']) )
def get_billing_addresses(self, customer): addresses = [(a.as_text(), ) for a in customer.billingaddress_set.all()] return format_html_join('', '<address>{0}</address>', addresses)
def booked_bike_report(self, instance): return format_html_join(mark_safe('<br/>'), '{}', ( (line, ) for line in instance.booked_bike.all() ) or mark_safe( "<span class='errors'>Det finns inga cykelbokningar registrerade hos denna bokning</span>" ))