---
# System prepended metadata

title: CSC309 Phase2
tags: [CSC309]

---

CSC309 Phase2
===

###### tags: `CSC309`

## Schema
### User
```json=
{
    _id: "default User Id",
    icon_img: "url",
    name: "UserName",
    email: "xxxx@gmail.com",
    password:"encodedpassword_0asdfadfawer",
    description: "I am an Academic waste",
    manageProjectList: ["pid1", "pid2"],
    contributeProjectList: ["pid3", "pid4", "pid5"]
}
```
### Project

```json=
{
    _id: "default project Id",
    name: "projectName",
    teamList: ["teamID1", "teamID2", "teamID3"],
    description: "description about this project"
 }

```
### team
```json=
{
_id: "team id",
name: "teamName",
managers: "user_id",
contributors: [
        {userId: "uid_3", userName: "userName3", 
        taskList: ["tid1", "tid2"]},
        {userId: "uid_4", userName: "userName4",
        taskList: ["tid3", "tid4"]},
        {userId: "uid_4", userName: "userName4",
        taskList: ["tid5"]}
        ],
projects: "pid"
}
```
### task
note that progress is 0-6, where 0 is the initial state and 6 means 100% complete.
```json=
_id："task Id",
name: "taskName",
description: "What is this task",
progess: 1
```

## Actions

### user.js

functions associate with login:

####  readCookie
see Professor sample code
####  updateLoginForm
see Professor sample code
####  login
see Professor sample code
####  logout
see Professor sample code
####  getUserInfo
will be used after user login authentication, in UserPage.jsx.

sample JSON Format: 
```json=
{
    _id: "default User Id",
    icon_img: "url",
    name: "UserName",
    email: "xxxx@gmail.com",
    password:"encodedpassword_0asdfadfawer",
    description: "I am an Academic waste",
    projects:{
        manageProjectList: [Project1, Project2],
        contributeProjectList: [Project3, Project4, Project5]
    }
}
```
Note: Project1, Project2, Project3...  are Project Objects in the Project Collection. 

Current JSON format used in User main page:
```json=
{
    "_id": "default User Id",
    "icon_img": "url",
    "name": "UserName",
    "email": "xxxx@gmail.com",
    "password":"encodedpassword_0asdfadfawer",
    "description": "I am an Academic waste",
    "projects":{
        "manageProjectList": [
            {
                "project_name": "UTOS",
                "pid": "project_id",
                "desc": "a project dedicated to developer community in UOFT"
              },
              {
                "project_name": "Linkus",
                "pid": "project_id",
                "desc": "A project that allows students to find a assignment partner"
              },
              {
                "project_name": "Linkus1",
                "pid": "project_id",
                "desc": "A project that allows students to find a assignment partner"
              },
              {
                "project_name": "Linkus2",
                "pid": "project_id",
                "desc": "A project that allows students to find a assignment partner"
              },
              {
                "project_name": "Linkus4",
                "pid": "project_id",
                "desc": "A project that allows students to find a assignment partner"
              }
        ],
        "contributeProjectList": [
            {
                "project_nam": "CSC309",
                "pid": "project_id",
                "desc": "a project dedicated to developer community in UOFT"
              },
              {
                "project_name": "CSC301A1",
                "pid": "project_id",
                "desc": "A project that allows students to find a assignment partner"
              }
        ]
    }
}
```

### project.js

#### createProject
* Request: PUT
* Purpose: create a project
* Usage: used in **UserPage** in Create New Project button
---

#### createTeam
* Request: PUT
* Purpose: create a Team in TeamCollection, and also update its Project teamList
* Usage: used in **ProjectPage** under **ProjectSection** -> **TeamSection**

---
#### createTask
* Request: PUT
* Purpose: create a Task in TaskCollection, and also append taskid to Team+Contributors+taskList
* Usage: used in **ProjectPage** under **ProjectSection** -> **Simple**

---
#### getProjectInfo
* Request: GET
* Purpose: return a JSON to populate ProjectPage
* Usage: used in **ProjectPage** in `componentWillMount()`
sample JSON Format: 
```json=
{
    _id: "default project Id",
    name: "projectName",
    managers: [
        {userId: "uid_1", userName: "userName1"},
        {userId: "uid_2", userName: "userName2"}
        ],
    teamList: [team1, team2, team3],
    
 }
}
```
note: team1, team2, and team3 are JSON object, it's format is pretty much the same as getTeam object

---
#### getTeam;
* Request: GET
* Purpose: return a Team Json Object
* Usage: used along side getProject

sample JSON Format: 
```json=
{
_id: "team id",
name: "teamName",
contributors: [
        {userId: "uid_3", userName: "userName3", 
        taskList: [task1, task2]},
        {userId: "uid_4", userName: "userName4",
        taskList: [task3]}
        ],
projects: "pid"
}
```

#### getTaskOnTeam;
* Request: GET
* "/user:id/team:id"
* Purpose: return a JSON to populate ContributeProjectPage
* Usage: used in **ContributeProjectPage** in `componentWillMount()`

sample JSON Format: 
```json=
{
    projectId: "asdf3asrdfg30a",
    pid: "project ID",
    projectName: "Utos",
    tid: "team ID",
    teamName: "Fantastic Frontend team",
    taskList: [
      {
        taskId: 1,
        taskDesc: "CSC309 TA meeting",
        taskProcess: 0
      },
      {
        taskId: 2,
        taskDesc: "CSC309 FrontEnd Dev",
        taskProcess: 2
      }
    ]
  }
```

---
#### addMember;
* Request: POST
* Purpose: add member to a team, ubnder Contributors
* Usage: **ProjectPage** under **ProjectSection** during CreateTeam, or in ProjectSection invite member.

---

//update this task's worker Info, and update Team's contributors -> worker -> taskList, append (POST)
#### updateTaskContributor
* Request: PATCH or POST
* Purpose: update this task's worker Info, and update Team's contributors -> contributor -> taskList (have to deletee from the orginal user and add into new)
* Usage: **ProjectPage** under **ProjectSection** -> ??? (currently not sure since we are using drag and drop), probably have some sort of submit button later.

//update this task's progress (PATCH)
#### updateTaskProgress
* Request: PATCH
* Purpose: update this task's progress
* Usage: **ContributeProjectPage** -> **TaskPopupAction**.
