diff --git a/lib/code_corps_web/controllers/project_controller.ex b/lib/code_corps_web/controllers/project_controller.ex index 8cb11f703..8c8d48711 100644 --- a/lib/code_corps_web/controllers/project_controller.ex +++ b/lib/code_corps_web/controllers/project_controller.ex @@ -45,7 +45,8 @@ defmodule CodeCorpsWeb.ProjectController do end @preloads [ - :donation_goals, :github_repos, [organization: :stripe_connect_account], + :categories, :donation_goals, :github_repos, + [organization: :stripe_connect_account], :project_categories, :project_skills, :project_users, :stripe_connect_plan, :task_lists, :tasks ] diff --git a/lib/code_corps_web/controllers/user_controller.ex b/lib/code_corps_web/controllers/user_controller.ex index 503b22dac..b0de51a90 100644 --- a/lib/code_corps_web/controllers/user_controller.ex +++ b/lib/code_corps_web/controllers/user_controller.ex @@ -81,7 +81,7 @@ defmodule CodeCorpsWeb.UserController do end @preloads [ - :github_app_installations, :project_users, :slugged_route, + :categories, :github_app_installations, :project_users, :slugged_route, :stripe_connect_subscriptions, :stripe_platform_card, :stripe_platform_customer, :user_categories, :user_roles, :user_skills ] diff --git a/lib/code_corps_web/views/project_view.ex b/lib/code_corps_web/views/project_view.ex index 0509c47c5..4a1630f8e 100644 --- a/lib/code_corps_web/views/project_view.ex +++ b/lib/code_corps_web/views/project_view.ex @@ -17,6 +17,7 @@ defmodule CodeCorpsWeb.ProjectView do has_one :organization, type: "organization", field: :organization_id has_one :stripe_connect_plan, serializer: CodeCorpsWeb.StripeConnectPlanView + has_many :categories, serializer: CodeCorpsWeb.CategoryView, identifiers: :always has_many :donation_goals, serializer: CodeCorpsWeb.DonationGoalView, identifiers: :always has_many :github_repos, serializer: CodeCorpsWeb.GithubRepoView, identifiers: :always has_many :project_categories, serializer: CodeCorpsWeb.ProjectCategoryView, identifiers: :always diff --git a/lib/code_corps_web/views/user_view.ex b/lib/code_corps_web/views/user_view.ex index dc0f57325..aabc87c19 100644 --- a/lib/code_corps_web/views/user_view.ex +++ b/lib/code_corps_web/views/user_view.ex @@ -17,6 +17,7 @@ defmodule CodeCorpsWeb.UserView do has_one :stripe_platform_card, serializer: CodeCorpsWeb.StripePlatformCardView has_one :stripe_platform_customer, serializer: CodeCorpsWeb.StripePlatformCustomerView + has_many :categories, serializer: CodeCorpsWeb.CategoryView, identifiers: :always has_many :github_app_installations, serializer: CodeCorpsWeb.GithubAppInstallationView, identifiers: :always has_many :project_users, serializer: CodeCorpsWeb.ProjectUserView, identifiers: :always has_many :stripe_connect_subscriptions, serializer: CodeCorpsWeb.StripeConnectSubscriptionView, identifiers: :always diff --git a/test/lib/code_corps_web/views/project_view_test.exs b/test/lib/code_corps_web/views/project_view_test.exs index eb6e54ecc..ed91e32a9 100644 --- a/test/lib/code_corps_web/views/project_view_test.exs +++ b/test/lib/code_corps_web/views/project_view_test.exs @@ -41,6 +41,11 @@ defmodule CodeCorpsWeb.ProjectViewTest do }, "id" => project.id |> Integer.to_string, "relationships" => %{ + "categories" => %{ + "data" => [ + %{"id" => project_category.category_id |> Integer.to_string, "type" => "category"} + ] + }, "donation-goals" => %{"data" => [ %{ "id" => donation_goal.id |> Integer.to_string, diff --git a/test/lib/code_corps_web/views/user_view_test.exs b/test/lib/code_corps_web/views/user_view_test.exs index fd8ddd488..3440acb4c 100644 --- a/test/lib/code_corps_web/views/user_view_test.exs +++ b/test/lib/code_corps_web/views/user_view_test.exs @@ -51,6 +51,11 @@ defmodule CodeCorpsWeb.UserViewTest do "website" => user.website }, "relationships" => %{ + "categories" => %{ + "data" => [ + %{"id" => user_category.category_id |> Integer.to_string, "type" => "category"} + ] + }, "github-app-installations" => %{ "data" => [ %{"id" => github_app_installation.id |> Integer.to_string, "type" => "github-app-installation"}