konova/konova/enums.py
mipel e2ed39c900 Compensation action
* adds compensation action to compensation detail view
* adds adding/removing logic for compensation action
* adds bootstrap style to select fields in forms
* refactors UnitEnum into UnitChoices using models.TextChoices (Django 3.x)
* adds translations
2021-08-04 10:44:02 +02:00

21 lines
526 B
Python

"""
Author: Michel Peltriaux
Organization: Struktur- und Genehmigungsdirektion Nord, Rhineland-Palatinate, Germany
Contact: michel.peltriaux@sgdnord.rlp.de
Created on: 17.11.20
"""
from enum import Enum
class BaseEnum(Enum):
""" Provides basic functionality for Enums
"""
@classmethod
def as_choices(cls, drop_empty_choice: bool = False):
empty_choice = [] if drop_empty_choice else [(None, "---")]
choices = empty_choice + [(enum.value, enum.name) for enum in cls]
return choices