Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: flask-admin - exclude created_at/updated_at so models can be saved #1551

Merged
merged 1 commit into from
Jan 27, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions redash/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def process_formdata(self, valuelist):
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):
Expand All @@ -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):
Expand Down
3 changes: 3 additions & 0 deletions redash/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down