Browse Source

Finish watch backend

tags/v1.2.0-rc1
Unknown 11 years ago
parent
commit
ee92fb8635
3 changed files with 8 additions and 0 deletions
  1. +6
    -0
      models/repo.go
  2. +1
    -0
      modules/middleware/context.go
  3. +1
    -0
      modules/middleware/repo.go

+ 6
- 0
models/repo.go View File

@@ -67,6 +67,12 @@ func GetWatches(repoId int64) ([]Watch, error) {
return watches, err
}

// IsWatching checks if user has watched given repository.
func IsWatching(userId, repoId int64) bool {
has, _ := orm.Get(&Watch{0, repoId, userId})
return has
}

var (
gitInitLocker = sync.Mutex{}
LanguageIgns, Licenses []string


+ 1
- 0
modules/middleware/context.go View File

@@ -31,6 +31,7 @@ type Context struct {
Repo struct {
IsValid bool
IsOwner bool
IsWatching bool
Repository *models.Repository
Owner *models.User
}


+ 1
- 0
modules/middleware/repo.go View File

@@ -63,6 +63,7 @@ func RepoAssignment(redirect bool) martini.Handler {
}

ctx.Repo.IsValid = true
ctx.Repo.IsWatching = models.IsWatching(ctx.User.Id, repo.Id)
ctx.Repo.Repository = repo

ctx.Data["IsRepositoryValid"] = true


Loading…
Cancel
Save