Don't perform repo trigger if submission is closed
This commit is contained in:
parent
0b16676929
commit
0042d373f6
@ -129,6 +129,19 @@ func declareAPIAuthRepositoriesRoutes(router *gin.RouterGroup) {
|
|||||||
})
|
})
|
||||||
repositoriesRoutes.DELETE("", func(c *gin.Context) {
|
repositoriesRoutes.DELETE("", func(c *gin.Context) {
|
||||||
repository := c.MustGet("repository").(*Repository)
|
repository := c.MustGet("repository").(*Repository)
|
||||||
|
work, err := getWork(int(repository.IdWork))
|
||||||
|
if err != nil {
|
||||||
|
c.AbortWithStatusJSON(http.StatusInternalServerError, gin.H{"errmsg": "Unable to find related work."})
|
||||||
|
return
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
now := time.Now()
|
||||||
|
|
||||||
|
if !work.Shown || work.Corrected || work.StartAvailability.After(now) || work.EndAvailability.Before(now) {
|
||||||
|
c.AbortWithStatusJSON(http.StatusForbidden, gin.H{"errmsg": "The submission is closed."})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if _, err := repository.Delete(); err != nil {
|
if _, err := repository.Delete(); err != nil {
|
||||||
log.Println("Unable to Delete repository:", err)
|
log.Println("Unable to Delete repository:", err)
|
||||||
@ -156,6 +169,11 @@ func declareAPIAuthRepositoriesRoutes(router *gin.RouterGroup) {
|
|||||||
|
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
|
|
||||||
|
if !work.Shown || work.Corrected || work.StartAvailability.After(now) || work.EndAvailability.Add(time.Hour).Before(now) {
|
||||||
|
c.AbortWithStatusJSON(http.StatusForbidden, gin.H{"errmsg": "The submission is closed."})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if repo.LastCheck != nil && !repo.LastCheck.Before(now.Add(-5*time.Minute)) {
|
if repo.LastCheck != nil && !repo.LastCheck.Before(now.Add(-5*time.Minute)) {
|
||||||
c.AbortWithStatusJSON(http.StatusPaymentRequired, gin.H{"errmsg": "Please wait between two pulls."})
|
c.AbortWithStatusJSON(http.StatusPaymentRequired, gin.H{"errmsg": "Please wait between two pulls."})
|
||||||
return
|
return
|
||||||
|
@ -17,9 +17,10 @@
|
|||||||
|
|
||||||
function updatePullState(repo) {
|
function updatePullState(repo) {
|
||||||
repo_pull_state = repo.getBuildState();
|
repo_pull_state = repo.getBuildState();
|
||||||
|
show_logs = null;
|
||||||
repo_pull_state.then((state) => {
|
repo_pull_state.then((state) => {
|
||||||
if (state.status == "pending" || state.status == "running") {
|
if (state.status == "pending" || state.status == "running") {
|
||||||
setTimeout(() => updatePullState(repo), state.status == "pending" ? 1000 : 2500);
|
setTimeout(() => updatePullState(repo), state.status == "pending" ? 1000 : 3000);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -53,6 +54,17 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function goRetrieveWork(repo) {
|
||||||
|
submitInProgress = true;
|
||||||
|
repo.retrieveWork().then(() => {
|
||||||
|
submitInProgress = false;
|
||||||
|
refresh_repo_work();
|
||||||
|
}, (error) => {
|
||||||
|
submitInProgress = false;
|
||||||
|
ToastsStore.addErrorToast({msg: "Une erreur s'est produite : " + error});
|
||||||
|
})
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#await repo_work}
|
{#await repo_work}
|
||||||
@ -75,8 +87,8 @@
|
|||||||
{#if state.status == "pending" || state.status == "running"}
|
{#if state.status == "pending" || state.status == "running"}
|
||||||
<div
|
<div
|
||||||
class="spinner-grow spinner-grow-sm mx-1"
|
class="spinner-grow spinner-grow-sm mx-1"
|
||||||
class:text-secondary={state.status == "pending"}
|
class:text-primary={state.status == "pending"}
|
||||||
class:text-warning={state.status == "running"}
|
class:text-warning={state.status == "running"}
|
||||||
title="La récupération est en cours"
|
title="La récupération est en cours"
|
||||||
role="status"
|
role="status"
|
||||||
></div>
|
></div>
|
||||||
@ -96,7 +108,7 @@
|
|||||||
type="button"
|
type="button"
|
||||||
class="btn btn-outline-info float-end mb-1"
|
class="btn btn-outline-info float-end mb-1"
|
||||||
disable={submitInProgress || readonly}
|
disable={submitInProgress || readonly}
|
||||||
on:click={() => repo.retrieveWork().then(() => { refresh_repo_work() }, (error) => ToastsStore.addErrorToast({msg: "Une erreur s'est produite : " + error}))}
|
on:click={() => goRetrieveWork(repo)}
|
||||||
>
|
>
|
||||||
Récupérer mon travail
|
Récupérer mon travail
|
||||||
</button>
|
</button>
|
||||||
|
Reference in New Issue
Block a user