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
|
||||
binutils-mingw-w64-x86-64 ansible
|
||||
- go get -u github.com/tools/godep
|
||||
- go get github.com/go-playground/overalls
|
||||
- go get golang.org/x/tools/cmd/cover
|
||||
- go get github.com/mattn/goveralls
|
||||
before_script:
|
||||
- go vet
|
||||
- go test -v ./...
|
||||
script:
|
||||
- go test -v ./... -covermode=count -coverprofile=coverage.out
|
||||
- $HOME/gopath/bin/goveralls -coverprofile=coverage.out -service=travis-ci -repotoken $COVERALLS_TOKEN
|
||||
- overalls -project=github.com/NyaaPantsu/nyaa -covermode=count -debug
|
||||
- goveralls -coverprofile="overalls.coverprofile" -service=travis-ci -repotoken $COVERALLS_TOKEN
|
||||
install:
|
||||
- export GOPATH="${TRAVIS_BUILD_DIR}/vendor:$GOPATH"
|
||||
- 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)
|
||||
currentUser := router.GetUser(c)
|
||||
torrent, _ := torrents.FindByID(uint(id))
|
||||
if currentUser.CurrentOrAdmin(torrent.UploaderID) {
|
||||
if currentUser.CurrentOrAdmin(torrent.UploaderID) && torrent.ID > 0 {
|
||||
_, _, err := torrent.Delete(false)
|
||||
if err == nil {
|
||||
if torrent.Uploader == nil {
|
||||
|
|
|
@ -20,7 +20,7 @@ func TorrentEditUserPanel(c *gin.Context) {
|
|||
id, _ := strconv.ParseInt(c.Query("id"), 10, 32)
|
||||
torrent, _ := torrents.FindByID(uint(id))
|
||||
currentUser := router.GetUser(c)
|
||||
if currentUser.CurrentOrAdmin(torrent.UploaderID) {
|
||||
if currentUser.CurrentOrAdmin(torrent.UploaderID) && torrent.ID > 0 {
|
||||
uploadForm := torrentValidator.TorrentRequest{}
|
||||
uploadForm.Name = torrent.Name
|
||||
uploadForm.Category = strconv.Itoa(torrent.Category) + "_" + strconv.Itoa(torrent.SubCategory)
|
||||
|
|
|
@ -101,7 +101,7 @@ func (u User) Size() (s int) {
|
|||
6*2 + // string pointers
|
||||
4*3 + //time.Time
|
||||
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)
|
||||
s *= 8
|
||||
|
||||
|
@ -154,6 +154,9 @@ func (u *User) HasAdmin() bool {
|
|||
|
||||
// CurrentOrAdmin check that user has admin permission or user is the current user.
|
||||
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)
|
||||
return (u.IsModerator() || u.ID == userID)
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@
|
|||
<a class="form-input" href="/notifications">{{ T("my_notifications")}}</a>
|
||||
<br/>
|
||||
{{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">
|
||||
{{ T("settings")}}
|
||||
</a>
|
||||
|
|
|
@ -164,7 +164,7 @@ func userProfileBase(c *gin.Context, templateName string, userProfile *models.Us
|
|||
query.Set("limit", "20")
|
||||
c.Request.URL.RawQuery = query.Encode()
|
||||
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)
|
||||
} else {
|
||||
_, userProfile.Torrents, nbTorrents, _ = search.ByQuery(c, 1, true, true, false, true)
|
||||
|
|
Référencer dans un nouveau ticket