284 lines
6.0 KiB
Python
284 lines
6.0 KiB
Python
from ckeditor.widgets import CKEditorWidget
|
|
from ckeditor_uploader.widgets import CKEditorUploadingWidget
|
|
from django import forms
|
|
from django.forms.widgets import HiddenInput
|
|
|
|
from .models import Attachment, Etherpad, FileUpload, Topic, TopicGroup
|
|
|
|
|
|
class DateInput(forms.DateInput):
|
|
input_type = "date"
|
|
|
|
|
|
class TopicGroupAdminForm(forms.ModelForm):
|
|
class Meta:
|
|
model = TopicGroup
|
|
fields = "__all__"
|
|
|
|
labels = {
|
|
"title": "Titel",
|
|
"shortterm": "Kürzel für Link",
|
|
"slug": "Permalink",
|
|
"short_description": "Kurzbeschreibung",
|
|
}
|
|
|
|
|
|
class TopicAdminForm(forms.ModelForm):
|
|
class Meta:
|
|
model = Topic
|
|
fields = "__all__"
|
|
|
|
labels = {
|
|
"title": "Titel",
|
|
"slug": "Permalink",
|
|
"description": "Beschreibung",
|
|
}
|
|
|
|
widgets = {"description": CKEditorUploadingWidget(config_name="default")}
|
|
|
|
|
|
class AttachmentAdminForm(forms.ModelForm):
|
|
class Meta:
|
|
model = Attachment
|
|
fields = "__all__"
|
|
|
|
labels = {
|
|
"title": "Titel",
|
|
"slug": "Permalink",
|
|
"topic": "Thema",
|
|
"description": "Beschreibung",
|
|
}
|
|
|
|
widgets = {"description": CKEditorUploadingWidget(config_name="default")}
|
|
|
|
|
|
class EtherpadAdminForm(forms.ModelForm):
|
|
class Meta:
|
|
model = Etherpad
|
|
fields = [
|
|
"title",
|
|
"date",
|
|
"attachment",
|
|
]
|
|
|
|
labels = {
|
|
"title": "Titel",
|
|
"attachment": "Anhang Ordner",
|
|
}
|
|
|
|
|
|
class FileUploadAdminForm(forms.ModelForm):
|
|
class Meta:
|
|
model = FileUpload
|
|
fields = [
|
|
"title",
|
|
"file_field",
|
|
"attachment",
|
|
]
|
|
|
|
labels = {
|
|
"title": "Titel",
|
|
"attachment": "Anhang Ordner",
|
|
}
|
|
|
|
|
|
class TopicInlineForm(forms.ModelForm):
|
|
class Meta:
|
|
model = Topic
|
|
fields = [
|
|
"title",
|
|
]
|
|
|
|
labels = {
|
|
"title": "Titel",
|
|
}
|
|
|
|
|
|
class AttachmentInlineForm(forms.ModelForm):
|
|
class Meta:
|
|
model = Attachment
|
|
fields = [
|
|
"title",
|
|
]
|
|
|
|
labels = {
|
|
"title": "Titel",
|
|
}
|
|
|
|
|
|
class EtherpadInlineForm(forms.ModelForm):
|
|
class Meta:
|
|
model = Etherpad
|
|
fields = [
|
|
"title",
|
|
"date",
|
|
"attachment",
|
|
]
|
|
|
|
labels = {
|
|
"title": "Titel",
|
|
"date": "Datum",
|
|
}
|
|
|
|
|
|
class FileUploadInlineForm(forms.ModelForm):
|
|
class Meta:
|
|
model = FileUpload
|
|
fields = [
|
|
"title",
|
|
"file_field",
|
|
]
|
|
|
|
labels = {
|
|
"title": "Titel",
|
|
}
|
|
|
|
|
|
class TopicCreateForm(forms.ModelForm):
|
|
class Meta:
|
|
model = Topic
|
|
fields = [
|
|
"title",
|
|
"description",
|
|
"topic_group",
|
|
]
|
|
|
|
labels = {
|
|
"title": "Titel",
|
|
"description": "Beschreibung",
|
|
}
|
|
|
|
widgets = {
|
|
"description": CKEditorWidget(config_name="intern"),
|
|
"topic_group": HiddenInput,
|
|
}
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
super().__init__(*args, **kwargs) # to get the self.fields set
|
|
|
|
self.fields["title"].autofocus = True
|
|
|
|
|
|
class TopicUpdateForm(forms.ModelForm):
|
|
class Meta:
|
|
model = Topic
|
|
fields = [
|
|
"title",
|
|
"description",
|
|
"topic_group",
|
|
]
|
|
|
|
labels = {
|
|
"title": "Titel",
|
|
"description": "Beschreibung",
|
|
}
|
|
|
|
widgets = {
|
|
"description": CKEditorWidget(config_name="intern"),
|
|
"topic_group": HiddenInput,
|
|
}
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
super().__init__(*args, **kwargs) # to get the self.fields set
|
|
|
|
self.fields["title"].autofocus = True
|
|
|
|
|
|
class AttachmentCreateForm(forms.ModelForm):
|
|
class Meta:
|
|
model = Attachment
|
|
fields = [
|
|
"title",
|
|
"description",
|
|
"topic",
|
|
]
|
|
|
|
labels = {
|
|
"title": "Titel",
|
|
"description": "Beschreibung",
|
|
}
|
|
|
|
widgets = {
|
|
"description": CKEditorWidget(config_name="intern"),
|
|
"topic": HiddenInput,
|
|
}
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
super().__init__(*args, **kwargs) # to get the self.fields set
|
|
|
|
self.fields["title"].autofocus = True
|
|
|
|
|
|
class AttachmentUpdateForm(forms.ModelForm):
|
|
class Meta:
|
|
model = Attachment
|
|
fields = [
|
|
"title",
|
|
"description",
|
|
"topic",
|
|
]
|
|
|
|
labels = {
|
|
"title": "Titel",
|
|
"description": "Beschreibung",
|
|
}
|
|
|
|
widgets = {
|
|
"description": CKEditorWidget(config_name="intern"),
|
|
"topic": HiddenInput,
|
|
}
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
super().__init__(*args, **kwargs) # to get the self.fields set
|
|
|
|
self.fields["title"].autofocus = True
|
|
|
|
|
|
class EtherpadCreateForm(forms.ModelForm):
|
|
class Meta:
|
|
model = Etherpad
|
|
fields = [
|
|
"title",
|
|
"date",
|
|
"attachment",
|
|
]
|
|
|
|
labels = {
|
|
"title": "Titel",
|
|
"date": "Datum",
|
|
}
|
|
|
|
widgets = {
|
|
"date": DateInput(format=("%Y-%m-%d")),
|
|
"attachment": HiddenInput,
|
|
}
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
super().__init__(*args, **kwargs) # to get the self.fields set
|
|
|
|
self.fields["title"].autofocus = True
|
|
|
|
|
|
class FileUploadCreateForm(forms.ModelForm):
|
|
class Meta:
|
|
model = FileUpload
|
|
fields = [
|
|
"title",
|
|
"file_field",
|
|
"attachment",
|
|
]
|
|
|
|
labels = {
|
|
"title": "Titel",
|
|
"date": "Datum",
|
|
}
|
|
|
|
widgets = {
|
|
"attachment": HiddenInput,
|
|
}
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
super().__init__(*args, **kwargs) # to get the self.fields set
|
|
|
|
self.fields["file_field"].autofocus = True
|