Improve teams settings invites and due tasks
This commit is contained in:
+32
-10
@@ -1,7 +1,8 @@
|
||||
from django import forms
|
||||
from django.contrib.auth.forms import UserCreationForm
|
||||
from django.contrib.auth.models import User
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from .models import ApiKey, Attachment, Item, Kanban, Tag, Team, TeamInvite, UserPreference
|
||||
from .models import ApiKey, Attachment, Item, Kanban, Tag, Team, TeamInvite, UserInvite, UserPreference
|
||||
|
||||
|
||||
class MultipleFileInput(forms.ClearableFileInput):
|
||||
@@ -38,17 +39,12 @@ class EditItemForm(forms.ModelForm):
|
||||
|
||||
class Meta:
|
||||
model = Item
|
||||
fields = ['content', 'comment', 'visibility', 'due_at', 'url']
|
||||
fields = ['content', 'comment', 'visibility', '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:
|
||||
@@ -60,16 +56,42 @@ class UserSettingsForm(forms.ModelForm):
|
||||
class UserPreferenceForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = UserPreference
|
||||
fields = ['show_notes', 'show_open_todos', 'show_done_todos', 'show_links', 'show_journal', 'overview_lines']
|
||||
fields = ['language', 'show_notes', 'show_open_todos', 'show_done_todos', 'show_links', 'due_first', 'overview_lines']
|
||||
labels = {
|
||||
'language': _('Language'),
|
||||
'show_notes': _('Show notes'),
|
||||
'show_open_todos': _('Show open tasks'),
|
||||
'show_done_todos': _('Show completed tasks'),
|
||||
'show_links': _('Show links'),
|
||||
'show_journal': _('Show journal'),
|
||||
'due_first': _('Always show due items first'),
|
||||
'overview_lines': _('Lines in overview'),
|
||||
}
|
||||
widgets = {'overview_lines': forms.NumberInput(attrs={'class': 'form-control', 'min': 1, 'max': 50})}
|
||||
widgets = {
|
||||
'language': forms.Select(attrs={'class': 'form-select'}),
|
||||
'overview_lines': forms.NumberInput(attrs={'class': 'form-control', 'min': 1, 'max': 50}),
|
||||
}
|
||||
|
||||
|
||||
class UserInviteForm(forms.ModelForm):
|
||||
email = forms.EmailField(required=True, label=_('Email'), widget=forms.EmailInput(attrs={'class': 'form-control', 'placeholder': 'person@example.com', 'required': True}))
|
||||
|
||||
class Meta:
|
||||
model = UserInvite
|
||||
fields = ['email']
|
||||
|
||||
|
||||
class InviteRegistrationForm(UserCreationForm):
|
||||
email = forms.EmailField(required=False, label=_('Email'), widget=forms.EmailInput(attrs={'class': 'form-control'}))
|
||||
|
||||
class Meta:
|
||||
model = User
|
||||
fields = ['username', 'email', 'password1', 'password2']
|
||||
widgets = {'username': forms.TextInput(attrs={'class': 'form-control'})}
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
for name in ['password1', 'password2']:
|
||||
self.fields[name].widget.attrs.update({'class': 'form-control'})
|
||||
|
||||
|
||||
class TeamForm(forms.ModelForm):
|
||||
|
||||
Reference in New Issue
Block a user