|
|
|
@@ -522,7 +522,6 @@ func MyFavoriteDataset(ctx *context.Context) { |
|
|
|
} |
|
|
|
datasets := IsColDatasets |
|
|
|
count := NotColcount + IsColcount |
|
|
|
//排序 |
|
|
|
sort.Slice(datasets, func(i, j int) bool { |
|
|
|
return datasets[i].Attachment.CreatedUnix > datasets[j].Attachment.CreatedUnix |
|
|
|
}) |
|
|
|
@@ -613,23 +612,28 @@ func GetDatasetStatus(ctx *context.Context) { |
|
|
|
func DatasetIsCollaborator(ctx *context.Context, DatasetID int64) bool { |
|
|
|
dataset, err := models.GetDatasetByID(DatasetID) |
|
|
|
if err != nil { |
|
|
|
log.Info("query dataset error") |
|
|
|
log.Error("query dataset error:", err.Error()) |
|
|
|
return false |
|
|
|
} else { |
|
|
|
repo, err := models.GetRepositoryByID(dataset.RepoID) |
|
|
|
if err != nil { |
|
|
|
log.Info("query repo error.") |
|
|
|
log.Error("query repo error:", err.Error()) |
|
|
|
} else { |
|
|
|
repo.GetOwner() |
|
|
|
if ctx.User != nil { |
|
|
|
if repo.Owner.IsOrganization() { |
|
|
|
if repo.Owner.IsUserPartOfOrg(ctx.User.ID) { |
|
|
|
log.Info("org user may visit the attach.") |
|
|
|
return true |
|
|
|
for _, t := range repo.Owner.Teams { |
|
|
|
if t.IsMember(ctx.User.ID) && t.HasRepository(repo.ID) { |
|
|
|
return true |
|
|
|
} |
|
|
|
} |
|
|
|
return false |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
isCollaborator, _ := repo.IsCollaborator(ctx.User.ID) |
|
|
|
if isCollaborator { |
|
|
|
log.Info("Collaborator user may visit the attach.") |
|
|
|
return true |
|
|
|
} |
|
|
|
} |
|
|
|
|