syrusakbary / Flask-SuperAdmin

The best admin interface framework for Flask. With scaffolding for MongoEngine, Django and SQLAlchemy.
Other
642 stars 131 forks source link

Fields order for mongoengine is broken #89

Open rochacbruno opened 11 years ago

rochacbruno commented 11 years ago

Hi, it was working a week ago but now is broken.

I defined: https://github.com/rochacbruno/quokka/blob/master/quokka/modules/posts/admin.py#L35

fields_order = ['title', 'slug', 'channel', 'channels', 'summary',
                    'body', 'published', 'comments']

And admin rendered in the model defined order.

content post quokka admin

iurisilvio commented 11 years ago

The fields_order parameter was removed, use fields instead.

rochacbruno commented 11 years ago

I changed it to fields

fields = ['title', 'slug', 'channel', 'channels', 'summary',
                    'body', 'published', 'comments']

But now I got an error.

fields_jinja_error

rochacbruno commented 11 years ago

I've found the problem.

When I define

    fields = ['title', 'slug', 'channel', 'channels', 'summary', 'body', 'published']

It works well.

But, if I include the EmbeddedDocumment it faills and raises that error.

    fields = ['title', 'slug', 'channel', 'channels', 'summary', 'body', 'published',
                 'comments']

In the above case I included comments in the list field.

class Comment(db.EmbeddedDocument, Publishable):
    body = db.StringField(verbose_name="Comment", required=True)
    author = db.StringField(verbose_name="Name", max_length=255, required=True)
    published = db.BooleanField(default=True)

    def __unicode__(self):
        return "{}-{}...".format(self.author, self.body[:10])

    meta = {
        'indexes': ['-created_at'],
        'ordering': ['-created_at']
    }

#And int he Post class

comments = db.ListField(db.EmbeddedDocumentField(Comment))

The problem, I guess is that it is looking for all the defined fields in the embedded document itself.

So there is a problem when using EmbeddedDocuments and fields argument.

ghost commented 11 years ago

@rochacbruno Can you tell me which Rich Text Editor you used in 'Edit Post' page ?

rochacbruno commented 11 years ago

@tianyu0915 it is http://www.tinymce.com/

https://github.com/rochacbruno/quokka/blob/master/quokka/templates/admin/custom/edit.html#L5-L27

ghost commented 11 years ago

THX !

mvdwaeter commented 10 years ago

I have this issue too. Searched for the answer, found this post, but no answer. What's the fix? Because I want to order the fields AND include the EmbeddedDocument.