diff --git a/backend/issue.go b/backend/issue.go index c04cb564..01d07e51 100644 --- a/backend/issue.go +++ b/backend/issue.go @@ -13,6 +13,7 @@ import ( ) type IssueUpload struct { + Id int64 `json:"id"` IdExercice int64 `json:"id_exercice"` Subject string `json:"subject"` Description string `json:"description"` @@ -32,9 +33,35 @@ func treatIssue(pathname string, team fic.Team) { } else if err := json.Unmarshal(cnt_raw, &issue); err != nil { log.Printf("%s [ERR] %s\n", id, err) } else if len(issue.Subject) == 0 && len(issue.Description) == 0 { + if err = os.Remove(pathname); err != nil { + log.Printf("%s [ERR] %s\n", id, err) + } log.Printf("%s Empty issue: not treated.\n", id) } else if len(issue.Subject) == 0 { - log.Printf("%s Issue with no subject: not treated.\n", id) + if issue.Id <= 0 { + if err = os.Remove(pathname); err != nil { + log.Printf("%s [ERR] %s\n", id, err) + } + log.Printf("%s Issue with no subject: not treated.\n", id) + } else if claim, err := team.GetClaim(issue.Id); err != nil { + log.Printf("%s [ERR] Team id=%d,name=%q tries to access issue id=%d, but not granted: %s.\n", id, team.Id, team.Name, issue.Id, err) + } else if len(issue.Description) == 0 { + if err = os.Remove(pathname); err != nil { + log.Printf("%s [ERR] %s\n", id, err) + } + log.Printf("%s Empty issue: not treated.\n", id) + } else if desc, err := claim.AddDescription(issue.Description, fic.ClaimAssignee{Id: 0}, true); err != nil { + log.Printf("%s [WRN] Unable to add description to issue: %s\n", id, err) + } else { + claim.State = "new" + claim.Update() + + log.Printf("%s [OOK] New comment added to issue id=%d: id_description=%s\n", id, claim.Id, desc.Id) + if err = os.Remove(pathname); err != nil { + log.Printf("%s [ERR] %s\n", id, err) + } + genTeamIssuesFile(team) + } } else { var exercice *fic.Exercice = nil if e, err := fic.GetExercice(issue.IdExercice); err == nil { diff --git a/configs/nginx-demo.conf b/configs/nginx-demo.conf index a66995d9..cfd45ce5 100644 --- a/configs/nginx-demo.conf +++ b/configs/nginx-demo.conf @@ -91,6 +91,11 @@ server { rewrite ^/.*$ /index.html; } + location /issues { + include fic-auth.conf; + + rewrite ^/.*$ /index.html; + } location /rank { include fic-auth.conf; diff --git a/configs/nginx-prod.conf b/configs/nginx-prod.conf index bc1591d0..9f5be5bc 100644 --- a/configs/nginx-prod.conf +++ b/configs/nginx-prod.conf @@ -83,6 +83,11 @@ server { rewrite ^/.*$ /index.html; } + location /issues { + include fic-auth.conf; + + rewrite ^/.*$ /index.html; + } location /rank { include fic-auth.conf; diff --git a/frontend/settings.go b/frontend/settings.go index c1b4adda..b5c2a743 100644 --- a/frontend/settings.go +++ b/frontend/settings.go @@ -75,5 +75,6 @@ func reloadSettings(config settings.FICSettings) { enableResolutionRoute = config.EnableResolutionRoute denyNameChange = config.DenyNameChange + acceptNewIssues = config.AcceptNewIssue allowRegistration = config.AllowRegistration } diff --git a/frontend/static/index.html b/frontend/static/index.html index c5f14d16..2c5fd3bd 100644 --- a/frontend/static/index.html +++ b/frontend/static/index.html @@ -103,7 +103,7 @@ Classement
Vous - à {{ text.date | date:"mediumTime" }} : + à {{ text.date | date:"mediumTime" }} : {{ text.cnt }} -
Votre rapport a bien été envoyé !{{ sberr }} {{ message }}