Skip to content
This repository has been archived by the owner on Dec 19, 2021. It is now read-only.

Initial refactoring of the dashboard logic #393

Merged
merged 12 commits into from
Oct 25, 2021
Prev Previous commit
Next Next commit
Rename from widget to Dashboard to match UI
Right now this is duplicated, because the frontend needs to be updated
to use the endpoint dashboard instead of widget.
  • Loading branch information
NickSchimek committed Oct 25, 2021
commit 634b8b441f690f7a836bb0317e9a3d837b0063c5
2 changes: 2 additions & 0 deletions config/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from resources.notes import Notes, Note
from resources.lease import Lease, Leases
from resources.widgets import Widgets
from resources.dashboard_resource import DashboardResource


class Routes:
Expand All @@ -35,6 +36,7 @@ def routing(app):
api.add_resource(ArchiveUser, "user/archive/<int:user_id>")
api.add_resource(UserLogin, "login")
api.add_resource(Widgets, "widgets")
api.add_resource(DashboardResource, "dashboard")
api.add_resource(UserAccessRefresh, "refresh")
api.add_resource(StaffTenants, "staff-tenants")
api.add_resource(Tenants, "tenants")
Expand Down
10 changes: 10 additions & 0 deletions resources/dashboard_resource.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from flask_restful import Resource
from utils.authorizations import pm_level_required

from models.dashboard import Dashboard


class DashboardResource(Resource):
@pm_level_required
def get(self):
return Dashboard.json()
9 changes: 9 additions & 0 deletions tests/integration/test_dashboard_resource.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import pytest


@pytest.mark.usefixtures("client_class", "empty_test_db")
class TestDashboardResource:
def test_GET(self, valid_header):
response = self.client.get("/api/dashboard", headers=valid_header)

assert response.status_code == 200
4 changes: 1 addition & 3 deletions tests/integration/test_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@

@pytest.mark.usefixtures("client_class", "empty_test_db")
class TestWidgets:
def test_get_widgets(
self, valid_header, create_ticket, create_property_manager, create_property
):
def test_get_widgets(self, valid_header):
response = self.client.get("/api/widgets", headers=valid_header)

assert response.status_code == 200