Ejemplo n.º 1
0
 def subconstituencies_as_html(self):
     """Return HTML for this instance's linked subconstituencies that has both a human-readable
     display and links to the read views for those subconstituencies (or "None")."""
     delimiter = get_comma_delimiter()
     subconstituencies = self.subconstituencies.distinct()
     if subconstituencies.count() == 0:
         return NO_LINKED_OBJECT
     return format_html_join(
         delimiter, ANCHOR_SNIPPET,
         ((subconstituency.get_absolute_url(), u'{} - {}'.format(
             subconstituency.id, subconstituency.name))
          for subconstituency in subconstituencies))
Ejemplo n.º 2
0
 def subconstituencies_as_html(self):
     """Return HTML for this instance's linked subconstituencies that has both a human-readable
     display and links to the read views for those subconstituencies (or "None")."""
     delimiter = get_comma_delimiter()
     subconstituencies = self.subconstituencies.distinct()
     if subconstituencies.count() == 0:
         return NO_LINKED_OBJECT
     return format_html_join(delimiter, ANCHOR_SNIPPET, (
         (subconstituency.get_absolute_url(), u'{} - {}'.format(subconstituency.id,
                                                                subconstituency.name))
         for subconstituency in subconstituencies
     ))
Ejemplo n.º 3
0
def get_copied_by_formatted(context):
    """Return a list of them centers that are copies of the one referenced in the context.

    The list is nicely formatted for display. Context should be a view context with
    context['object'] referring to the copied center.

    This is a support function for RegistrationCenterReadView.
    """
    original = context['object']

    copies = get_comma_delimiter().join(['{} - {}'.format(copy_center.center_id, copy_center.name)
                                        for copy_center in original.copied_by.all()])

    return copies or _("No copies")
Ejemplo n.º 4
0
def display_center_infos(center_infos):
    """Given a list of center info tuples, return that list as an HTML string formatted with links.
    This is a specialized filter for the job view. Given a list of 2-tuples of (center id, url),
    return a string of marked-safe HTML where each center id is wrapped in an <a> with href=the url.
    """

    html = []
    for center_id, url in center_infos:
        if url:
            html.append(format_html(ANCHOR_SNIPPET.format(url, center_id)))
        else:
            html.append(str(center_id))
    delimiter = get_comma_delimiter()
    return mark_safe(delimiter.join(html))
Ejemplo n.º 5
0
def get_copied_by_formatted(context):
    """Return a list of them centers that are copies of the one referenced in the context.

    The list is nicely formatted for display. Context should be a view context with
    context['object'] referring to the copied center.

    This is a support function for RegistrationCenterReadView.
    """
    original = context["object"]

    copies = get_comma_delimiter().join(
        ["{} - {}".format(copy_center.center_id, copy_center.name) for copy_center in original.copied_by.all()]
    )

    return copies or _("No copies")
Ejemplo n.º 6
0
def groups_formatted(context):
    user = context['object']
    return get_comma_delimiter().join([group.name for group in user.groups.all().order_by('name')])
Ejemplo n.º 7
0
def groups_formatted(context):
    user = context['object']
    return get_comma_delimiter().join(
        [group.name for group in user.groups.all().order_by('name')])