<commit_before># -*- coding: utf-8 -*-
# Copyright 2020 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License")
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import logging
from django import forms
from django.core.validators import validate_email

# from google.appengine.api import users
from framework import users

from internals import models
from internals import processes

class MultiEmailField(forms.Field):
    def to_python(self, value):
        """Normalize data to a list of strings."""
        # Return an empty list if no input was given.
        if not value:
            return []
        return value.split(',')

    def validate(self, value):
        """Check if value consists only of valid emails."""
        # Use the parent's handling of required fields, etc.
        super(MultiEmailField, self).validate(value)
        for email in value:
            validate_email(email.strip())

SHIPPED_HELP_TXT = (
    'First milestone to ship with this status. Applies to: Enabled by '
    'default, Browser Intervention, Deprecated and Removed.')

SHIPPED_WEBVIEW_HELP_TXT = ('First milestone to ship with this status. '
                            'Applies to Enabled by default, Browser '
                            'Intervention, Deprecated, and Removed.')

SUMMARY_PLACEHOLDER_TXT = (
  'NOTE: This text describes this feature in the eventual beta release post '
  'and possibly in other external documents.\n\n'
  'Begin with one line explaining what the feature does. Add one or two '
  'lines explaining how this feature helps developers. Avoid language such '
  'as "a new feature". They all are or have been new features.\n\n'
  'Write it from a web developer\'s point of view.\n\n'
  'Follow the example link below for more guidance.')


# We define all form fields here so that they can be include in one or more
# stage-specific fields without repeating the details and help text.
ALL_FIELDS = {
    'name': forms.CharField(
        required=True, label='Feature name',
        # Use a specific autocomplete value to avoid "name" autofill.
        # https://bugs.chromium.org/p/chromium/issues/detail?id=468153#c164
        widget=forms.TextInput(attrs={'autocomplete': 'feature-name'}),
        help_text=
        ('Capitalize only the first letter and the beginnings of '
         'proper nouns. '
         '<a target="_blank" href="'
         'https://github.com/GoogleChrome/chromium-dashboard/wiki/'
         'EditingHelp#feature-name">Learn more</a>. '
         '<a target="_blank" href="'
         'https://github.com/GoogleChrome/chromium-dashboard/wiki/'
         'EditingHelp#feature-name-example">Example</a>.'
        )),

    'summary': forms.CharField(
        required=True,
        widget=forms.Textarea(
            attrs={'cols': 50, 'maxlength': 500,
                   'placeholder': SUMMARY_PLACEHOLDER_TXT}),
        help_text=
        ('<a target="_blank" href="'
         'https://github.com/GoogleChrome/chromium-dashboard/wiki/'
         'EditingHelp#summary-example">Guidelines and example</a>.'
        )),

    'owner': MultiEmailField(
        required=True, label='Contact emails',
        widget=forms.EmailInput(
            attrs={'multiple': True, 'placeholder': 'email,email'}),
        help_text=('Comma separated list of full email addresses. '
                   'Prefer @chromium.<EMAIL>.')),

    'category': forms.ChoiceField(
        required=False,
        help_text=('Select the most specific category. If unsure, '<commit_msg>Relabel owners from "Contact emails" to "Feature owners" (#1783)<commit_after># -*- coding: utf-8 -*-
# Copyright 2020 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License")
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import logging
from django import forms
from django.core.validators import validate_email

# from google.appengine.api import users
from framework import users

from internals import models
from internals import processes

class MultiEmailField(forms.Field):
    def to_python(self, value):
        """Normalize data to a list of strings."""
        # Return an empty list if no input was given.
        if not value:
            return []
        return value.split(',')

    def validate(self, value):
        """Check if value consists only of valid emails."""
        # Use the parent's handling of required fields, etc.
        super(MultiEmailField, self).validate(value)
        for email in value:
            validate_email(email.strip())

SHIPPED_HELP_TXT = (
    'First milestone to ship with this status. Applies to: Enabled by '
    'default, Browser Intervention, Deprecated and Removed.')

SHIPPED_WEBVIEW_HELP_TXT = ('First milestone to ship with this status. '
                            'Applies to Enabled by default, Browser '
                            'Intervention, Deprecated, and Removed.')

SUMMARY_PLACEHOLDER_TXT = (
  'NOTE: This text describes this feature in the eventual beta release post '
  'and possibly in other external documents.\n\n'
  'Begin with one line explaining what the feature does. Add one or two '
  'lines explaining how this feature helps developers. Avoid language such '
  'as "a new feature". They all are or have been new features.\n\n'
  'Write it from a web developer\'s point of view.\n\n'
  'Follow the example link below for more guidance.')


# We define all form fields here so that they can be include in one or more
# stage-specific fields without repeating the details and help text.
ALL_FIELDS = {
    'name': forms.CharField(
        required=True, label='Feature name',
        # Use a specific autocomplete value to avoid "name" autofill.
        # https://bugs.chromium.org/p/chromium/issues/detail?id=468153#c164
        widget=forms.TextInput(attrs={'autocomplete': 'feature-name'}),
        help_text=
        ('Capitalize only the first letter and the beginnings of '
         'proper nouns. '
         '<a target="_blank" href="'
         'https://github.com/GoogleChrome/chromium-dashboard/wiki/'
         'EditingHelp#feature-name">Learn more</a>. '
         '<a target="_blank" href="'
         'https://github.com/GoogleChrome/chromium-dashboard/wiki/'
         'EditingHelp#feature-name-example">Example</a>.'
        )),

    'summary': forms.CharField(
        required=True,
        widget=forms.Textarea(
            attrs={'cols': 50, 'maxlength': 500,
                   'placeholder': SUMMARY_PLACEHOLDER_TXT}),
        help_text=
        ('<a target="_blank" href="'
         'https://github.com/GoogleChrome/chromium-dashboard/wiki/'
         'EditingHelp#summary-example">Guidelines and example</a>.'
        )),

    'owner': MultiEmailField(
        required=True, label='Feature owners',
        widget=forms.EmailInput(
            attrs={'multiple': True, 'placeholder': 'email,email'}),
        help_text=('Comma separated list of full email addresses. '
                   'Prefer <EMAIL>.')),

    'category': forms.ChoiceField(
        required=False,
        help_text=('Select the most specific category. If unsure, '
{'fraction_non_alphanumeric': 0.1014711429649189, 'fraction_numerical': 0.00628693574751666, 'mean_word_length': 2.8952007835455436, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 8, 'lorem ipsum': 0, 'www.': 2, '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': '6301472', 'n_tokens_mistral': 2235, 'n_tokens_neox': 2133, 'n_words': 776}