Commit 9a649317 authored by ynerant's avatar ynerant
Browse files

Add forms

parent c0479408
Pipeline #4754 passed with stages
in 2 minutes and 4 seconds
from django import forms
from .models import Action, CupidonAction, DoveAction, HackerAction, RavenAction, WerewolfAction, WitchAction
class ActionForm(forms.ModelForm):
_forms_per_model = dict()
def __init_subclass__(cls):
ActionForm._forms_per_model[cls.Meta.model] = cls
return super().__init_subclass__()
@staticmethod
def get_form_class(model_class):
return ActionForm._forms_per_model.get(model_class, ActionForm)
class Meta:
model = Action
exclude = ('player', 'night',)
class WerewolfActionForm(ActionForm):
class Meta:
model = WerewolfAction
exclude = ('player', 'night',)
class CupidonActionForm(ActionForm):
class Meta:
model = CupidonAction
exclude = ('player', 'night',)
class WitchActionForm(ActionForm):
class Meta:
model = WitchAction
exclude = ('player', 'night',)
class RavenActionForm(ActionForm):
class Meta:
model = RavenAction
exclude = ('player', 'night',)
class DoveActionForm(ActionForm):
class Meta:
model = DoveAction
exclude = ('player', 'night',)
class HackerActionForm(ActionForm):
class Meta:
model = HackerAction
exclude = ('player', 'night',)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment