Packages

This library is a summary of the functions that are generally required for Matching Web service development.

Current section

Files

Jump to
servicex_matching lib servicex_matching_web views project_view.ex
Raw

lib/servicex_matching_web/views/project_view.ex

defmodule ServicexMatchingWeb.ProjectView do
use ServicexMatchingWeb, :view
alias ServicexMatchingWeb.ProjectView
alias ServicexMatching.Organizations.Project
alias AppExUtils.Calendar.CalendarUtil
def render("index.json", %{projects: projects}) do
render_many(projects, ProjectView, "project.json")
end
def render("show.json", %{project: project}) do
render_one(project, ProjectView, "project.json")
end
def render("project.json", %{project: project}) do
project_map = %{id: project.id,
title: project.title,
img_utl: project.img_utl,
back_ground_img_url: project.back_ground_img_url,
overview: project.overview,
description: project.description,
project_category: project.project_category,
project_start_date: CalendarUtil.convert_time_utc2local(project.project_start_date),
project_end_date: CalendarUtil.convert_time_utc2local(project.project_end_date),
work_start_date: CalendarUtil.convert_time_utc2local(project.work_start_date),
work_end_date: CalendarUtil.convert_time_utc2local(project.work_end_date),
status: project.status,
status_disp: Project.get_status_disp(project.status),
pay: project.pay,
work_style: project.work_style,
location: project.location,
}
project_map =
if Ecto.assoc_loaded?(project.organization) do
Map.put(project_map, :organization, project.organization)
else
Map.put(project_map, :organization, nil)
end
end
end