Skip to content

Commit

Permalink
Merge pull request #51 from Killerrekt/master
Browse files Browse the repository at this point in the history
hopefully backend redeploys :'(
  • Loading branch information
aditansh authored Mar 17, 2024
2 parents 726a9f3 + 3396d37 commit f5177a0
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 5 deletions.
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
version: '3'
services:

api:
build: .
ports:
Expand Down
32 changes: 32 additions & 0 deletions internal/controllers/admin_teams_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,3 +188,35 @@ func GetTeamLeader(ctx echo.Context) error {
})

}

/*func GetAllFresherTeams(ctx echo.Context) error {
team, err := teamService.GetAllFresherTeam()
if err != nil {
return ctx.JSON(http.StatusBadRequest, map[string]string{
"message": "Failed to fetch teams",
"data": err.Error(),
"status": "false",
})
}
return ctx.JSON(http.StatusAccepted, map[string]interface{}{
"message": "Successfully fetched teams",
"data": team,
"status": "true",
})
}
func GetAllFemaleTeams(ctx echo.Context) error {
team, err := teamService.GetAllFemaleTeams()
if err != nil {
return ctx.JSON(http.StatusBadRequest, map[string]string{
"message": "Failed to fetch teams",
"data": err.Error(),
"status": "false",
})
}
return ctx.JSON(http.StatusAccepted, map[string]interface{}{
"message": "Successfully fetched teams",
"data": team,
"status": "true",
})
}*/
4 changes: 2 additions & 2 deletions internal/controllers/idea_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func CreateIdea(ctx echo.Context) error {
user := ctx.Get("user").(*models.User)

if user.TeamID == uuid.Nil {
return ctx.JSON(http.StatusForbidden, map[string]string{
return ctx.JSON(http.StatusConflict, map[string]string{
"message": "user is not in a team",
"status": "fail",
})
Expand Down Expand Up @@ -142,7 +142,7 @@ func UpdateIdea(ctx echo.Context) error {
}

if !user.IsLeader {
return ctx.JSON(http.StatusUnauthorized, map[string]string{
return ctx.JSON(http.StatusForbidden, map[string]string{
"message": "user is not a leader",
"status": "fail",
})
Expand Down
6 changes: 3 additions & 3 deletions internal/controllers/project_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func CreateProject(ctx echo.Context) error {
user := ctx.Get("user").(*models.User)

if user.TeamID == uuid.Nil {
return ctx.JSON(http.StatusForbidden, map[string]string{
return ctx.JSON(http.StatusConflict, map[string]string{
"message": "user is not in a team",
"status": "fail",
})
Expand Down Expand Up @@ -135,14 +135,14 @@ func UpdateProject(ctx echo.Context) error {
user := ctx.Get("user").(*models.User)

if !user.IsLeader {
return ctx.JSON(http.StatusUnauthorized, map[string]string{
return ctx.JSON(http.StatusForbidden, map[string]string{
"message": "user is not a leader",
"status": "fail",
})
}

if user.TeamID == uuid.Nil {
return ctx.JSON(http.StatusForbidden, map[string]string{
return ctx.JSON(http.StatusConflict, map[string]string{
"message": "The user is not in a team",
"status": "fail",
})
Expand Down
3 changes: 3 additions & 0 deletions internal/routes/admin_routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,7 @@ func AdminRoutes(incomingRoutes *echo.Echo) {

admin.GET("/projects/all", controllers.GetAllProject)
admin.GET("/ideas/all", controllers.GetAllIdeas)

//admin.GET("/team/freshers", controllers.GetAllFresherTeams)
//admin.GET("/team/females", controllers.GetAllFemaleTeams)
}

0 comments on commit f5177a0

Please sign in to comment.