Files
Dashboard_Projects_Management/projects/forms.py
T

39 lines
1.2 KiB
Python

from django import forms
from .models import Card, Column, Profile, Project
class ProjectForm(forms.ModelForm):
class Meta:
model = Project
fields = ['name', 'description', 'git_repository_url']
def clean_git_repository_url(self):
value = self.cleaned_data['git_repository_url']
if value and not value.startswith('https://'):
raise forms.ValidationError('Use an HTTPS repository URL.')
return value
class CardForm(forms.ModelForm):
expected_revision = forms.IntegerField(widget=forms.HiddenInput, required=False)
class Meta:
model = Card
fields = ['title', 'description_markdown', 'priority', 'card_type', 'due_date', 'is_blocked', 'blocked_reason']
widgets = {'description_markdown': forms.Textarea(attrs={'rows': 16}), 'due_date': forms.DateInput(attrs={'type': 'date'})}
class ColumnForm(forms.ModelForm):
class Meta:
model = Column
fields = ['name', 'color', 'is_done']
widgets = {'color': forms.TextInput(attrs={'type': 'color'})}
class ProfileForm(forms.ModelForm):
email = forms.EmailField(required=False)
class Meta:
model = Profile
fields = ['display_name', 'avatar_url', 'timezone', 'language', 'theme']