Fix default homepage for public projects as guest

stable
Daniel García 2018-11-26 18:41:20 +01:00 committed by Alex Hermida
parent f019be3d3b
commit 0bd3b38a26
1 changed files with 17 additions and 12 deletions

View File

@ -24,6 +24,9 @@
module = angular.module("taigaCommon")
class SectionsService extends taiga.Service
@.$inject = ["$translate", "tgCurrentUserService"]
SECTIONS = {
1: {id: 1, title: 'TIMELINE', path:'timeline', enabled: ''}
2: {id: 2, title: 'EPICS', path:'epics', enabled: 'is_epics_activated'}
@ -33,24 +36,26 @@ SECTIONS = {
6: {id: 6, title: 'WIKI', path:'wiki', enabled: 'is_wiki_activated'}
}
class SectionsService extends taiga.Service
@.$inject = ["$translate", "tgCurrentUserService"]
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")
defaultHomePage = "timeline"
projects = @currentUserService.projects?.get("all")
project = projects.find (p) -> return p.get('slug') == projectSlug
if not project
return defaultHomePage
if not sectionId
sectionId = project.get('my_homepage')
section = _.find(SECTIONS, {"id": sectionId})
section = _.find(SECTIONS, {"id": sectionId})
if !section or project?.get(section.enabled) is not true
return "timeline"
return defaultHomePage
return section.path