Reviewed-on: https://git.openi.org.cn/OpenI/aiforge/pulls/1002 Reviewed-by: zhoupzh <zhoupzh@pcl.ac.cn>tags/v1.21.12.1^2
| @@ -145,6 +145,7 @@ type User struct { | |||||
| AllowImportLocal bool // Allow migrate repository by local path | AllowImportLocal bool // Allow migrate repository by local path | ||||
| AllowCreateOrganization bool `xorm:"DEFAULT true"` | AllowCreateOrganization bool `xorm:"DEFAULT true"` | ||||
| ProhibitLogin bool `xorm:"NOT NULL DEFAULT false"` | ProhibitLogin bool `xorm:"NOT NULL DEFAULT false"` | ||||
| IsOperator bool `xorm:"NOT NULL DEFAULT false"` //运营人员 | |||||
| // Avatar | // Avatar | ||||
| Avatar string `xorm:"VARCHAR(2048) NOT NULL"` | Avatar string `xorm:"VARCHAR(2048) NOT NULL"` | ||||
| @@ -145,8 +145,7 @@ func Toggle(options *ToggleOptions) macaron.Handler { | |||||
| } | } | ||||
| if options.OperationRequired { | if options.OperationRequired { | ||||
| //todo: add isOperator judgement | |||||
| if !ctx.User.IsAdmin { | |||||
| if !ctx.User.IsOperator { | |||||
| ctx.Error(403) | ctx.Error(403) | ||||
| return | return | ||||
| } | } | ||||
| @@ -310,6 +310,7 @@ func Contexter() macaron.Handler { | |||||
| ctx.Data["SignedUserID"] = ctx.User.ID | ctx.Data["SignedUserID"] = ctx.User.ID | ||||
| ctx.Data["SignedUserName"] = ctx.User.Name | ctx.Data["SignedUserName"] = ctx.User.Name | ||||
| ctx.Data["IsAdmin"] = ctx.User.IsAdmin | ctx.Data["IsAdmin"] = ctx.User.IsAdmin | ||||
| ctx.Data["IsOperator"] = ctx.User.IsOperator | |||||
| c.Data["SignedUserName"] = ctx.User.Name | c.Data["SignedUserName"] = ctx.User.Name | ||||
| } else { | } else { | ||||
| ctx.Data["SignedUserID"] = int64(0) | ctx.Data["SignedUserID"] = int64(0) | ||||
| @@ -75,6 +75,7 @@ import ( | |||||
| "code.gitea.io/gitea/routers/api/v1/repo" | "code.gitea.io/gitea/routers/api/v1/repo" | ||||
| _ "code.gitea.io/gitea/routers/api/v1/swagger" // for swagger generation | _ "code.gitea.io/gitea/routers/api/v1/swagger" // for swagger generation | ||||
| "code.gitea.io/gitea/routers/api/v1/user" | "code.gitea.io/gitea/routers/api/v1/user" | ||||
| repo_ext "code.gitea.io/gitea/routers/repo" | |||||
| "gitea.com/macaron/binding" | "gitea.com/macaron/binding" | ||||
| "gitea.com/macaron/macaron" | "gitea.com/macaron/macaron" | ||||
| @@ -523,23 +524,26 @@ func RegisterRoutes(m *macaron.Macaron) { | |||||
| Get(notify.GetThread). | Get(notify.GetThread). | ||||
| Patch(notify.ReadThread) | Patch(notify.ReadThread) | ||||
| }, reqToken()) | }, reqToken()) | ||||
| adminReq := context.Toggle(&context.ToggleOptions{SignInRequired: true, AdminRequired: true}) | |||||
| operationReq := context.Toggle(&context.ToggleOptions{SignInRequired: true, OperationRequired: true}) | |||||
| //Project board | //Project board | ||||
| m.Group("/projectboard", func() { | m.Group("/projectboard", func() { | ||||
| m.Get("/restoreFork", adminReq, repo.RestoreForkNumber) | |||||
| m.Get("/downloadAll", adminReq, repo.ServeAllProjectsPeriodStatisticsFile) | |||||
| m.Get("/downloadAllOpenI", adminReq, repo.ServeAllProjectsOpenIStatisticsFile) | |||||
| m.Get("/restoreFork", repo.RestoreForkNumber) | |||||
| m.Get("/downloadAll", repo.ServeAllProjectsPeriodStatisticsFile) | |||||
| m.Get("/downloadAllOpenI", repo.ServeAllProjectsOpenIStatisticsFile) | |||||
| m.Group("/project", func() { | m.Group("/project", func() { | ||||
| m.Get("", adminReq, repo.GetAllProjectsPeriodStatistics) | |||||
| m.Get("", repo.GetAllProjectsPeriodStatistics) | |||||
| m.Group("/:id", func() { | m.Group("/:id", func() { | ||||
| m.Get("", adminReq, repo.GetProjectLatestStatistics) | |||||
| m.Get("/period", adminReq, repo.GetProjectPeriodStatistics) | |||||
| m.Get("", repo.GetProjectLatestStatistics) | |||||
| m.Get("/period", repo.GetProjectPeriodStatistics) | |||||
| }) | }) | ||||
| }) | }) | ||||
| }) | |||||
| }, operationReq) | |||||
| m.Get("/query_user_static_page", operationReq, repo_ext.QueryUserStaticDataPage) | |||||
| // Users | // Users | ||||
| m.Group("/users", func() { | m.Group("/users", func() { | ||||
| @@ -792,7 +792,7 @@ func RegisterRoutes(m *macaron.Macaron) { | |||||
| }, reqSignIn, context.RepoAssignment(), context.UnitTypes(), reqRepoAdmin, context.RepoRef()) | }, reqSignIn, context.RepoAssignment(), context.UnitTypes(), reqRepoAdmin, context.RepoRef()) | ||||
| m.Post("/:username/:reponame/action/:action", reqSignIn, context.RepoAssignment(), context.UnitTypes(), repo.Action) | m.Post("/:username/:reponame/action/:action", reqSignIn, context.RepoAssignment(), context.UnitTypes(), repo.Action) | ||||
| m.Get("/tool/query_user_static_page", adminReq, repo.QueryUserStaticDataPage) | |||||
| // Grouping for those endpoints not requiring authentication | // Grouping for those endpoints not requiring authentication | ||||
| m.Group("/:username/:reponame", func() { | m.Group("/:username/:reponame", func() { | ||||
| m.Get("/contributors", repo.Contributors) | m.Get("/contributors", repo.Contributors) | ||||
| @@ -37,7 +37,7 @@ | |||||
| <a class="item" href="{{AppSubUrl}}/explore/users">{{.i18n.Tr "explore.users"}}</a> | <a class="item" href="{{AppSubUrl}}/explore/users">{{.i18n.Tr "explore.users"}}</a> | ||||
| <a class="item" href="{{AppSubUrl}}/explore/organizations">{{.i18n.Tr "explore.organizations"}}</a> | <a class="item" href="{{AppSubUrl}}/explore/organizations">{{.i18n.Tr "explore.organizations"}}</a> | ||||
| <a class="item" href="{{AppSubUrl}}/explore/images">{{.i18n.Tr "explore.images"}}</a> | <a class="item" href="{{AppSubUrl}}/explore/images">{{.i18n.Tr "explore.images"}}</a> | ||||
| {{if .IsAdmin}} | |||||
| {{if .IsOperator}} | |||||
| <a class="item" href="{{AppSubUrl}}/explore/data_analysis">{{.i18n.Tr "explore.data_analysis"}}</a> | <a class="item" href="{{AppSubUrl}}/explore/data_analysis">{{.i18n.Tr "explore.data_analysis"}}</a> | ||||
| {{end}} | {{end}} | ||||
| </div> | </div> | ||||
| @@ -55,7 +55,7 @@ | |||||
| <a class="item" href="{{AppSubUrl}}/explore/users">{{.i18n.Tr "explore.users"}}</a> | <a class="item" href="{{AppSubUrl}}/explore/users">{{.i18n.Tr "explore.users"}}</a> | ||||
| <a class="item" href="{{AppSubUrl}}/explore/organizations">{{.i18n.Tr "explore.organizations"}}</a> | <a class="item" href="{{AppSubUrl}}/explore/organizations">{{.i18n.Tr "explore.organizations"}}</a> | ||||
| <a class="item" href="{{AppSubUrl}}/explore/images">{{.i18n.Tr "explore.images"}}</a> | <a class="item" href="{{AppSubUrl}}/explore/images">{{.i18n.Tr "explore.images"}}</a> | ||||
| {{if .IsAdmin}} | |||||
| {{if .IsOperator}} | |||||
| <a class="item" href="{{AppSubUrl}}/explore/data_analysis">{{.i18n.Tr "explore.data_analysis"}}</a> | <a class="item" href="{{AppSubUrl}}/explore/data_analysis">{{.i18n.Tr "explore.data_analysis"}}</a> | ||||
| {{end}} | {{end}} | ||||
| </div> | </div> | ||||
| @@ -37,7 +37,7 @@ | |||||
| <a class="item" href="{{AppSubUrl}}/explore/users">{{.i18n.Tr "explore.users"}}</a> | <a class="item" href="{{AppSubUrl}}/explore/users">{{.i18n.Tr "explore.users"}}</a> | ||||
| <a class="item" href="{{AppSubUrl}}/explore/organizations">{{.i18n.Tr "explore.organizations"}}</a> | <a class="item" href="{{AppSubUrl}}/explore/organizations">{{.i18n.Tr "explore.organizations"}}</a> | ||||
| <a class="item" href="{{AppSubUrl}}/explore/images">{{.i18n.Tr "explore.images"}}</a> | <a class="item" href="{{AppSubUrl}}/explore/images">{{.i18n.Tr "explore.images"}}</a> | ||||
| {{if .IsAdmin}} | |||||
| {{if .IsOperator}} | |||||
| <a class="item" href="{{AppSubUrl}}/explore/data_analysis">{{.i18n.Tr "explore.data_analysis"}}</a> | <a class="item" href="{{AppSubUrl}}/explore/data_analysis">{{.i18n.Tr "explore.data_analysis"}}</a> | ||||
| {{end}} | {{end}} | ||||
| </div> | </div> | ||||
| @@ -55,7 +55,7 @@ | |||||
| <a class="item" href="{{AppSubUrl}}/explore/users">{{.i18n.Tr "explore.users"}}</a> | <a class="item" href="{{AppSubUrl}}/explore/users">{{.i18n.Tr "explore.users"}}</a> | ||||
| <a class="item" href="{{AppSubUrl}}/explore/organizations">{{.i18n.Tr "explore.organizations"}}</a> | <a class="item" href="{{AppSubUrl}}/explore/organizations">{{.i18n.Tr "explore.organizations"}}</a> | ||||
| <a class="item" href="{{AppSubUrl}}/explore/images">{{.i18n.Tr "explore.images"}}</a> | <a class="item" href="{{AppSubUrl}}/explore/images">{{.i18n.Tr "explore.images"}}</a> | ||||
| {{if .IsAdmin}} | |||||
| {{if .IsOperator}} | |||||
| <a class="item" href="{{AppSubUrl}}/explore/data_analysis">{{.i18n.Tr "explore.data_analysis"}}</a> | <a class="item" href="{{AppSubUrl}}/explore/data_analysis">{{.i18n.Tr "explore.data_analysis"}}</a> | ||||
| {{end}} | {{end}} | ||||
| </div> | </div> | ||||
| @@ -29,7 +29,7 @@ | |||||
| <a class="item" href="{{AppSubUrl}}/explore/users">{{.i18n.Tr "explore.users"}}</a> | <a class="item" href="{{AppSubUrl}}/explore/users">{{.i18n.Tr "explore.users"}}</a> | ||||
| <a class="item" href="{{AppSubUrl}}/explore/organizations">{{.i18n.Tr "explore.organizations"}}</a> | <a class="item" href="{{AppSubUrl}}/explore/organizations">{{.i18n.Tr "explore.organizations"}}</a> | ||||
| <a class="item" href="{{AppSubUrl}}/explore/images">{{.i18n.Tr "explore.images"}}</a> | <a class="item" href="{{AppSubUrl}}/explore/images">{{.i18n.Tr "explore.images"}}</a> | ||||
| {{if .IsAdmin}} | |||||
| {{if .IsOperator}} | |||||
| <a class="item" href="{{AppSubUrl}}/explore/data_analysis">{{.i18n.Tr "explore.data_analysis"}}</a> | <a class="item" href="{{AppSubUrl}}/explore/data_analysis">{{.i18n.Tr "explore.data_analysis"}}</a> | ||||
| {{end}} | {{end}} | ||||
| </div> | </div> | ||||
| @@ -47,7 +47,7 @@ | |||||
| <a class="item" href="{{AppSubUrl}}/explore/users">{{.i18n.Tr "explore.users"}}</a> | <a class="item" href="{{AppSubUrl}}/explore/users">{{.i18n.Tr "explore.users"}}</a> | ||||
| <a class="item" href="{{AppSubUrl}}/explore/organizations">{{.i18n.Tr "explore.organizations"}}</a> | <a class="item" href="{{AppSubUrl}}/explore/organizations">{{.i18n.Tr "explore.organizations"}}</a> | ||||
| <a class="item" href="{{AppSubUrl}}/explore/images">{{.i18n.Tr "explore.images"}}</a> | <a class="item" href="{{AppSubUrl}}/explore/images">{{.i18n.Tr "explore.images"}}</a> | ||||
| {{if .IsAdmin}} | |||||
| {{if .IsOperator}} | |||||
| <a class="item" href="{{AppSubUrl}}/explore/data_analysis">{{.i18n.Tr "explore.data_analysis"}}</a> | <a class="item" href="{{AppSubUrl}}/explore/data_analysis">{{.i18n.Tr "explore.data_analysis"}}</a> | ||||
| {{end}} | {{end}} | ||||
| </div> | </div> | ||||
| @@ -27,10 +27,10 @@ | |||||
| </span> | </span> | ||||
| <span style="float:right; margin-right: 20px;" > | <span style="float:right; margin-right: 20px;" > | ||||
| <a style="display:inline-block;margin-left: 20px; " id = 'download'> | <a style="display:inline-block;margin-left: 20px; " id = 'download'> | ||||
| <a class="el-icon-download" v-if="tableData!=''" :href= "'../tool/query_user_static_page/?startDate='+this.params.startDate+'&endDate='+this.params.endDate+'&IsReturnFile=true'+'&userName='+this.params.userName" ></a> | |||||
| <a class="el-icon-download" v-if="tableData!=''" :href= "'../api/v1/query_user_static_page/?startDate='+this.params.startDate+'&endDate='+this.params.endDate+'&IsReturnFile=true'+'&userName='+this.params.userName" ></a> | |||||
| <i class="el-icon-download" v-else="tableData=''" href="#" style="color:rgba(187, 187, 187, 100);" @click='popMark()'></i> | <i class="el-icon-download" v-else="tableData=''" href="#" style="color:rgba(187, 187, 187, 100);" @click='popMark()'></i> | ||||
| <span > | <span > | ||||
| <a v-if="tableData!=''" :href= "'../tool/query_user_static_page/?startDate='+this.params.startDate+'&endDate='+this.params.endDate+'&IsReturnFile=true'+'&userName='+this.params.userName" >下载报告</a> | |||||
| <a v-if="tableData!=''" :href= "'../api/v1/query_user_static_page/?startDate='+this.params.startDate+'&endDate='+this.params.endDate+'&IsReturnFile=true'+'&userName='+this.params.userName" >下载报告</a> | |||||
| <a v-else="tableData=''" href= "#" style="color:rgba(187, 187, 187, 100);" @click='popMark()'>下载报告</a> | <a v-else="tableData=''" href= "#" style="color:rgba(187, 187, 187, 100);" @click='popMark()'>下载报告</a> | ||||
| </span> | </span> | ||||
| </a> | </a> | ||||
| @@ -335,7 +335,7 @@ | |||||
| } | } | ||||
| }; | }; | ||||
| this.$axios.get('../tool/query_user_static_page',{ | |||||
| this.$axios.get('../api/v1/query_user_static_page',{ | |||||
| params:this.params | params:this.params | ||||
| }).then((res)=>{ | }).then((res)=>{ | ||||
| this.tableData = res.data.data | this.tableData = res.data.data | ||||