Skip to content

Commit 79efa8d

Browse files
authored
Merge pull request #1238 from code-corps/add-categories-to-user-and-project
Add categories to user and project views
2 parents 90fa278 + da880e4 commit 79efa8d

File tree

6 files changed

+15
-2
lines changed

6 files changed

+15
-2
lines changed

lib/code_corps_web/controllers/project_controller.ex

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ defmodule CodeCorpsWeb.ProjectController do
4545
end
4646

4747
@preloads [
48-
:donation_goals, :github_repos, [organization: :stripe_connect_account],
48+
:categories, :donation_goals, :github_repos,
49+
[organization: :stripe_connect_account],
4950
:project_categories, :project_skills, :project_users, :stripe_connect_plan,
5051
:task_lists, :tasks
5152
]

lib/code_corps_web/controllers/user_controller.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ defmodule CodeCorpsWeb.UserController do
8181
end
8282

8383
@preloads [
84-
:github_app_installations, :project_users, :slugged_route,
84+
:categories, :github_app_installations, :project_users, :slugged_route,
8585
:stripe_connect_subscriptions, :stripe_platform_card,
8686
:stripe_platform_customer, :user_categories, :user_roles, :user_skills
8787
]

lib/code_corps_web/views/project_view.ex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ defmodule CodeCorpsWeb.ProjectView do
1717
has_one :organization, type: "organization", field: :organization_id
1818
has_one :stripe_connect_plan, serializer: CodeCorpsWeb.StripeConnectPlanView
1919

20+
has_many :categories, serializer: CodeCorpsWeb.CategoryView, identifiers: :always
2021
has_many :donation_goals, serializer: CodeCorpsWeb.DonationGoalView, identifiers: :always
2122
has_many :github_repos, serializer: CodeCorpsWeb.GithubRepoView, identifiers: :always
2223
has_many :project_categories, serializer: CodeCorpsWeb.ProjectCategoryView, identifiers: :always

lib/code_corps_web/views/user_view.ex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ defmodule CodeCorpsWeb.UserView do
1717
has_one :stripe_platform_card, serializer: CodeCorpsWeb.StripePlatformCardView
1818
has_one :stripe_platform_customer, serializer: CodeCorpsWeb.StripePlatformCustomerView
1919

20+
has_many :categories, serializer: CodeCorpsWeb.CategoryView, identifiers: :always
2021
has_many :github_app_installations, serializer: CodeCorpsWeb.GithubAppInstallationView, identifiers: :always
2122
has_many :project_users, serializer: CodeCorpsWeb.ProjectUserView, identifiers: :always
2223
has_many :stripe_connect_subscriptions, serializer: CodeCorpsWeb.StripeConnectSubscriptionView, identifiers: :always

test/lib/code_corps_web/views/project_view_test.exs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ defmodule CodeCorpsWeb.ProjectViewTest do
4141
},
4242
"id" => project.id |> Integer.to_string,
4343
"relationships" => %{
44+
"categories" => %{
45+
"data" => [
46+
%{"id" => project_category.category_id |> Integer.to_string, "type" => "category"}
47+
]
48+
},
4449
"donation-goals" => %{"data" => [
4550
%{
4651
"id" => donation_goal.id |> Integer.to_string,

test/lib/code_corps_web/views/user_view_test.exs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ defmodule CodeCorpsWeb.UserViewTest do
5151
"website" => user.website
5252
},
5353
"relationships" => %{
54+
"categories" => %{
55+
"data" => [
56+
%{"id" => user_category.category_id |> Integer.to_string, "type" => "category"}
57+
]
58+
},
5459
"github-app-installations" => %{
5560
"data" => [
5661
%{"id" => github_app_installation.id |> Integer.to_string, "type" => "github-app-installation"}

0 commit comments

Comments
 (0)