diff --git a/hubsrht/alembic/versions/de4adc3cc306_add_visibility_enum.py b/hubsrht/alembic/versions/de4adc3cc306_add_visibility_enum.py new file mode 100644 index 0000000..82897ef --- /dev/null +++ b/hubsrht/alembic/versions/de4adc3cc306_add_visibility_enum.py @@ -0,0 +1,41 @@ +"""Add visibility enum + +Revision ID: de4adc3cc306 +Revises: 5b1ac5bdb471 +Create Date: 2022-06-16 01:32:20.691725 + +""" + +# revision identifiers, used by Alembic. +revision = 'de4adc3cc306' +down_revision = '5b1ac5bdb471' + +from alembic import op +import sqlalchemy as sa + + +def upgrade(): + op.execute(""" + CREATE TYPE visibility AS ENUM ( + 'PUBLIC', + 'PRIVATE', + 'UNLISTED' + ); + + ALTER TABLE project + ALTER COLUMN visibility DROP DEFAULT; + ALTER TABLE project + ALTER COLUMN visibility TYPE visibility USING upper(visibility)::visibility; + ALTER TABLE project + ALTER COLUMN visibility SET DEFAULT 'UNLISTED'::visibility; + """) + + +def downgrade(): + op.execute(""" + ALTER TABLE project + ALTER COLUMN visibility TYPE varchar USING lower(visibility::varchar); + ALTER TABLE project + ALTER COLUMN visibility SET DEFAULT 'unlisted'; + DROP TYPE visibility; + """) diff --git a/hubsrht/templates/dashboard.html b/hubsrht/templates/dashboard.html index 7f118de..f2b6b7c 100644 --- a/hubsrht/templates/dashboard.html +++ b/hubsrht/templates/dashboard.html @@ -48,8 +48,8 @@ {% for project in projects %}

- {% if project.visibility.value != 'public' %} - {{project.visibility.value}} + {% if project.visibility.value != 'PUBLIC' %} + {{project.visibility.value.lower()}} {% endif %}

- {% if project.visibility.value != 'public' %} - {{project.visibility.value}} + {% if project.visibility.value != 'PUBLIC' %} + {{project.visibility.value.lower()}} {% endif %} Public + value="PUBLIC"> Public Shown on your profile and listed in the public project index @@ -90,10 +90,10 @@ class="form-check-input" type="radio" name="visibility" - {% if (visibility and visibility == "unlisted") or project.visibility.value == "unlisted" %} + {% if (visibility and visibility == "UNLISTED") or project.visibility.value == "UNLISTED" %} checked {% endif %} - value="unlisted"> Unlisted + value="UNLISTED"> Unlisted Visible to anyone who knows the URL, but not shown on your profile @@ -108,10 +108,10 @@ class="form-check-input" type="radio" name="visibility" - {% if (visibility and visibility == "private") or project.visibility.value == "private" %} + {% if (visibility and visibility == "PRIVATE") or project.visibility.value == "PRIVATE" %} checked {% endif %} - value="private"> Private + value="PRIVATE"> Private Only visible to you and your collaborators diff --git a/hubsrht/templates/project-create.html b/hubsrht/templates/project-create.html index 69c9ca6..ff12f8c 100644 --- a/hubsrht/templates/project-create.html +++ b/hubsrht/templates/project-create.html @@ -76,8 +76,8 @@ class="form-check-input" type="radio" name="visibility" - value="public" - {% if not visibility or visibility == "public" %} + value="PUBLIC" + {% if not visibility or visibility == "PUBLIC" %} checked {% endif %} > Public @@ -95,8 +95,8 @@ class="form-check-input" type="radio" name="visibility" - value="unlisted" - {% if visibility and visibility == "unlisted" %} + value="UNLISTED" + {% if visibility and visibility == "UNLISTED" %} checked {% endif %} > Unlisted @@ -114,8 +114,8 @@ class="form-check-input" type="radio" name="visibility" - value="private" - {% if visibility and visibility == "private" %} + value="PRIVATE" + {% if visibility and visibility == "PRIVATE" %} checked {% endif %} > Private diff --git a/hubsrht/templates/project-nav.html b/hubsrht/templates/project-nav.html index 056be43..3f5fa79 100644 --- a/hubsrht/templates/project-nav.html +++ b/hubsrht/templates/project-nav.html @@ -9,18 +9,18 @@ href="{{ path }}">{{ title }} {% endmacro %}