#1146 finish new access rights for collaborators
This commit is contained in:
parent
045f14fbd0
commit
a5b0400be7
22 changed files with 210 additions and 190 deletions
|
@ -298,16 +298,18 @@ func newIssue(e *xorm.Session, repo *Repository, issue *Issue, labelIDs []int64,
|
|||
return err
|
||||
}
|
||||
|
||||
// During the session, SQLite3 dirver cannot handle retrieve objects after update something.
|
||||
// So we have to get all needed labels first.
|
||||
labels := make([]*Label, 0, len(labelIDs))
|
||||
if err = e.In("id", labelIDs).Find(&labels); err != nil {
|
||||
return fmt.Errorf("find all labels: %v", err)
|
||||
}
|
||||
if len(labelIDs) > 0 {
|
||||
// During the session, SQLite3 dirver cannot handle retrieve objects after update something.
|
||||
// So we have to get all needed labels first.
|
||||
labels := make([]*Label, 0, len(labelIDs))
|
||||
if err = e.In("id", labelIDs).Find(&labels); err != nil {
|
||||
return fmt.Errorf("find all labels: %v", err)
|
||||
}
|
||||
|
||||
for _, label := range labels {
|
||||
if err = issue.addLabel(e, label); err != nil {
|
||||
return fmt.Errorf("addLabel: %v", err)
|
||||
for _, label := range labels {
|
||||
if err = issue.addLabel(e, label); err != nil {
|
||||
return fmt.Errorf("addLabel: %v", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ type CommentTag int
|
|||
const (
|
||||
COMMENT_TAG_NONE CommentTag = iota
|
||||
COMMENT_TAG_POSTER
|
||||
COMMENT_TAG_ADMIN
|
||||
COMMENT_TAG_WRITER
|
||||
COMMENT_TAG_OWNER
|
||||
)
|
||||
|
||||
|
|
|
@ -348,19 +348,15 @@ func (u *User) UploadAvatar(data []byte) error {
|
|||
|
||||
// IsAdminOfRepo returns true if user has admin or higher access of repository.
|
||||
func (u *User) IsAdminOfRepo(repo *Repository) bool {
|
||||
if repo.MustOwner().IsOrganization() {
|
||||
has, err := HasAccess(u, repo, ACCESS_MODE_ADMIN)
|
||||
if err != nil {
|
||||
log.Error(3, "HasAccess: %v", err)
|
||||
}
|
||||
return has
|
||||
has, err := HasAccess(u, repo, ACCESS_MODE_ADMIN)
|
||||
if err != nil {
|
||||
log.Error(3, "HasAccess: %v", err)
|
||||
}
|
||||
|
||||
return repo.IsOwnedBy(u.Id)
|
||||
return has
|
||||
}
|
||||
|
||||
// CanWriteTo returns true if user has write access to given repository.
|
||||
func (u *User) CanWriteTo(repo *Repository) bool {
|
||||
// IsWriterOfRepo returns true if user has write access to given repository.
|
||||
func (u *User) IsWriterOfRepo(repo *Repository) bool {
|
||||
has, err := HasAccess(u, repo, ACCESS_MODE_WRITE)
|
||||
if err != nil {
|
||||
log.Error(3, "HasAccess: %v", err)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue