Skip to content

Instantly share code, notes, and snippets.

@slomo
Last active April 18, 2017 07:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save slomo/1d420006088ff88f447f7f5d6b4dabbf to your computer and use it in GitHub Desktop.
Save slomo/1d420006088ff88f447f7f5d6b4dabbf to your computer and use it in GitHub Desktop.
from adhcoracy4.maps.models import AreaSettings
SETTINGS_WIDGETS = {
AreaSettings: {
'polygon': MapChoosePolygonPresets
}
}
def get_module_settings_form(settings_instance_or_modelref):
if hasattr(settings_instance_or_modelref, 'module'):
settings_model = settings_instance_or_modelref.__class__
else:
settings_model = loading.get_model(
settings_instance_or_modelref[0],
settings_instance_or_modelref[1],
)
widgets = SETTINGS_WIDGETS.get(settings_model, settings_model().widgets())
class ModuleSettings(forms.ModelForm):
class Meta:
model = settings_model
exclude = ['module']
widgets = widgets
return ModuleSettings
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment