Skip to content

Commit 5dd7826

Browse files
committed
tryign to reset views
1 parent 62cfd10 commit 5dd7826

File tree

5 files changed

+35
-44
lines changed

5 files changed

+35
-44
lines changed

lib/code_corps_web/views/comment_view.ex

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ defmodule CodeCorpsWeb.CommentView do
22
@moduledoc false
33
use CodeCorpsWeb, :view
44
use JaSerializer.PhoenixView
5-
use JSONAPI.View, type: "comment"
65

76
attributes [
87
:body, :created_at, :created_from, :inserted_at, :markdown, :modified_at,

lib/code_corps_web/views/project_view.ex

-9
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,6 @@ defmodule CodeCorpsWeb.ProjectView do
55

66
use CodeCorpsWeb, :view
77
use JaSerializer.PhoenixView
8-
use JSONAPI.View, type: "project"
9-
10-
def fields do
11-
[:approved, :can_activate_donations, :cloudinary_public_id,
12-
:description, :donations_active, :icon_thumb_url,
13-
:icon_large_url, :inserted_at, :long_description_body,
14-
:long_description_markdown, :should_link_externally, :slug, :title,
15-
:total_monthly_donated, :updated_at, :website]
16-
end
178

189
attributes [
1910
:approval_requested,

lib/code_corps_web/views/task_list_view.ex

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ defmodule CodeCorpsWeb.TaskListView do
1515

1616
def fields, do: [:done, :inbox, :name, :order, :pull_requests, :inserted_at, :updated_at]
1717

18-
def relationships do
19-
[project: ProjectView, tasks: TaskView]
20-
end
18+
# def relationships do
19+
# [project: ProjectView, tasks: TaskView]
20+
# end
2121
end

lib/code_corps_web/views/task_view.ex

+31-31
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,39 @@
11
defmodule CodeCorpsWeb.TaskView do
22
@moduledoc false
33
use CodeCorpsWeb, :view
4-
use JSONAPI.View, type: "task"
4+
use JaSerializer.PhoenixView
55

6-
alias CodeCorpsWeb.{GithubIssueView, GithubPullRequestView, GithubRepoView, ProjectView,
7-
TaskListView, UserView, UserTaskView, CommentView, TaskSkillView}
6+
attributes [
7+
:archived, :body, :created_at, :created_from, :has_github_pull_request,
8+
:inserted_at, :markdown, :modified_at, :modified_from, :number, :order,
9+
:overall_status, :status, :title, :updated_at
10+
]
811

9-
def fields do
10-
[:archived, :body, :created_at, :created_from, :inserted_at, :markdown,
11-
:modified_at, :modified_from, :number, :order, :status, :title, :updated_at]
12-
end
13-
14-
def relationships do
15-
[comments: CommentView, task_skills: TaskSkillView]
16-
end
12+
has_one :github_issue, type: "github-issue", field: :github_issue_id
13+
has_one :github_pull_request, serializer: CodeCorpsWeb.GithubPullRequestView, identifiers: :always
14+
has_one :github_repo, type: "github-repo", field: :github_repo_id
15+
has_one :project, type: "project", field: :project_id
16+
has_one :task_list, type: "task-list", field: :task_list_id
17+
has_one :user, type: "user", field: :user_id
18+
has_one :user_task, serializer: CodeCorpsWeb.UserTaskView, identifiers: :always
1719

18-
# <<<<<<< HEAD
19-
# has_many :comments, serializer: CodeCorpsWeb.CommentView, identifiers: :always
20-
# has_many :task_skills, serializer: CodeCorpsWeb.TaskSkillView, identifiers: :always
20+
has_many :comments, serializer: CodeCorpsWeb.CommentView, identifiers: :always
21+
has_many :task_skills, serializer: CodeCorpsWeb.TaskSkillView, identifiers: :always
2122

22-
# def has_github_pull_request(%{
23-
# github_pull_request: %CodeCorps.GithubPullRequest{}
24-
# }), do: true
25-
# def has_github_pull_request(%{github_pull_request: nil}), do: false
23+
def has_github_pull_request(%{
24+
github_pull_request: %CodeCorps.GithubPullRequest{}
25+
}), do: true
26+
def has_github_pull_request(%{github_pull_request: nil}), do: false
2627

27-
# def overall_status(%{
28-
# github_pull_request: %CodeCorps.GithubPullRequest{merged: merged, state: state}
29-
# }, _conn) do
30-
# case merged do
31-
# true -> "merged"
32-
# false -> state
33-
# end
34-
# end
35-
# def overall_status(%{github_pull_request: nil, status: status}, _conn) do
36-
# status
37-
# end
38-
# =======
39-
end
28+
def overall_status(%{
29+
github_pull_request: %CodeCorps.GithubPullRequest{merged: merged, state: state}
30+
}, _conn) do
31+
case merged do
32+
true -> "merged"
33+
false -> state
34+
end
35+
end
36+
def overall_status(%{github_pull_request: nil, status: status}, _conn) do
37+
status
38+
end
39+
end

test/lib/code_corps_web/views/task_list_view_test.exs

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
defmodule CodeCorpsWeb.TaskListViewTest do
22
use CodeCorpsWeb.ViewCase
33

4+
@tag :wip
45
test "renders all attributes and relationships properly" do
56
project = insert(:project)
67
task_list = insert(:task_list, order: 1000, project: project)

0 commit comments

Comments
 (0)