<commit_before>from datetime import datetime

from django import forms
from django.conf import settings

from cc.feed.models import FeedItem
from django.utils.translation import ugettext_lazy as _

# Passing no radius => use default, so need a code for infinite.
INFINITE_RADIUS = -1

RADIUS_CHOICES = (
    (1000, _('Within 1 km')),
    (5000, _('Within 5 km')),
    (10000, _('Within 10 km')),
    (50000, _('Within 50 km')),
    (INFINITE_RADIUS, _('Anywhere')),
)

RADII = [rc[0] for rc in RADIUS_CHOICES]
DEFAULT_RADIUS = 5000
DATE_FORMAT = '%Y-%m-%d %H:%M:%S.%f'

class FeedFilterForm(forms.Form):
    d = forms.DateTimeField(
        label="Up to date", required=False, input_formats=[DATE_FORMAT])
    q = forms.CharField(
        label="Search", required=False, widget=forms.TextInput(
            attrs={'class': 'instruction_input', 'help': "Search"}))
    radius = forms.TypedChoiceField(
        required=False, choices=RADIUS_CHOICES, coerce=int, empty_value=None)
    trusted = forms.BooleanField(required=False)
    
    def __init__(self, data, profile, location=None, item_type=None,
                 poster=None, recipient=None, do_filter=False, *args, **kwargs):
        self.profile, self.location, self.item_type = (
            profile, location, item_type)
        self.poster, self.recipient = poster, recipient
        data = data.copy()
        if do_filter and 'radius' not in data:
            default_radius = (profile and profile.settings.feed_radius
                              or DEFAULT_RADIUS)
            data['radius'] = default_radius
            self._explicit_radius = False
        else:
            self._explicit_radius = True
        if do_filter and 'q' not in data:  # Fresh load, no search/filter.
            # Set trusted checkbox to the profile sticky setting.
            # Can't just check for presence of 'trusted' in data, because
            # it is not submitted when unchecked.<commit_msg>i18n: changes in feed code<commit_after>from datetime import datetime

from django import forms
from django.conf import settings

from cc.feed.models import FeedItem
from django.utils.translation import ugettext_lazy as _

# Passing no radius => use default, so need a code for infinite.
INFINITE_RADIUS = -1

RADIUS_CHOICES = (
    (1000, _('Within 1 km')),
    (5000, _('Within 5 km')),
    (10000, _('Within 10 km')),
    (50000, _('Within 50 km')),
    (INFINITE_RADIUS, _('Anywhere')),
)

RADII = [rc[0] for rc in RADIUS_CHOICES]
DEFAULT_RADIUS = 5000
DATE_FORMAT = '%Y-%m-%d %H:%M:%S.%f'

class FeedFilterForm(forms.Form):
    d = forms.DateTimeField(
        label="Up to date", required=False, input_formats=[DATE_FORMAT])
    q = forms.CharField(
        label="Search", required=False, widget=forms.TextInput(
            attrs={'class': 'instruction_input', 'help': _("Search")}))
    radius = forms.TypedChoiceField(
        required=False, choices=RADIUS_CHOICES, coerce=int, empty_value=None)
    trusted = forms.BooleanField(required=False)
    
    def __init__(self, data, profile, location=None, item_type=None,
                 poster=None, recipient=None, do_filter=False, *args, **kwargs):
        self.profile, self.location, self.item_type = (
            profile, location, item_type)
        self.poster, self.recipient = poster, recipient
        data = data.copy()
        if do_filter and 'radius' not in data:
            default_radius = (profile and profile.settings.feed_radius
                              or DEFAULT_RADIUS)
            data['radius'] = default_radius
            self._explicit_radius = False
        else:
            self._explicit_radius = True
        if do_filter and 'q' not in data:  # Fresh load, no search/filter.
            # Set trusted checkbox to the profile sticky setting.
            # Can't just check for presence of 'trusted' in data, because
            # it is not submitted when unchecked.
{'fraction_non_alphanumeric': 0.10966257668711657, 'fraction_numerical': 0.015848670756646217, 'mean_word_length': 2.8780971258671952, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7272089', 'n_tokens_mistral': 1255, 'n_tokens_neox': 1167, 'n_words': 339}