<commit_before>from django.template import Context, Library, Template
from django.utils.html import format_html
from django.utils.translation import ugettext

from events.models import Location
from proposals.utils import format_names


LOCATION_DISPLAY_DICT = {
    Location.R0: 'R0',
    Location.R1: 'R1',
    Location.R2: 'R2',
    Location.R3: 'R3',
    Location.R012: 'R123',
}

register = Library()


@register.filter
def event_cell_class(event):
    event_class = {
        'events.customevent': 'custom',
        'events.keynoteevent': 'keynote',
        'events.proposedtalkevent': 'talk',
        'events.sponsoredevent': 'talk',
    }[event._meta.label_lower]
    classes = [event_class]
    if getattr(event, 'break_event', False):
        classes.append('is-break')
    return ' '.join(classes)


@register.filter
def room_display(value):
    return LOCATION_DISPLAY_DICT.get(value, '')


def get_custom_event_display(event):
    return event.title


def get_keynote_event_display(event):
    return format_html(
        '{title}<span class="keynote-speaker">{name}</span>',
        title=ugettext('Keynote: '),
        name=event.speaker_name,
    )


TALK_EVENT_TEMPLATE = Template("""
{% load i18n %}
<p class="talk-title">
  <a href="{{ event.get_absolute_url }}">{{ title }}</a>
</p>
<p class="talk-speakers">{{ speakers }}</p>
<p class="talk-tags">
  <span class="schedule-label lang-label"
      data-balloon="{{ language_display }}" data-balloon-pos="down">
    <span>{{ language_tag }}</span>
    <span class="schedule-label-description">{{ language_display }}</span>
  </span>
  <span class="schedule-label level-label"
      data-balloon="{{ level_display }}" data-balloon-pos="down">
    <span>{{ level_tag }}</span>
    <span class="schedule-label-description">{{ level_display }}</span>
  </span>
  {% if sponsored %}
  {% with label=_('Sponsored talk') %}
  <span class="schedule-label sponsor-label"
      data-balloon="{{ label }}" data-balloon-pos="down">
    <span class="fa fa-handshake-o"></span>
    <span class="schedule-label-description">{{ label }}</span>
  </span>
  {% endwith %}
  {% endif %}
  {% if not recording_policy %}
  <span class="schedule-label recording-label"
      data-balloon="No recording" data-balloon-pos="down">
    <span class="fa fa-microphone-slash"></span>
    <span class="schedule-label-description">{% trans 'No recording' %}</span>
  </span><commit_msg>Can't translate frozen HTML<commit_after>from django.template import Context, Library, Template
from django.utils.html import format_html

from events.models import Location
from proposals.utils import format_names


LOCATION_DISPLAY_DICT = {
    Location.R0: 'R0',
    Location.R1: 'R1',
    Location.R2: 'R2',
    Location.R3: 'R3',
    Location.R012: 'R123',
}

register = Library()


@register.filter
def event_cell_class(event):
    event_class = {
        'events.customevent': 'custom',
        'events.keynoteevent': 'keynote',
        'events.proposedtalkevent': 'talk',
        'events.sponsoredevent': 'talk',
    }[event._meta.label_lower]
    classes = [event_class]
    if getattr(event, 'break_event', False):
        classes.append('is-break')
    return ' '.join(classes)


@register.filter
def room_display(value):
    return LOCATION_DISPLAY_DICT.get(value, '')


def get_custom_event_display(event):
    return event.title


def get_keynote_event_display(event):
    return format_html(
        'Keynote: <span class="keynote-speaker">{name}</span>',
        name=event.speaker_name,
    )


TALK_EVENT_TEMPLATE = Template("""
<p class="talk-title">
  <a href="{{ event.get_absolute_url }}">{{ title }}</a>
</p>
<p class="talk-speakers">{{ speakers }}</p>
<p class="talk-tags">
  <span class="schedule-label lang-label"
      data-balloon="{{ language_display }}" data-balloon-pos="down">
    <span>{{ language_tag }}</span>
    <span class="schedule-label-description">{{ language_display }}</span>
  </span>
  <span class="schedule-label level-label"
      data-balloon="{{ level_display }}" data-balloon-pos="down">
    <span>{{ level_tag }}</span>
    <span class="schedule-label-description">{{ level_display }}</span>
  </span>
  {% if sponsored %}
  {% with label=_('Sponsored talk') %}
  <span class="schedule-label sponsor-label"
      data-balloon="{{ label }}" data-balloon-pos="down">
    <span class="fa fa-handshake-o"></span>
    <span class="schedule-label-description">{{ label }}</span>
  </span>
  {% endwith %}
  {% endif %}
  {% if not recording_policy %}
  <span class="schedule-label recording-label"
      data-balloon="No recording" data-balloon-pos="down">
    <span class="fa fa-microphone-slash"></span>
    <span class="schedule-label-description">No recording</span>
  </span>
{'fraction_non_alphanumeric': 0.16993051168667087, 'fraction_numerical': 0.006317119393556538, 'mean_word_length': 4.0, 'pattern_counts': {'":': 0, '<': 69, '<?xml version=': 0, '>': 69, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4102879', 'n_tokens_mistral': 1616, 'n_tokens_neox': 1546, 'n_words': 313}