I have variable outside class. Variable is needed for proper function of class. How to move it inside class and use it in other class?
This works good, but I need move STATUS_CHOICES
inside class UserDevice
and use STATUS_CHOICES
inside UserDeviceAdmin
too.
STATUS_CHOICES = ((0, gettext("disabled")), (1, gettext("allowed")))
class UserDevice(BaseModel):
"""Table with all devices added and owned by users."""
device_uniqueid = CharField(primary_key=True)
device_user = ForeignKeyField(User, null=True, backref='userdevices')
device_name = CharField()
model = CharField()
phone = CharField()
status = IntegerField(choices=STATUS_CHOICES, default=1)
inserted_at = DateTimeField(null=True)
def myfunc(self):
return self.a
class UserDeviceAdmin(ModelView):
can_create = False
edit_modal = True
column_choices = {'status': STATUS_CHOICES}
column_list = [
'device_uniqueid',
'device_user.email',
'device_name',
'model',
'phone',
'status',
'inserted_at',
]
column_sortable_list = ('device_uniqueid', 'device_user.email')
form_ajax_refs = {'device_user': {'fields': ['email']}}