mirror of
https://github.com/go-gitea/gitea
synced 2024-11-25 00:12:52 +01:00
Update action struct
This commit is contained in:
parent
3005a0f13e
commit
ea765d25e2
3 changed files with 16 additions and 39 deletions
|
@ -5,7 +5,6 @@
|
||||||
package models
|
package models
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -23,28 +22,22 @@ const (
|
||||||
type Action struct {
|
type Action struct {
|
||||||
Id int64
|
Id int64
|
||||||
UserId int64
|
UserId int64
|
||||||
|
UserName string
|
||||||
OpType int
|
OpType int
|
||||||
RepoId int64
|
RepoId int64
|
||||||
|
RepoName string
|
||||||
Content string
|
Content string
|
||||||
Created time.Time `xorm:"created"`
|
Created time.Time `xorm:"created"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type NewRepoContent struct {
|
|
||||||
UserName string
|
|
||||||
RepoName string
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewRepoAction inserts action for create repository.
|
// NewRepoAction inserts action for create repository.
|
||||||
func NewRepoAction(user *User, repo *Repository) error {
|
func NewRepoAction(user *User, repo *Repository) error {
|
||||||
content, err := json.Marshal(&NewRepoContent{user.Name, repo.Name})
|
_, err := orm.InsertOne(&Action{
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
_, err = orm.InsertOne(&Action{
|
|
||||||
UserId: user.Id,
|
UserId: user.Id,
|
||||||
|
UserName: user.Name,
|
||||||
OpType: OP_CREATE_REPO,
|
OpType: OP_CREATE_REPO,
|
||||||
RepoId: repo.Id,
|
RepoId: repo.Id,
|
||||||
Content: string(content),
|
RepoName: repo.Name,
|
||||||
})
|
})
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
package user
|
package user
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/codegangsta/martini"
|
"github.com/codegangsta/martini"
|
||||||
|
@ -167,20 +166,10 @@ func Delete(data base.TmplData, req *http.Request, session sessions.Session, r r
|
||||||
r.HTML(200, "user/delete", data)
|
r.HTML(200, "user/delete", data)
|
||||||
}
|
}
|
||||||
|
|
||||||
func Feeds(form auth.FeedsForm, r render.Render) string {
|
func Feeds(form auth.FeedsForm, r render.Render) {
|
||||||
actions, err := models.GetFeeds(form.UserId, form.Offset)
|
actions, err := models.GetFeeds(form.UserId, form.Offset)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err.Error()
|
r.JSON(500, err)
|
||||||
}
|
}
|
||||||
|
r.JSON(200, actions)
|
||||||
length := len(actions)
|
|
||||||
buf := bytes.NewBuffer([]byte("["))
|
|
||||||
for i, action := range actions {
|
|
||||||
buf.WriteString(action.Content)
|
|
||||||
if i < length-1 {
|
|
||||||
buf.WriteString(",")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
buf.WriteString("]")
|
|
||||||
return buf.String()
|
|
||||||
}
|
}
|
||||||
|
|
7
web.go
7
web.go
|
@ -30,10 +30,7 @@ var CmdWeb = cli.Command{
|
||||||
Description: `
|
Description: `
|
||||||
gogs web`,
|
gogs web`,
|
||||||
Action: runWeb,
|
Action: runWeb,
|
||||||
Flags: []cli.Flag{
|
Flags: []cli.Flag{},
|
||||||
//cli.BoolFlag{"update, u", "update pakcage(s) and dependencies if any"},
|
|
||||||
//cli.BoolFlag{"verbose, v", "show process details"},
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var AppHelpers template.FuncMap = map[string]interface{}{
|
var AppHelpers template.FuncMap = map[string]interface{}{
|
||||||
|
@ -78,8 +75,6 @@ func runWeb(*cli.Context) {
|
||||||
|
|
||||||
//m.Get("/:username/:reponame", repo.Repo)
|
//m.Get("/:username/:reponame", repo.Repo)
|
||||||
|
|
||||||
//m.Get("/:username/:reponame", repo.Repo)
|
|
||||||
|
|
||||||
listenAddr := fmt.Sprintf("%s:%s",
|
listenAddr := fmt.Sprintf("%s:%s",
|
||||||
base.Cfg.MustValue("server", "HTTP_ADDR"),
|
base.Cfg.MustValue("server", "HTTP_ADDR"),
|
||||||
base.Cfg.MustValue("server", "HTTP_PORT", "3000"))
|
base.Cfg.MustValue("server", "HTTP_PORT", "3000"))
|
||||||
|
|
Loading…
Reference in a new issue