from django import forms
from django.forms import ModelForm, CharField, SlugField
from django.core.validators import validate_unicode_slug
from .models import Network, Host
class NetworkForm(ModelForm):
class Meta:
model=Network
#fields = ['name', 'slug', 'nickname', 'password', 'username', 'home_channel', 'command_character', 'help_character']
fields='__all__'
#exclude = ['slug'] #Does not need "fields = '__all__'".
labels={
'name': 'Name',
'slug': 'Slug',
'nickname': 'Nickname',
'username': 'Username',
'password': 'Password',
'mail': 'NickServ registration E-mail',
'home_channel': 'Home channel',
'command_character': 'Command character',
'help_character': 'Help character',
#'network_services': 'Network services',
'enabled': 'Enabled',
# 'mute': 'Mute',
}
widgets={
'name': forms.TextInput(attrs={'autocomplete': 'on'}),
'nickname': forms.TextInput(attrs={'autocomplete': 'on'}),
'username': forms.TextInput(attrs={'autocomplete': 'on'}),
}
class HostForm(ModelForm):
class Meta:
model=Host
exclude=['network', 'connection_attempts', 'connection_succeeds']
labels={
'address': 'Address',
'port': 'Port',
'ssl': 'Use SSL',
}
widgets={
'address': forms.TextInput(attrs={'autocomplete': 'on'}),
'ssl': forms.CheckboxInput(attrs={'_style': 'toggle',}),
}