Skip to content

Commit

Permalink
TODOs for backend updates for portals
Browse files Browse the repository at this point in the history
  • Loading branch information
mshriver committed Jun 17, 2024
1 parent 5813a7e commit 742173e
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# TODO IQE-2953 handle portal administration
2 changes: 2 additions & 0 deletions backend/ibutsu_server/controllers/admin/user_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,5 @@ def admin_delete_user(id_, token_info=None, user=None):
session.delete(requested_user)
session.commit()
return "OK", 200

# TODO IQE-2953 handle portal association with users
5 changes: 5 additions & 0 deletions backend/ibutsu_server/controllers/dashboard_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ def add_dashboard(dashboard=None, token_info=None, user=None):
if not connexion.request.is_json:
return "Bad request, JSON required", 400
dashboard = Dashboard.from_dict(**connexion.request.get_json())
# TODO IQE-2953 handle portal_id and project_id
if dashboard.project_id and not project_has_user(dashboard.project_id, user):
return "Forbidden", 403
if dashboard.user_id and not User.query.get(dashboard.user_id):
Expand All @@ -40,6 +41,7 @@ def get_dashboard(id_, token_info=None, user=None):
dashboard = Dashboard.query.get(id_)
if not dashboard:
return "Dashboard not found", 404
# TODO IQE-2953 handle portal_id and project_id
if dashboard and dashboard.project and not project_has_user(dashboard.project, user):
return "Forbidden", 403
return dashboard.to_dict()
Expand All @@ -63,6 +65,7 @@ def get_dashboard_list(
"""
query = Dashboard.query
project = None
# TODO IQE-2953 handle portal_id and project_id
if "project_id" in connexion.request.args:
project = Project.query.get(connexion.request.args["project_id"])
if project:
Expand Down Expand Up @@ -106,6 +109,7 @@ def update_dashboard(id_, dashboard=None, token_info=None, user=None):
if not connexion.request.is_json:
return "Bad request, JSON required", 400
dashboard_dict = connexion.request.get_json()
# TODO IQE-2953 handle portal_id and project_id
if dashboard_dict.get("metadata", {}).get("project") and not project_has_user(
dashboard_dict["metadata"]["project"], user
):
Expand Down Expand Up @@ -133,6 +137,7 @@ def delete_dashboard(id_, token_info=None, user=None):
dashboard = Dashboard.query.get(id_)
if not dashboard:
return "Not Found", 404
# TODO IQE-2953 handle portal_id and project_id
if not project_has_user(dashboard.project, user):
return "Forbidden", 403
widget_configs = WidgetConfig.query.filter(WidgetConfig.dashboard_id == dashboard.id).all()
Expand Down
1 change: 1 addition & 0 deletions backend/ibutsu_server/controllers/portal_controller.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# TODO IQE-2953 Controller for portal handling
4 changes: 4 additions & 0 deletions backend/ibutsu_server/controllers/widget_config_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def add_widget_config(widget_config=None, token_info=None, user=None):
if not data.get("weight"):
data["weight"] = 10
# Look up the project id
# TODO IQE-2953 Process portal_id or project_id
if data.get("project"):
project = get_project(data.pop("project"))
if not project_has_user(project, user):
Expand Down Expand Up @@ -73,6 +74,7 @@ def get_widget_config_list(filter_=None, page=1, page_size=25):
query = WidgetConfig.query
if filter_:
for filter_string in filter_:
# TODO IQE-2953 Process portal_id or project_id
if "project" in filter_string:
filter_clause = or_(
WidgetConfig.project_id.is_(None),
Expand Down Expand Up @@ -114,6 +116,7 @@ def update_widget_config(id_, body=None, widget_config=None, token_info=None, us
if data.get("widget") and data["widget"] not in WIDGET_TYPES.keys():
return "Bad request, widget type does not exist", 400
# Look up the project id
# TODO IQE-2953 Process portal_id or project_id
if data.get("project"):
project = get_project(data.pop("project"))
if not project_has_user(project, user):
Expand Down Expand Up @@ -149,6 +152,7 @@ def delete_widget_config(id_, token_info=None, user=None):
if not widget_config:
return "Not Found", 404
else:
# TODO IQE-2953 Process portal_id or project_id
if widget_config.project and not project_has_user(widget_config.project, user):
return "Forbidden", 403
session.delete(widget_config)
Expand Down
3 changes: 3 additions & 0 deletions backend/ibutsu_server/db/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ class Dashboard(Model, ModelMixin):
title = Column(Text, index=True)
description = Column(Text, default="")
filters = Column(Text, default="")
#TODO IQE-2953 portal_id, nullable, indexed
project_id = Column(PortableUUID(), ForeignKey("projects.id"), index=True)
user_id = Column(PortableUUID(), ForeignKey("users.id"), index=True)
widgets = relationship("WidgetConfig")
Expand Down Expand Up @@ -146,6 +147,7 @@ def to_dict(self, with_owner=False):
project_dict["defaultDashboard"] = self.default_dashboard.to_dict()
return project_dict

#TODO IQE-2953 Portal model

class Report(Model, ModelMixin):
__tablename__ = "reports"
Expand Down Expand Up @@ -208,6 +210,7 @@ class WidgetConfig(Model, ModelMixin):
__tablename__ = "widget_configs"
navigable = Column(Boolean, index=True)
params = Column(mutable_json_type(dbtype=PortableJSON()))
# TODO IQE-2953 portal_id
project_id = Column(PortableUUID(), ForeignKey("projects.id"), index=True)
dashboard_id = Column(PortableUUID(), ForeignKey("dashboards.id"), index=True)
title = Column(Text, index=True)
Expand Down
2 changes: 2 additions & 0 deletions backend/ibutsu_server/db/upgrades.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,3 +175,5 @@ def upgrade_5(session):
"projects",
Column("default_dashboard_id", PortableUUID(), ForeignKey("dashboards.id")),
)

#TODO IQE-2953 upgrade_6 for portal schema updates
1 change: 1 addition & 0 deletions backend/ibutsu_server/util/portals.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# TODO IQE-2953 handle portal entity utils

0 comments on commit 742173e

Please sign in to comment.