61 lines
2.0 KiB
Python
61 lines
2.0 KiB
Python
from django import forms
|
|
from django.contrib.auth.models import User
|
|
from .models import ApiKey, Attachment, Item
|
|
|
|
|
|
class QuickItemForm(forms.ModelForm):
|
|
files = forms.FileField(required=False, widget=forms.ClearableFileInput(attrs={'multiple': False}))
|
|
|
|
class Meta:
|
|
model = Item
|
|
fields = ['content']
|
|
widgets = {'content': forms.Textarea(attrs={
|
|
'class': 'form-control form-control-lg',
|
|
'rows': 3,
|
|
'placeholder': 'Schreibe etwas … /todo /link /public #tag [[note:1]]',
|
|
'x-model': 'text',
|
|
'@keydown': 'onKeydown($event)',
|
|
'@input': 'onInput($event)',
|
|
'@paste': 'handlePaste($event)',
|
|
})}
|
|
|
|
|
|
class EditItemForm(forms.ModelForm):
|
|
files = forms.FileField(required=False, widget=forms.ClearableFileInput())
|
|
|
|
class Meta:
|
|
model = Item
|
|
fields = ['content', 'comment', 'visibility', 'due_at', 'url']
|
|
widgets = {
|
|
'comment': forms.Textarea(attrs={'class': 'form-control', 'rows': 3}),
|
|
'due_at': forms.DateTimeInput(attrs={'type': 'datetime-local'}, format='%Y-%m-%dT%H:%M'),
|
|
'url': forms.URLInput(attrs={'class': 'form-control', 'placeholder': 'URL'}),
|
|
}
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
super().__init__(*args, **kwargs)
|
|
self.fields['due_at'].input_formats = ['%Y-%m-%dT%H:%M']
|
|
|
|
|
|
class UserSettingsForm(forms.ModelForm):
|
|
class Meta:
|
|
model = User
|
|
fields = ['first_name', 'last_name', 'email']
|
|
widgets = {field: forms.TextInput(attrs={'class': 'form-control'}) for field in ['first_name', 'last_name', 'email']}
|
|
|
|
|
|
class ApiKeyForm(forms.ModelForm):
|
|
class Meta:
|
|
model = ApiKey
|
|
fields = ['name', 'tags']
|
|
widgets = {
|
|
'name': forms.TextInput(attrs={'class': 'form-control', 'placeholder': 'Name des API Keys'}),
|
|
'tags': forms.CheckboxSelectMultiple(),
|
|
}
|
|
|
|
|
|
class AttachmentForm(forms.ModelForm):
|
|
class Meta:
|
|
model = Attachment
|
|
fields = ['file']
|