Skip to content

Commit

Permalink
Allow look at student's gradings - Part of MeetPlan/MeetPlanFrontend#10
Browse files Browse the repository at this point in the history
  • Loading branch information
mytja committed Apr 22, 2022
1 parent 7f89f2d commit 872b436
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion config.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"database_name":"sqlite3","database_config":"MeetPlanDB/meetplan.db","debug":true,"host":"127.0.0.1:8000","school_name":"Testna šola","school_address":"Testna ulica 1","school_city":"Ljubljana","school_country":"Slovenija","school_post_code":1000,"parent_view_grades":false,"parent_view_absences":true,"parent_view_homework":true}
{"database_name":"sqlite3","database_config":"MeetPlanDB/meetplan.db","debug":true,"host":"127.0.0.1:8000","school_name":"Testna šola","school_address":"Testna ulica 1","school_city":"Ljubljana","school_country":"Slovenija","school_post_code":1000,"parent_view_grades":false,"parent_view_absences":true,"parent_view_homework":true,"parent_view_gradings":true}
8 changes: 8 additions & 0 deletions httphandlers/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ type ParentConfig struct {
ParentViewGrades bool `json:"parent_view_grades"`
ParentViewAbsences bool `json:"parent_view_absences"`
ParentViewHomework bool `json:"parent_view_homework"`
ParentViewGradings bool `json:"parent_view_gradings"`
}

func (server *httpImpl) GetConfig(w http.ResponseWriter, r *http.Request) {
Expand Down Expand Up @@ -53,6 +54,11 @@ func (server *httpImpl) UpdateConfiguration(w http.ResponseWriter, r *http.Reque
WriteBadRequest(w)
return
}
parentViewGradings, err := strconv.ParseBool(r.FormValue("parent_view_gradings"))
if err != nil {
WriteBadRequest(w)
return
}
server.config.SchoolPostCode = schoolPostCode
server.config.SchoolCountry = r.FormValue("school_country")
server.config.SchoolAddress = r.FormValue("school_address")
Expand All @@ -61,6 +67,7 @@ func (server *httpImpl) UpdateConfiguration(w http.ResponseWriter, r *http.Reque
server.config.ParentViewGrades = parentViewGrades
server.config.ParentViewAbsences = parentViewAbsences
server.config.ParentViewHomework = parentViewHomework
server.config.ParentViewGradings = parentViewGradings
err = sql.SaveConfig(server.config)
if err != nil {
WriteJSON(w, Response{Data: "Failed to save config", Error: err.Error(), Success: false}, http.StatusInternalServerError)
Expand All @@ -87,5 +94,6 @@ func (server *httpImpl) ParentConfig(w http.ResponseWriter, r *http.Request) {
ParentViewGrades: server.config.ParentViewGrades,
ParentViewAbsences: server.config.ParentViewAbsences,
ParentViewHomework: server.config.ParentViewHomework,
ParentViewGradings: server.config.ParentViewGradings,
}, Success: true}, http.StatusOK)
}

0 comments on commit 872b436

Please sign in to comment.