flask-admin and allow_inheritance for an embedded document in mongoengine

713 views Asked by At

For flask-admin the following only gives me CRUD access to Task and the TaskItem embedded document, but no access to ItemParameter or ItemTitle. Is this not supported in flask-admin or am I doing something wrong? Thx

class TaskItem(db.EmbeddedDocument):
    type = db.StringField(max_length = 32)
    column = db.IntField()
    row = db.IntField()
    width = db.IntField()
    height = db.IntField()
    meta = {'allow_inheritance': True}


class ItemParameter(TaskItem):
    label = db.StringField(max_length = 32)
    formula = db.StringField(max_length = 256)
    parameter = db.ReferenceField(Parameter)


class ItemTitle(TaskItem):
    label = db.StringField(max_length = 32)
    document = db.ReferenceField(Document)


class Task(db.Document):
    items = db.ListField(db.EmbeddedDocumentField(TaskItem))

    def __unicode__(self):
        return unicode(self.name)


# Flask-Admin
class SecuredModelView(ModelView):
    def is_accessible(self):
        return current_user.has_role('admin')


admin.add_view(SecuredModelView(Task))
1

There are 1 answers

0
spitz On

As stated by the flask-admin creator this feature is not yet supported.

https://github.com/flask-admin/flask-admin/issues/907