minecraft_manager/forms.py

53 lines
1.4 KiB
Python
Raw Normal View History

2018-09-20 02:56:17 +00:00
from django.forms import ModelForm, Textarea, HiddenInput, TextInput
from minecraft_manager.models import UserSettings, Application, Alert, Ticket, TicketNote, Note
2018-09-20 02:56:17 +00:00
def __all__():
return [UserSettingsForm, ApplicationForm, AlertForm, TicketForm, TicketNoteForm, NoteForm]
2018-09-20 02:56:17 +00:00
class UserSettingsForm(ModelForm):
class Meta:
model = UserSettings
fields = ['default_results', 'default_theme', 'default_timezone', 'search_player_ip', 'show_timestamp_chat']
class ApplicationForm(ModelForm):
class Meta:
model = Application
fields = ['username', 'age', 'player_type', 'ever_banned', 'ever_banned_explanation', 'reference', 'read_rules']
class AlertForm(ModelForm):
class Meta:
model = Alert
fields = ['message']
class TicketForm(ModelForm):
class Meta:
model = Ticket
fields = ['player', 'message', 'priority', 'world', 'x', 'y', 'z']
widgets = {
'player': TextInput,
'message': Textarea(attrs={'style': 'display: block;'}),
2018-09-20 02:56:17 +00:00
}
class NoteForm(ModelForm):
2018-09-20 02:56:17 +00:00
class Meta:
model = Note
fields = ['player', 'message', 'importance']
2018-09-20 02:56:17 +00:00
widgets = {
'message': Textarea(attrs={'style': 'display: block;'})
2018-09-20 02:56:17 +00:00
}
class TicketNoteForm(ModelForm):
2018-09-20 02:56:17 +00:00
class Meta:
model = TicketNote
fields = ['ticket', 'message']
2018-09-20 02:56:17 +00:00
widgets = {
'ticket': HiddenInput
2018-09-20 02:56:17 +00:00
}