"""
byceps.blueprints.news_admin.forms
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:Copyright: 2006-2019 Jochen Kupperschmidt
:License: Modified BSD, see LICENSE for details.
"""

import re

from wtforms import StringField, TextAreaField
from wtforms.validators import InputRequired, Length, Optional, Regexp

from ...util.l10n import LocalizedForm


SLUG_REGEX = re.compile('^[a-z0-9-]+$')


class ChannelCreateForm(LocalizedForm):
    channel_id = StringField('ID', validators=[Length(min=1, max=40)])
    url_prefix = StringField('URL-Präfix', [InputRequired(), Length(max=80)])


class ItemCreateForm(LocalizedForm):
    slug = StringField('Slug', [InputRequired(), Length(max=80), Regexp(SLUG_REGEX, message='Nur Kleinbuchstaben, Ziffern und Bindestrich sind erlaubt.')])
    title = StringField('Titel', [InputRequired(), Length(max=80)])
    body = TextAreaField('Text', [InputRequired()])
    image_url_path = StringField('Bild-URL-Pfad', [Optional(), Length(max=80)])


class ItemUpdateForm(ItemCreateForm):
    pass

@@ -666,17 +666,18 @@
 gth(max=
-8
+10
 0), Rege
@@ -821,25 +821,26 @@
  Length(max=
-8
+10
 0)%5D)%0A    bod
@@ -950,33 +950,34 @@
 l(), Length(max=
-8
+10
 0)%5D)%0A%0A%0Aclass Ite

Increase form length limits for news item's slug, title, and image URL path