Avoid 403 custom homepages
parent
050d694ed1
commit
e7ea15427e
|
@ -119,9 +119,8 @@ NavigationUrlsDirective = ($navurls, $auth, $q, $location, lightboxService, tgSe
|
||||||
options.user = user.username if user
|
options.user = user.username if user
|
||||||
|
|
||||||
if options['section']
|
if options['section']
|
||||||
sections = tgSections.list()
|
path = tgSections.getPath(options['project'], options['section'])
|
||||||
section = _.find(sections, {"id": options['section']})
|
name = "#{name}-#{path}"
|
||||||
name = "#{name}-#{section.path}"
|
|
||||||
|
|
||||||
url = $navurls.resolve(name)
|
url = $navurls.resolve(name)
|
||||||
|
|
||||||
|
|
|
@ -25,21 +25,29 @@
|
||||||
module = angular.module("taigaCommon")
|
module = angular.module("taigaCommon")
|
||||||
|
|
||||||
SECTIONS = {
|
SECTIONS = {
|
||||||
1: {id: 1, title: 'TIMELINE', path:'timeline'}
|
1: {id: 1, title: 'TIMELINE', path:'timeline', enabled: ''}
|
||||||
2: {id: 2, title: 'EPICS', path:'epics'}
|
2: {id: 2, title: 'EPICS', path:'epics', enabled: 'is_epics_activated'}
|
||||||
3: {id: 3, title: 'BACKLOG', path:'backlog'}
|
3: {id: 3, title: 'BACKLOG', path:'backlog', enabled: 'is_backlog_activated'}
|
||||||
4: {id: 4, title: 'KANBAN', path:'kanban'}
|
4: {id: 4, title: 'KANBAN', path:'kanban', enabled: 'is_kanban_activated'}
|
||||||
5: {id: 5, title: 'ISSUES', path:'issues'}
|
5: {id: 5, title: 'ISSUES', path:'issues', enabled: 'is_issues_activated'}
|
||||||
6: {id: 6, title: 'WIKI', path:'wiki'}
|
6: {id: 6, title: 'WIKI', path:'wiki', enabled: 'is_wiki_activated'}
|
||||||
}
|
}
|
||||||
|
|
||||||
class SectionsService extends taiga.Service
|
class SectionsService extends taiga.Service
|
||||||
@.$inject = ["$translate"]
|
@.$inject = ["$translate", "tgCurrentUserService"]
|
||||||
|
|
||||||
constructor: (@translate) ->
|
constructor: (@translate, @currentUserService) ->
|
||||||
super()
|
super()
|
||||||
_.map(SECTIONS, (x) => x.title = @translate.instant("PROJECT.SECTION.#{x.title}"))
|
_.map(SECTIONS, (x) => x.title = @translate.instant("PROJECT.SECTION.#{x.title}"))
|
||||||
list: () ->
|
list: () ->
|
||||||
return SECTIONS
|
return SECTIONS
|
||||||
|
getPath: (projectSlug, sectionId) ->
|
||||||
|
projects = @currentUserService.projects.get("all")
|
||||||
|
project = projects.find (p) -> return p.get('slug') == projectSlug
|
||||||
|
section = _.find(SECTIONS, {"id": sectionId})
|
||||||
|
if !section or project?.get(section.enabled) is not true
|
||||||
|
return "timeline"
|
||||||
|
|
||||||
|
return section.path
|
||||||
|
|
||||||
module.service("$tgSections", SectionsService)
|
module.service("$tgSections", SectionsService)
|
||||||
|
|
|
@ -40,16 +40,12 @@ class ProjectRouterController
|
||||||
@location.url("project/#{@routeParams.pslug}/timeline")
|
@location.url("project/#{@routeParams.pslug}/timeline")
|
||||||
|
|
||||||
getProjectHomepage: () ->
|
getProjectHomepage: () ->
|
||||||
sections = @tgSections.list()
|
|
||||||
project = @projectService.project.toJS()
|
project = @projectService.project.toJS()
|
||||||
|
|
||||||
@rs.userProjectSettings.list({project: project.id}).then (userProjectSettings) ->
|
@rs.userProjectSettings.list({project: project.id}).then (userProjectSettings) =>
|
||||||
settings = _.find(userProjectSettings, {"project": project.id})
|
settings = _.find(userProjectSettings, {"project": project.id})
|
||||||
return if !settings
|
return if !settings
|
||||||
|
|
||||||
section = _.find(sections, {"id": settings.homepage})
|
return @tgSections.getPath(project.slug, settings.homepage)
|
||||||
return if !section
|
|
||||||
|
|
||||||
return section.path
|
|
||||||
|
|
||||||
angular.module("taigaProjects").controller("ProjectRouter", ProjectRouterController)
|
angular.module("taigaProjects").controller("ProjectRouter", ProjectRouterController)
|
||||||
|
|
Loading…
Reference in New Issue