mirror of
				https://github.com/go-gitea/gitea
				synced 2025-10-26 17:08:25 +00:00 
			
		
		
		
	* Fix PR, milestone and label functionality if issue unit is disabled or not assigned to user * Fix multi-actions in PR page * Change error message * Fix comment update and delete functionality in PR
		
			
				
	
	
		
			53 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			53 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
| // Copyright 2017 The Gitea Authors. All rights reserved.
 | |
| // Use of this source code is governed by a MIT-style
 | |
| // license that can be found in the LICENSE file.
 | |
| 
 | |
| package repo
 | |
| 
 | |
| import (
 | |
| 	"net/http"
 | |
| 
 | |
| 	"code.gitea.io/gitea/models"
 | |
| 	"code.gitea.io/gitea/modules/context"
 | |
| )
 | |
| 
 | |
| // IssueStopwatch creates or stops a stopwatch for the given issue.
 | |
| func IssueStopwatch(c *context.Context) {
 | |
| 	issue := GetActionIssue(c)
 | |
| 	if c.Written() {
 | |
| 		return
 | |
| 	}
 | |
| 	if !c.Repo.CanUseTimetracker(issue, c.User) {
 | |
| 		c.Handle(http.StatusNotFound, "CanUseTimetracker", nil)
 | |
| 		return
 | |
| 	}
 | |
| 
 | |
| 	if err := models.CreateOrStopIssueStopwatch(c.User, issue); err != nil {
 | |
| 		c.Handle(http.StatusInternalServerError, "CreateOrStopIssueStopwatch", err)
 | |
| 		return
 | |
| 	}
 | |
| 
 | |
| 	url := issue.HTMLURL()
 | |
| 	c.Redirect(url, http.StatusSeeOther)
 | |
| }
 | |
| 
 | |
| // CancelStopwatch cancel the stopwatch
 | |
| func CancelStopwatch(c *context.Context) {
 | |
| 	issue := GetActionIssue(c)
 | |
| 	if c.Written() {
 | |
| 		return
 | |
| 	}
 | |
| 	if !c.Repo.CanUseTimetracker(issue, c.User) {
 | |
| 		c.Handle(http.StatusNotFound, "CanUseTimetracker", nil)
 | |
| 		return
 | |
| 	}
 | |
| 
 | |
| 	if err := models.CancelStopwatch(c.User, issue); err != nil {
 | |
| 		c.Handle(http.StatusInternalServerError, "CancelStopwatch", err)
 | |
| 		return
 | |
| 	}
 | |
| 
 | |
| 	url := issue.HTMLURL()
 | |
| 	c.Redirect(url, http.StatusSeeOther)
 | |
| }
 |