Merge branch 'dev' into tags
Cette révision appartient à :
révision
d2339e9a43
6 fichiers modifiés avec 11 ajouts et 7 suppressions
|
@ -6,14 +6,15 @@ before_install:
|
||||||
- sudo apt-get install gcc-mingw-w64 gcc-mingw-w64-i686 gcc-mingw-w64-x86-64 binutils-mingw-w64-i686
|
- sudo apt-get install gcc-mingw-w64 gcc-mingw-w64-i686 gcc-mingw-w64-x86-64 binutils-mingw-w64-i686
|
||||||
binutils-mingw-w64-x86-64 ansible
|
binutils-mingw-w64-x86-64 ansible
|
||||||
- go get -u github.com/tools/godep
|
- go get -u github.com/tools/godep
|
||||||
|
- go get github.com/go-playground/overalls
|
||||||
- go get golang.org/x/tools/cmd/cover
|
- go get golang.org/x/tools/cmd/cover
|
||||||
- go get github.com/mattn/goveralls
|
- go get github.com/mattn/goveralls
|
||||||
before_script:
|
before_script:
|
||||||
- go vet
|
- go vet
|
||||||
- go test -v ./...
|
- go test -v ./...
|
||||||
script:
|
script:
|
||||||
- go test -v ./... -covermode=count -coverprofile=coverage.out
|
- overalls -project=github.com/NyaaPantsu/nyaa -covermode=count -debug
|
||||||
- $HOME/gopath/bin/goveralls -coverprofile=coverage.out -service=travis-ci -repotoken $COVERALLS_TOKEN
|
- goveralls -coverprofile="overalls.coverprofile" -service=travis-ci -repotoken $COVERALLS_TOKEN
|
||||||
install:
|
install:
|
||||||
- export GOPATH="${TRAVIS_BUILD_DIR}/vendor:$GOPATH"
|
- export GOPATH="${TRAVIS_BUILD_DIR}/vendor:$GOPATH"
|
||||||
- export PATH="${TRAVIS_BUILD_DIR}/Godeps/_workspace/bin:$PATH"
|
- export PATH="${TRAVIS_BUILD_DIR}/Godeps/_workspace/bin:$PATH"
|
||||||
|
|
|
@ -18,7 +18,7 @@ func TorrentDeleteUserPanel(c *gin.Context) {
|
||||||
id, _ := strconv.ParseInt(c.Query("id"), 10, 32)
|
id, _ := strconv.ParseInt(c.Query("id"), 10, 32)
|
||||||
currentUser := router.GetUser(c)
|
currentUser := router.GetUser(c)
|
||||||
torrent, _ := torrents.FindByID(uint(id))
|
torrent, _ := torrents.FindByID(uint(id))
|
||||||
if currentUser.CurrentOrAdmin(torrent.UploaderID) {
|
if currentUser.CurrentOrAdmin(torrent.UploaderID) && torrent.ID > 0 {
|
||||||
_, _, err := torrent.Delete(false)
|
_, _, err := torrent.Delete(false)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
if torrent.Uploader == nil {
|
if torrent.Uploader == nil {
|
||||||
|
|
|
@ -20,7 +20,7 @@ func TorrentEditUserPanel(c *gin.Context) {
|
||||||
id, _ := strconv.ParseInt(c.Query("id"), 10, 32)
|
id, _ := strconv.ParseInt(c.Query("id"), 10, 32)
|
||||||
torrent, _ := torrents.FindByID(uint(id))
|
torrent, _ := torrents.FindByID(uint(id))
|
||||||
currentUser := router.GetUser(c)
|
currentUser := router.GetUser(c)
|
||||||
if currentUser.CurrentOrAdmin(torrent.UploaderID) {
|
if currentUser.CurrentOrAdmin(torrent.UploaderID) && torrent.ID > 0 {
|
||||||
uploadForm := torrentValidator.TorrentRequest{}
|
uploadForm := torrentValidator.TorrentRequest{}
|
||||||
uploadForm.Name = torrent.Name
|
uploadForm.Name = torrent.Name
|
||||||
uploadForm.Category = strconv.Itoa(torrent.Category) + "_" + strconv.Itoa(torrent.SubCategory)
|
uploadForm.Category = strconv.Itoa(torrent.Category) + "_" + strconv.Itoa(torrent.SubCategory)
|
||||||
|
|
|
@ -101,7 +101,7 @@ func (u User) Size() (s int) {
|
||||||
6*2 + // string pointers
|
6*2 + // string pointers
|
||||||
4*3 + //time.Time
|
4*3 + //time.Time
|
||||||
3*2 + // arrays
|
3*2 + // arrays
|
||||||
// string arrays
|
// string arrays
|
||||||
len(u.Username) + len(u.Password) + len(u.Email) + len(u.APIToken) + len(u.MD5) + len(u.Language) + len(u.Theme)
|
len(u.Username) + len(u.Password) + len(u.Email) + len(u.APIToken) + len(u.MD5) + len(u.Language) + len(u.Theme)
|
||||||
s *= 8
|
s *= 8
|
||||||
|
|
||||||
|
@ -154,6 +154,9 @@ func (u *User) HasAdmin() bool {
|
||||||
|
|
||||||
// CurrentOrAdmin check that user has admin permission or user is the current user.
|
// CurrentOrAdmin check that user has admin permission or user is the current user.
|
||||||
func (u *User) CurrentOrAdmin(userID uint) bool {
|
func (u *User) CurrentOrAdmin(userID uint) bool {
|
||||||
|
if userID == 0 {
|
||||||
|
return false
|
||||||
|
}
|
||||||
log.Debugf("user.ID == userID %d %d %s", u.ID, userID, u.ID == userID)
|
log.Debugf("user.ID == userID %d %d %s", u.ID, userID, u.ID == userID)
|
||||||
return (u.IsModerator() || u.ID == userID)
|
return (u.IsModerator() || u.ID == userID)
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,7 +51,7 @@
|
||||||
<a class="form-input" href="/notifications">{{ T("my_notifications")}}</a>
|
<a class="form-input" href="/notifications">{{ T("my_notifications")}}</a>
|
||||||
<br/>
|
<br/>
|
||||||
{{end}}
|
{{end}}
|
||||||
{{if User.CurrentOrAdmin(UserProfile.ID) }}
|
{{if UserProfile.ID > 0 && User.CurrentOrAdmin(UserProfile.ID) }}
|
||||||
<a class="form-input" href="/user/{{UserProfile.ID}}/{{UserProfile.Username}}/edit">
|
<a class="form-input" href="/user/{{UserProfile.ID}}/{{UserProfile.Username}}/edit">
|
||||||
{{ T("settings")}}
|
{{ T("settings")}}
|
||||||
</a>
|
</a>
|
||||||
|
|
|
@ -164,7 +164,7 @@ func userProfileBase(c *gin.Context, templateName string, userProfile *models.Us
|
||||||
query.Set("limit", "20")
|
query.Set("limit", "20")
|
||||||
c.Request.URL.RawQuery = query.Encode()
|
c.Request.URL.RawQuery = query.Encode()
|
||||||
nbTorrents := 0
|
nbTorrents := 0
|
||||||
if currentUser.CurrentOrAdmin(userProfile.ID) {
|
if userProfile.ID > 0 && currentUser.CurrentOrAdmin(userProfile.ID) {
|
||||||
_, userProfile.Torrents, nbTorrents, _ = search.ByQuery(c, 1, true, true, false, false)
|
_, userProfile.Torrents, nbTorrents, _ = search.ByQuery(c, 1, true, true, false, false)
|
||||||
} else {
|
} else {
|
||||||
_, userProfile.Torrents, nbTorrents, _ = search.ByQuery(c, 1, true, true, false, true)
|
_, userProfile.Torrents, nbTorrents, _ = search.ByQuery(c, 1, true, true, false, true)
|
||||||
|
|
Référencer dans un nouveau ticket