0
0
Fork 0
mirror of https://github.com/go-gitea/gitea synced 2024-11-24 21:22:49 +01:00

Update action struct

This commit is contained in:
Unknown 2014-03-13 02:09:36 -04:00
parent 3005a0f13e
commit ea765d25e2
3 changed files with 16 additions and 39 deletions

View file

@ -5,7 +5,6 @@
package models package models
import ( import (
"encoding/json"
"time" "time"
) )
@ -21,30 +20,24 @@ const (
// An Action represents // An Action represents
type Action struct { type Action struct {
Id int64 Id int64
UserId int64 UserId int64
OpType int
RepoId int64
Content string
Created time.Time `xorm:"created"`
}
type NewRepoContent struct {
UserName string UserName string
OpType int
RepoId int64
RepoName string RepoName string
Content string
Created time.Time `xorm:"created"`
} }
// 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 { UserId: user.Id,
return err UserName: user.Name,
} OpType: OP_CREATE_REPO,
_, err = orm.InsertOne(&Action{ RepoId: repo.Id,
UserId: user.Id, RepoName: repo.Name,
OpType: OP_CREATE_REPO,
RepoId: repo.Id,
Content: string(content),
}) })
return err return err
} }

View file

@ -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
View file

@ -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"))