Started implementing settign for dependencies
This commit is contained in:
parent
fc35252f68
commit
33c5033c8b
|
|
@ -32,3 +32,21 @@ func (repo *Repository) AllowOnlyContributorsToTrackTime() bool {
|
||||||
}
|
}
|
||||||
return u.IssuesConfig().AllowOnlyContributorsToTrackTime
|
return u.IssuesConfig().AllowOnlyContributorsToTrackTime
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
________ .___ .__
|
||||||
|
\______ \ ____ ______ ____ ____ __| _/____ ____ ____ |__| ____ ______
|
||||||
|
| | \_/ __ \\____ \_/ __ \ / \ / __ |/ __ \ / \_/ ___\| |/ __ \ / ___/
|
||||||
|
| ` \ ___/| |_> > ___/| | \/ /_/ \ ___/| | \ \___| \ ___/ \___ \
|
||||||
|
/_______ /\___ > __/ \___ >___| /\____ |\___ >___| /\___ >__|\___ >____ >
|
||||||
|
\/ \/|__| \/ \/ \/ \/ \/ \/ \/ \/
|
||||||
|
*/
|
||||||
|
|
||||||
|
func (repo *Repository) IsDependenciesEnabled() bool {
|
||||||
|
var u *RepoUnit
|
||||||
|
var err error
|
||||||
|
if u, err = repo.GetUnit(UnitTypeIssues); err != nil {
|
||||||
|
return setting.Service.DefaultEnableDependencies
|
||||||
|
}
|
||||||
|
return u.IssuesConfig().EnableDependencies
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -73,6 +73,7 @@ func (cfg *ExternalTrackerConfig) ToDB() ([]byte, error) {
|
||||||
type IssuesConfig struct {
|
type IssuesConfig struct {
|
||||||
EnableTimetracker bool
|
EnableTimetracker bool
|
||||||
AllowOnlyContributorsToTrackTime bool
|
AllowOnlyContributorsToTrackTime bool
|
||||||
|
EnableDependencies bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// FromDB fills up a IssuesConfig from serialized format.
|
// FromDB fills up a IssuesConfig from serialized format.
|
||||||
|
|
|
||||||
|
|
@ -103,6 +103,14 @@ func (r *Repository) CanUseTimetracker(issue *models.Issue, user *models.User) b
|
||||||
r.IsWriter() || issue.IsPoster(user.ID) || issue.AssigneeID == user.ID)
|
r.IsWriter() || issue.IsPoster(user.ID) || issue.AssigneeID == user.ID)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CanUseDependencies returns whether or not a user can create dependencies.
|
||||||
|
func (r *Repository) CanUseDependencies(issue *models.Issue, user *models.User) bool {
|
||||||
|
// Checking for following:
|
||||||
|
// 1. Is dependencies enabled
|
||||||
|
// 2. Has the user write access?
|
||||||
|
return r.Repository.IsDependenciesEnabled() && r.IsWriter()
|
||||||
|
}
|
||||||
|
|
||||||
// GetCommitsCount returns cached commit count for current view
|
// GetCommitsCount returns cached commit count for current view
|
||||||
func (r *Repository) GetCommitsCount() (int64, error) {
|
func (r *Repository) GetCommitsCount() (int64, error) {
|
||||||
var contextName string
|
var contextName string
|
||||||
|
|
|
||||||
|
|
@ -1138,6 +1138,7 @@ var Service struct {
|
||||||
DefaultKeepEmailPrivate bool
|
DefaultKeepEmailPrivate bool
|
||||||
DefaultAllowCreateOrganization bool
|
DefaultAllowCreateOrganization bool
|
||||||
DefaultEnableTimetracking bool
|
DefaultEnableTimetracking bool
|
||||||
|
DefaultEnableDependencies bool
|
||||||
DefaultAllowOnlyContributorsToTrackTime bool
|
DefaultAllowOnlyContributorsToTrackTime bool
|
||||||
NoReplyAddress string
|
NoReplyAddress string
|
||||||
|
|
||||||
|
|
@ -1161,6 +1162,7 @@ func newService() {
|
||||||
Service.DefaultKeepEmailPrivate = sec.Key("DEFAULT_KEEP_EMAIL_PRIVATE").MustBool()
|
Service.DefaultKeepEmailPrivate = sec.Key("DEFAULT_KEEP_EMAIL_PRIVATE").MustBool()
|
||||||
Service.DefaultAllowCreateOrganization = sec.Key("DEFAULT_ALLOW_CREATE_ORGANIZATION").MustBool(true)
|
Service.DefaultAllowCreateOrganization = sec.Key("DEFAULT_ALLOW_CREATE_ORGANIZATION").MustBool(true)
|
||||||
Service.DefaultEnableTimetracking = sec.Key("DEFAULT_ENABLE_TIMETRACKING").MustBool(true)
|
Service.DefaultEnableTimetracking = sec.Key("DEFAULT_ENABLE_TIMETRACKING").MustBool(true)
|
||||||
|
Service.DefaultEnableDependencies = sec.Key("DEFAULT_ENABLE_DEPENDENCIES").MustBool(true)
|
||||||
Service.DefaultAllowOnlyContributorsToTrackTime = sec.Key("DEFAULT_ALLOW_ONLY_CONTRIBUTORS_TO_TRACK_TIME").MustBool(true)
|
Service.DefaultAllowOnlyContributorsToTrackTime = sec.Key("DEFAULT_ALLOW_ONLY_CONTRIBUTORS_TO_TRACK_TIME").MustBool(true)
|
||||||
Service.NoReplyAddress = sec.Key("NO_REPLY_ADDRESS").MustString("noreply.example.org")
|
Service.NoReplyAddress = sec.Key("NO_REPLY_ADDRESS").MustString("noreply.example.org")
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -624,6 +624,9 @@ func ViewIssue(ctx *context.Context) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check if the user can use the dependencies
|
||||||
|
ctx.Data["CanUseDependencies"] = ctx.Repo.CanUseDependencies(issue, ctx.User)
|
||||||
|
|
||||||
// Render comments and and fetch participants.
|
// Render comments and and fetch participants.
|
||||||
participants[0] = issue.Poster
|
participants[0] = issue.Poster
|
||||||
for _, comment = range issue.Comments {
|
for _, comment = range issue.Comments {
|
||||||
|
|
|
||||||
|
|
@ -152,11 +152,11 @@
|
||||||
<label>{{.i18n.Tr "repo.settings.allow_only_contributors_to_track_time"}}</label>
|
<label>{{.i18n.Tr "repo.settings.allow_only_contributors_to_track_time"}}</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<div class="field">
|
||||||
<div class="field">
|
<div class="ui checkbox">
|
||||||
<div class="ui checkbox">
|
<input name="enable_issue_dependencies" type="checkbox" {{if (.Repository.IsDependenciesEnabled)}}checked{{end}}>
|
||||||
<input name="enable_issue_dependencies" type="checkbox" {{if (.Repository.UnitEnabled $.UnitTypeIssueDependencies)}}checked{{end}}>
|
<label>{{.i18n.Tr "repo.issues.dependency.setting"}}</label>
|
||||||
<label>{{.i18n.Tr "repo.issues.dependency.setting"}}</label>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="field">
|
<div class="field">
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user