Merge pull request #1551 from getredash/change_tracking

Fix: flask-admin - exclude created_at/updated_at so models can be saved
This commit is contained in:
Arik Fraimovich 2017-01-27 17:00:27 +02:00 committed by GitHub
commit 4b4758af22
2 changed files with 7 additions and 0 deletions

View File

@ -42,6 +42,7 @@ class JSONTextAreaField(fields.TextAreaField):
class BaseModelView(ModelView):
column_display_pk = True
model_form_converter = AdminModelConverter
form_excluded_columns = ('created_at', 'updated_at')
@require_super_admin
def is_accessible(self):
@ -54,10 +55,13 @@ class QueryResultModelView(BaseModelView):
class QueryModelView(BaseModelView):
column_exclude_list = ('latest_query_data',)
form_excluded_columns = ('version', 'visualizations', 'alerts', 'org', 'created_at', 'updated_at', 'latest_query_data')
class DashboardModelView(BaseModelView):
column_searchable_list = ('name', 'slug')
column_exclude_list = ('version', )
form_excluded_columns = ('version', 'widgets', 'org', 'created_at', 'updated_at')
def init_admin(app):

View File

@ -236,6 +236,9 @@ class Organization(TimestampMixin, db.Model):
def __repr__(self):
return u"<Organization: {}, {}>".format(self.id, self.name)
def __unicode__(self):
return u'%s (%s)' % (self.name, self.id)
@classmethod
def get_by_slug(cls, slug):
return cls.query.filter(cls.slug == slug).first()