mirror of
https://github.com/valitydev/redash.git
synced 2024-11-06 09:05:17 +00:00
add org_id to favorites
This commit is contained in:
parent
bcf49a700b
commit
9feb7773ce
26
migrations/versions/e7004224f284_add_org_id_to_favorites.py
Normal file
26
migrations/versions/e7004224f284_add_org_id_to_favorites.py
Normal file
@ -0,0 +1,26 @@
|
||||
"""add_org_id_to_favorites
|
||||
|
||||
Revision ID: e7004224f284
|
||||
Revises: d4c798575877
|
||||
Create Date: 2018-05-10 09:46:31.169938
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'e7004224f284'
|
||||
down_revision = 'd4c798575877'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.add_column('favorites', sa.Column('org_id', sa.Integer(), nullable=True))
|
||||
op.create_foreign_key(None, 'favorites', 'organizations', ['org_id'], ['id'])
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.drop_constraint(None, 'favorites', type_='foreignkey')
|
||||
op.drop_column('favorites', 'org_id')
|
@ -14,7 +14,7 @@ class QueryFavoriteResource(BaseResource):
|
||||
query = get_object_or_404(models.Query.get_by_id_and_org, query_id, self.current_org)
|
||||
require_access(query.groups, self.current_user, view_only)
|
||||
|
||||
fav = models.Favorite(object=query, user=self.current_user)
|
||||
fav = models.Favorite(org_id=self.current_org.id, object=query, user=self.current_user)
|
||||
models.db.session.add(fav)
|
||||
models.db.session.commit()
|
||||
|
||||
@ -35,7 +35,7 @@ class DashboardFavoriteListResource(BaseResource):
|
||||
class DashboardFavoriteResource(BaseResource):
|
||||
def post(self, object_id):
|
||||
dashboard = get_object_or_404(models.Dashboard.get_by_slug_and_org, object_id, self.current_org)
|
||||
fav = models.Favorite(object=dashboard, user=self.current_user)
|
||||
fav = models.Favorite(org_id=self.current_org.id, object=dashboard, user=self.current_user)
|
||||
models.db.session.add(fav)
|
||||
models.db.session.commit()
|
||||
|
||||
|
@ -1087,6 +1087,7 @@ class Favorite(TimestampMixin, db.Model):
|
||||
__tablename__ = "favorites"
|
||||
|
||||
id = Column(db.Integer, primary_key=True)
|
||||
org_id = Column(db.Integer, db.ForeignKey("organizations.id"))
|
||||
|
||||
object_type = Column(db.Unicode(255))
|
||||
object_id = Column(db.Integer)
|
||||
|
Loading…
Reference in New Issue
Block a user