2022-12-25 13:45:24 -05:00
|
|
|
from django import forms
|
|
|
|
from django.utils.translation import gettext_lazy as _
|
2023-08-10 11:27:31 -04:00
|
|
|
from markdownx.fields import MarkdownxFormField
|
|
|
|
|
2022-12-28 01:09:55 -05:00
|
|
|
from common.forms import PreviewImageInput
|
2022-12-25 13:45:24 -05:00
|
|
|
|
2023-08-10 11:27:31 -04:00
|
|
|
from .models import *
|
|
|
|
|
2022-12-25 13:45:24 -05:00
|
|
|
|
|
|
|
class ReviewForm(forms.ModelForm):
|
|
|
|
class Meta:
|
|
|
|
model = Review
|
2022-12-29 23:57:02 -05:00
|
|
|
fields = ["id", "item", "title", "body", "visibility"]
|
2022-12-25 13:45:24 -05:00
|
|
|
widgets = {
|
2022-12-29 23:57:02 -05:00
|
|
|
"item": forms.TextInput(attrs={"hidden": ""}),
|
2022-12-25 13:45:24 -05:00
|
|
|
}
|
2022-12-29 23:57:02 -05:00
|
|
|
|
2024-03-10 20:55:50 -04:00
|
|
|
title = forms.CharField(label=_("Title"))
|
|
|
|
body = MarkdownxFormField(label=_("Content (Markdown)"), strip=False)
|
2022-12-25 13:45:24 -05:00
|
|
|
share_to_mastodon = forms.BooleanField(
|
2024-06-13 23:02:12 -04:00
|
|
|
label=_("Post to Fediverse"), initial=True, required=False
|
2022-12-29 23:57:02 -05:00
|
|
|
)
|
2022-12-25 13:45:24 -05:00
|
|
|
id = forms.IntegerField(required=False, widget=forms.HiddenInput())
|
|
|
|
visibility = forms.TypedChoiceField(
|
2024-03-10 20:55:50 -04:00
|
|
|
label=_("Visibility"),
|
2022-12-25 13:45:24 -05:00
|
|
|
initial=0,
|
|
|
|
coerce=int,
|
|
|
|
choices=VisibilityType.choices,
|
2022-12-29 23:57:02 -05:00
|
|
|
widget=forms.RadioSelect,
|
2022-12-25 13:45:24 -05:00
|
|
|
)
|
2022-12-28 01:09:55 -05:00
|
|
|
|
|
|
|
|
|
|
|
COLLABORATIVE_CHOICES = [
|
2024-03-10 20:55:50 -04:00
|
|
|
(0, _("creator only")),
|
|
|
|
(1, _("creator and their mutuals")),
|
2022-12-28 01:09:55 -05:00
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
class CollectionForm(forms.ModelForm):
|
|
|
|
# id = forms.IntegerField(required=False, widget=forms.HiddenInput())
|
2024-03-10 20:55:50 -04:00
|
|
|
title = forms.CharField(label=_("Title"))
|
|
|
|
brief = MarkdownxFormField(label=_("Content (Markdown)"), strip=False)
|
2024-05-15 20:41:03 -04:00
|
|
|
# share_to_mastodon = forms.BooleanField(label=_("Repost to Fediverse"), initial=True, required=False)
|
2022-12-28 01:09:55 -05:00
|
|
|
visibility = forms.TypedChoiceField(
|
2024-03-10 20:55:50 -04:00
|
|
|
label=_("Visibility"),
|
2022-12-28 01:09:55 -05:00
|
|
|
initial=0,
|
|
|
|
coerce=int,
|
|
|
|
choices=VisibilityType.choices,
|
2022-12-29 23:57:02 -05:00
|
|
|
widget=forms.RadioSelect,
|
2022-12-28 01:09:55 -05:00
|
|
|
)
|
|
|
|
collaborative = forms.TypedChoiceField(
|
2024-03-10 20:55:50 -04:00
|
|
|
label=_("Collaborative editing"),
|
2022-12-28 01:09:55 -05:00
|
|
|
initial=0,
|
|
|
|
coerce=int,
|
|
|
|
choices=COLLABORATIVE_CHOICES,
|
2022-12-29 23:57:02 -05:00
|
|
|
widget=forms.RadioSelect,
|
2022-12-28 01:09:55 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
model = Collection
|
|
|
|
fields = [
|
2022-12-29 23:57:02 -05:00
|
|
|
"title",
|
|
|
|
"cover",
|
|
|
|
"visibility",
|
|
|
|
"collaborative",
|
|
|
|
"brief",
|
2022-12-28 01:09:55 -05:00
|
|
|
]
|
|
|
|
|
|
|
|
widgets = {
|
2022-12-29 23:57:02 -05:00
|
|
|
"cover": PreviewImageInput(),
|
2022-12-28 01:09:55 -05:00
|
|
|
}
|