diff --git a/src/models/project.go b/src/models/project.go index 43f62638..24dc591f 100644 --- a/src/models/project.go +++ b/src/models/project.go @@ -67,7 +67,7 @@ type Project struct { ForumEnabled bool `db:"forum_enabled"` BlogEnabled bool `db:"blog_enabled"` - LibraryEnabled bool `db:"library_enabled"` + LibraryEnabled bool `db:"library_enabled"` // TODO: Delete this field from the db } func (p *Project) IsHMN() bool { @@ -82,6 +82,19 @@ func (p *Project) Subdomain() string { return p.Slug } +// Checks whether the project has forums enabled. This should restrict the creation of new forum +// content, but it should NOT prevent the viewing of existing forum content. (Projects may at one +// point have forums enabled, write some stuff, and then later disable forums, and we want that +// content to stay accessible.) Hiding the navigation is ok. +func (p *Project) HasForums() bool { + return !p.Personal && p.ForumEnabled +} + +// Same as HasForums, but for blogs. +func (p *Project) HasBlog() bool { + return !p.Personal && p.BlogEnabled +} + var slugUnsafeChars = regexp.MustCompile(`[^a-zA-Z0-9-]`) var slugHyphenRun = regexp.MustCompile(`-+`) diff --git a/src/templates/mapping.go b/src/templates/mapping.go index 364f4abd..5bf86ac6 100644 --- a/src/templates/mapping.go +++ b/src/templates/mapping.go @@ -80,8 +80,8 @@ func ProjectToTemplate(p *models.Project, url string, theme string) Project { IsHMN: p.IsHMN(), - HasBlog: p.BlogEnabled, - HasForum: p.ForumEnabled, + HasBlog: p.HasBlog(), + HasForum: p.HasForums(), DateApproved: p.DateApproved, } diff --git a/src/templates/src/blog_post.html b/src/templates/src/blog_post.html index b984dfe3..fd7444db 100644 --- a/src/templates/src/blog_post.html +++ b/src/templates/src/blog_post.html @@ -20,7 +20,7 @@