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
|
||||
|
||||
if options['section']
|
||||
sections = tgSections.list()
|
||||
section = _.find(sections, {"id": options['section']})
|
||||
name = "#{name}-#{section.path}"
|
||||
path = tgSections.getPath(options['project'], options['section'])
|
||||
name = "#{name}-#{path}"
|
||||
|
||||
url = $navurls.resolve(name)
|
||||
|
||||
|
|
|
@ -25,21 +25,29 @@
|
|||
module = angular.module("taigaCommon")
|
||||
|
||||
SECTIONS = {
|
||||
1: {id: 1, title: 'TIMELINE', path:'timeline'}
|
||||
2: {id: 2, title: 'EPICS', path:'epics'}
|
||||
3: {id: 3, title: 'BACKLOG', path:'backlog'}
|
||||
4: {id: 4, title: 'KANBAN', path:'kanban'}
|
||||
5: {id: 5, title: 'ISSUES', path:'issues'}
|
||||
6: {id: 6, title: 'WIKI', path:'wiki'}
|
||||
1: {id: 1, title: 'TIMELINE', path:'timeline', enabled: ''}
|
||||
2: {id: 2, title: 'EPICS', path:'epics', enabled: 'is_epics_activated'}
|
||||
3: {id: 3, title: 'BACKLOG', path:'backlog', enabled: 'is_backlog_activated'}
|
||||
4: {id: 4, title: 'KANBAN', path:'kanban', enabled: 'is_kanban_activated'}
|
||||
5: {id: 5, title: 'ISSUES', path:'issues', enabled: 'is_issues_activated'}
|
||||
6: {id: 6, title: 'WIKI', path:'wiki', enabled: 'is_wiki_activated'}
|
||||
}
|
||||
|
||||
class SectionsService extends taiga.Service
|
||||
@.$inject = ["$translate"]
|
||||
@.$inject = ["$translate", "tgCurrentUserService"]
|
||||
|
||||
constructor: (@translate) ->
|
||||
constructor: (@translate, @currentUserService) ->
|
||||
super()
|
||||
_.map(SECTIONS, (x) => x.title = @translate.instant("PROJECT.SECTION.#{x.title}"))
|
||||
list: () ->
|
||||
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)
|
||||
|
|
|
@ -40,16 +40,12 @@ class ProjectRouterController
|
|||
@location.url("project/#{@routeParams.pslug}/timeline")
|
||||
|
||||
getProjectHomepage: () ->
|
||||
sections = @tgSections.list()
|
||||
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})
|
||||
return if !settings
|
||||
|
||||
section = _.find(sections, {"id": settings.homepage})
|
||||
return if !section
|
||||
|
||||
return section.path
|
||||
return @tgSections.getPath(project.slug, settings.homepage)
|
||||
|
||||
angular.module("taigaProjects").controller("ProjectRouter", ProjectRouterController)
|
||||
|
|
Loading…
Reference in New Issue