from django import forms
from django.utils.translation import gettext_lazy as _

import pytz

from newsreader.core.forms import CheckboxInput
from newsreader.news.collection.forms.base import CollectionRuleForm
from newsreader.news.collection.models import CollectionRule


class FeedForm(CollectionRuleForm):
    timezone = forms.ChoiceField(
        widget=forms.Select(attrs={"size": len(pytz.all_timezones)}),
        choices=((timezone, timezone) for timezone in pytz.all_timezones),
        help_text=_("The timezone which the feed uses"),
        initial=pytz.utc,
    )

    class Meta:
        model = CollectionRule
        fields = ("name", "url", "timezone", "favicon", "category")


class OPMLImportForm(forms.Form):
    file = forms.FileField(allow_empty_file=False)
    skip_existing = forms.BooleanField(
        initial=False, required=False, widget=CheckboxInput
    )
