lib.itmens/collection/forms.py
2021-12-27 16:31:26 -05:00

31 lines
908 B
Python

from django import forms
from django.utils.translation import gettext_lazy as _
from .models import Collection
from common.forms import *
class CollectionForm(forms.ModelForm):
# id = forms.IntegerField(required=False, widget=forms.HiddenInput())
title = forms.CharField(label=_("标题"))
description = MarkdownxFormField(label=_("详细介绍 (Markdown)"))
# share_to_mastodon = forms.BooleanField(label=_("分享到联邦网络"), initial=True, required=False)
visibility = forms.TypedChoiceField(
label=_("可见性"),
initial=0,
coerce=int,
choices=VISIBILITY_CHOICES,
widget=forms.RadioSelect
)
class Meta:
model = Collection
fields = [
'title',
'description',
'cover',
'visibility',
]
widgets = {
'cover': PreviewImageInput(),
}