Restrict project header links
This commit is contained in:
parent
ebae821e39
commit
c59b58daf0
|
@ -0,0 +1,61 @@
|
||||||
|
package migrations
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"git.handmade.network/hmn/hmn/src/migration/types"
|
||||||
|
"git.handmade.network/hmn/hmn/src/oops"
|
||||||
|
"github.com/jackc/pgx/v4"
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
registerMigration(RemoveFeatureFlags{})
|
||||||
|
}
|
||||||
|
|
||||||
|
type RemoveFeatureFlags struct{}
|
||||||
|
|
||||||
|
func (m RemoveFeatureFlags) Version() types.MigrationVersion {
|
||||||
|
return types.MigrationVersion(time.Date(2021, 8, 28, 12, 49, 59, 0, time.UTC))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m RemoveFeatureFlags) Name() string {
|
||||||
|
return "RemoveFeatureFlags"
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m RemoveFeatureFlags) Description() string {
|
||||||
|
return "Convert project feature flags to booleans"
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m RemoveFeatureFlags) Up(ctx context.Context, tx pgx.Tx) error {
|
||||||
|
_, err := tx.Exec(ctx, `
|
||||||
|
ALTER TABLE handmade_project
|
||||||
|
DROP wiki_flags,
|
||||||
|
DROP wiki_last_updated,
|
||||||
|
DROP static_flags,
|
||||||
|
DROP annotation_flags
|
||||||
|
`)
|
||||||
|
if err != nil {
|
||||||
|
return oops.New(err, "failed to drop stupid old columns")
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err = tx.Exec(ctx, `
|
||||||
|
ALTER TABLE handmade_project
|
||||||
|
ALTER forum_flags TYPE BOOLEAN USING forum_flags > 0,
|
||||||
|
ALTER blog_flags TYPE BOOLEAN USING blog_flags > 0,
|
||||||
|
ALTER library_flags TYPE BOOLEAN USING library_flags > 0;
|
||||||
|
|
||||||
|
ALTER TABLE handmade_project RENAME forum_flags TO forum_enabled;
|
||||||
|
ALTER TABLE handmade_project RENAME blog_flags TO blog_enabled;
|
||||||
|
ALTER TABLE handmade_project RENAME library_flags TO library_enabled;
|
||||||
|
`)
|
||||||
|
if err != nil {
|
||||||
|
return oops.New(err, "failed to convert flags to bools")
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m RemoveFeatureFlags) Down(ctx context.Context, tx pgx.Tx) error {
|
||||||
|
panic("Implement me")
|
||||||
|
}
|
|
@ -57,6 +57,10 @@ type Project struct {
|
||||||
Featured bool `db:"featured"`
|
Featured bool `db:"featured"`
|
||||||
DateApproved time.Time `db:"date_approved"`
|
DateApproved time.Time `db:"date_approved"`
|
||||||
AllLastUpdated time.Time `db:"all_last_updated"`
|
AllLastUpdated time.Time `db:"all_last_updated"`
|
||||||
|
|
||||||
|
ForumEnabled bool `db:"forum_enabled"`
|
||||||
|
BlogEnabled bool `db:"blog_enabled"`
|
||||||
|
LibraryEnabled bool `db:"library_enabled"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Project) IsHMN() bool {
|
func (p *Project) IsHMN() bool {
|
||||||
|
|
|
@ -91,9 +91,9 @@ func ProjectToTemplate(p *models.Project, theme string) Project {
|
||||||
|
|
||||||
IsHMN: p.IsHMN(),
|
IsHMN: p.IsHMN(),
|
||||||
|
|
||||||
HasBlog: true, // TODO: Check flag sets or whatever
|
HasBlog: p.BlogEnabled,
|
||||||
HasForum: true,
|
HasForum: p.ForumEnabled,
|
||||||
HasLibrary: true,
|
HasLibrary: false, // TODO: port the library lol
|
||||||
|
|
||||||
DateApproved: p.DateApproved,
|
DateApproved: p.DateApproved,
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,7 +57,6 @@
|
||||||
{{ if .Project.IsHMN }}
|
{{ if .Project.IsHMN }}
|
||||||
<a href="{{ .Header.ManifestoUrl }}" class="misson">Mission</a>
|
<a href="{{ .Header.ManifestoUrl }}" class="misson">Mission</a>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{/* {% if project.default_annotation_category %} */}}
|
|
||||||
{{ if .Header.EpisodeGuideUrl }}
|
{{ if .Header.EpisodeGuideUrl }}
|
||||||
<a href="{{ .Header.EpisodeGuideUrl }}" class="annotations">Episode Guide</a>
|
<a href="{{ .Header.EpisodeGuideUrl }}" class="annotations">Episode Guide</a>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
Loading…
Reference in New Issue