Skip to content

Commit 4068aa5

Browse files
committed
Add organizations to user
1 parent a494af2 commit 4068aa5

File tree

5 files changed

+13
-13
lines changed

5 files changed

+13
-13
lines changed

lib/code_corps/model/user.ex

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,29 +40,23 @@ defmodule CodeCorps.User do
4040
field :username, :string
4141
field :website, :string
4242

43+
has_one :github_app_installation, CodeCorps.GithubAppInstallation
4344
has_one :slugged_route, SluggedRoute
4445

4546
has_many :github_app_installations, CodeCorps.GithubAppInstallation
46-
47+
has_many :organizations, CodeCorps.Organization, foreign_key: :owner_id
4748
has_many :project_users, CodeCorps.ProjectUser
48-
4949
has_many :stripe_connect_customers, CodeCorps.StripeConnectCustomer
5050
has_many :stripe_connect_subscriptions, CodeCorps.StripeConnectSubscription
51-
5251
has_one :stripe_platform_card, CodeCorps.StripePlatformCard
5352
has_one :stripe_platform_customer, CodeCorps.StripePlatformCustomer
54-
5553
has_many :user_categories, CodeCorps.UserCategory
5654
has_many :categories, through: [:user_categories, :category]
57-
5855
has_many :user_roles, CodeCorps.UserRole
5956
has_many :roles, through: [:user_roles, :role]
60-
6157
has_many :user_skills, CodeCorps.UserSkill
6258
has_many :skills, through: [:user_skills, :skill]
6359

64-
has_one :github_app_installation, CodeCorps.GithubAppInstallation
65-
6660
belongs_to :github_user, CodeCorps.GithubUser
6761

6862
timestamps()

lib/code_corps_web/controllers/user_controller.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ defmodule CodeCorpsWeb.UserController do
8181
end
8282

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

lib/code_corps_web/views/user_view.ex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ defmodule CodeCorpsWeb.UserView do
1919

2020
has_many :categories, serializer: CodeCorpsWeb.CategoryView, identifiers: :always
2121
has_many :github_app_installations, serializer: CodeCorpsWeb.GithubAppInstallationView, identifiers: :always
22+
has_many :organizations, serializer: CodeCorpsWeb.OrganizationView, identifiers: :always
2223
has_many :project_users, serializer: CodeCorpsWeb.ProjectUserView, identifiers: :always
2324
has_many :stripe_connect_subscriptions, serializer: CodeCorpsWeb.StripeConnectSubscriptionView, identifiers: :always
2425
has_many :user_categories, serializer: CodeCorpsWeb.UserCategoryView, identifiers: :always

priv/repo/structure.sql

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
-- PostgreSQL database dump
33
--
44

5-
-- Dumped from database version 10.0
6-
-- Dumped by pg_dump version 10.0
5+
-- Dumped from database version 9.5.10
6+
-- Dumped by pg_dump version 10.1
77

88
SET statement_timeout = 0;
99
SET lock_timeout = 0;
@@ -4159,4 +4159,3 @@ ALTER TABLE ONLY users
41594159
--
41604160

41614161
INSERT INTO "schema_migrations" (version) VALUES (20160723215749), (20160804000000), (20160804001111), (20160805132301), (20160805203929), (20160808143454), (20160809214736), (20160810124357), (20160815125009), (20160815143002), (20160816020347), (20160816034021), (20160817220118), (20160818000944), (20160818132546), (20160820113856), (20160820164905), (20160822002438), (20160822004056), (20160822011624), (20160822020401), (20160822044612), (20160830081224), (20160830224802), (20160911233738), (20160912002705), (20160912145957), (20160918003206), (20160928232404), (20161003185918), (20161019090945), (20161019110737), (20161020144622), (20161021131026), (20161031001615), (20161121005339), (20161121014050), (20161121043941), (20161121045709), (20161122015942), (20161123081114), (20161123150943), (20161124085742), (20161125200620), (20161126045705), (20161127054559), (20161205024856), (20161207112519), (20161209192504), (20161212005641), (20161214005935), (20161215052051), (20161216051447), (20161218005913), (20161219160401), (20161219163909), (20161220141753), (20161221085759), (20161226213600), (20161231063614), (20170102130055), (20170102181053), (20170104113708), (20170104212623), (20170104235423), (20170106013143), (20170115035159), (20170115230549), (20170121014100), (20170131234029), (20170201014901), (20170201025454), (20170201035458), (20170201183258), (20170220032224), (20170224233516), (20170226050552), (20170228085250), (20170308214128), (20170308220713), (20170308222552), (20170313130611), (20170318032449), (20170318082740), (20170324194827), (20170424215355), (20170501225441), (20170505224222), (20170526095401), (20170602000208), (20170622205732), (20170626231059), (20170628092119), (20170628213609), (20170629183404), (20170630140136), (20170706132431), (20170707213648), (20170711122252), (20170717092127), (20170725060612), (20170727052644), (20170731130121), (20170814131722), (20170913114958), (20170921014405), (20170925214512), (20170925230419), (20170926134646), (20170927100300), (20170928234412), (20171003134956), (20171003225853), (20171006063358), (20171006161407), (20171012215106), (20171012221231), (20171016125229), (20171016125516), (20171016223356), (20171016235656), (20171017235433), (20171019191035), (20171025184225), (20171026010933), (20171027061833), (20171028011642), (20171028173508), (20171030182857), (20171031232023), (20171031234356), (20171101023309), (20171104013543), (20171106045740), (20171106050209), (20171106103153), (20171106200036), (20171109231538), (20171110001134), (20171114010851), (20171114033357), (20171114225214), (20171114225713), (20171114232534), (20171115201624), (20171115225358), (20171119004204), (20171121075226), (20171121144138), (20171123065902), (20171127215847), (20171201073818), (20171205161052), (20171213062707);
4162-

test/lib/code_corps_web/views/user_view_test.exs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ defmodule CodeCorpsWeb.UserViewTest do
1515
user_category = insert(:user_category, user: user)
1616
user_role = insert(:user_role, user: user)
1717
user_skill = insert(:user_skill, user: user)
18+
organization = insert(:organization, owner: user)
1819
project_user = insert(:project_user, user: user)
1920

2021
host = Application.get_env(:code_corps, :asset_host)
@@ -61,6 +62,11 @@ defmodule CodeCorpsWeb.UserViewTest do
6162
%{"id" => github_app_installation.id |> Integer.to_string, "type" => "github-app-installation"}
6263
]
6364
},
65+
"organizations" => %{
66+
"data" => [
67+
%{"id" => organization.id |> Integer.to_string, "type" => "organization"}
68+
]
69+
},
6470
"project-users" => %{
6571
"data" => [
6672
%{"id" => project_user.id |> Integer.to_string, "type" => "project-user"}

0 commit comments

Comments
 (0)