mirror of https://git.sr.ht/~sircmpwn/hub.sr.ht
hubsrht: Add visibility enum
This commit is contained in:
parent
db74624e2a
commit
ab821d423a
|
@ -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;
|
||||||
|
""")
|
|
@ -48,8 +48,8 @@
|
||||||
{% for project in projects %}
|
{% for project in projects %}
|
||||||
<div class="event">
|
<div class="event">
|
||||||
<h4>
|
<h4>
|
||||||
{% if project.visibility.value != 'public' %}
|
{% if project.visibility.value != 'PUBLIC' %}
|
||||||
<small class="text-muted pull-right">{{project.visibility.value}}</small>
|
<small class="text-muted pull-right">{{project.visibility.value.lower()}}</small>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<a href="{{url_for("projects.summary_GET",
|
<a href="{{url_for("projects.summary_GET",
|
||||||
owner=project.owner.canonical_name,
|
owner=project.owner.canonical_name,
|
||||||
|
|
|
@ -60,8 +60,8 @@
|
||||||
{% for project in projects %}
|
{% for project in projects %}
|
||||||
<div class="event">
|
<div class="event">
|
||||||
<h4>
|
<h4>
|
||||||
{% if project.visibility.value != 'public' %}
|
{% if project.visibility.value != 'PUBLIC' %}
|
||||||
<small class="text-muted pull-right">{{project.visibility.value}}</small>
|
<small class="text-muted pull-right">{{project.visibility.value.lower()}}</small>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<a href="{{url_for("projects.summary_GET",
|
<a href="{{url_for("projects.summary_GET",
|
||||||
owner=project.owner.canonical_name,
|
owner=project.owner.canonical_name,
|
||||||
|
|
|
@ -72,10 +72,10 @@
|
||||||
class="form-check-input"
|
class="form-check-input"
|
||||||
type="radio"
|
type="radio"
|
||||||
name="visibility"
|
name="visibility"
|
||||||
{% if (visibility and visibility == "public") or project.visibility.value == "public" %}
|
{% if (visibility and visibility == "PUBLIC") or project.visibility.value == "PUBLIC" %}
|
||||||
checked
|
checked
|
||||||
{% endif %}
|
{% endif %}
|
||||||
value="public"> Public
|
value="PUBLIC"> Public
|
||||||
<small id="visibility-public-help" class="form-text text-muted">
|
<small id="visibility-public-help" class="form-text text-muted">
|
||||||
Shown on your profile and listed in the public project index
|
Shown on your profile and listed in the public project index
|
||||||
</small>
|
</small>
|
||||||
|
@ -90,10 +90,10 @@
|
||||||
class="form-check-input"
|
class="form-check-input"
|
||||||
type="radio"
|
type="radio"
|
||||||
name="visibility"
|
name="visibility"
|
||||||
{% if (visibility and visibility == "unlisted") or project.visibility.value == "unlisted" %}
|
{% if (visibility and visibility == "UNLISTED") or project.visibility.value == "UNLISTED" %}
|
||||||
checked
|
checked
|
||||||
{% endif %}
|
{% endif %}
|
||||||
value="unlisted"> Unlisted
|
value="UNLISTED"> Unlisted
|
||||||
<small id="visibility-unlisted-help" class="form-text text-muted">
|
<small id="visibility-unlisted-help" class="form-text text-muted">
|
||||||
Visible to anyone who knows the URL, but not shown on your profile
|
Visible to anyone who knows the URL, but not shown on your profile
|
||||||
</small>
|
</small>
|
||||||
|
@ -108,10 +108,10 @@
|
||||||
class="form-check-input"
|
class="form-check-input"
|
||||||
type="radio"
|
type="radio"
|
||||||
name="visibility"
|
name="visibility"
|
||||||
{% if (visibility and visibility == "private") or project.visibility.value == "private" %}
|
{% if (visibility and visibility == "PRIVATE") or project.visibility.value == "PRIVATE" %}
|
||||||
checked
|
checked
|
||||||
{% endif %}
|
{% endif %}
|
||||||
value="private"> Private
|
value="PRIVATE"> Private
|
||||||
<small id="visibility-unlisted-help" class="form-text text-muted">
|
<small id="visibility-unlisted-help" class="form-text text-muted">
|
||||||
Only visible to you and your collaborators
|
Only visible to you and your collaborators
|
||||||
</small>
|
</small>
|
||||||
|
|
|
@ -76,8 +76,8 @@
|
||||||
class="form-check-input"
|
class="form-check-input"
|
||||||
type="radio"
|
type="radio"
|
||||||
name="visibility"
|
name="visibility"
|
||||||
value="public"
|
value="PUBLIC"
|
||||||
{% if not visibility or visibility == "public" %}
|
{% if not visibility or visibility == "PUBLIC" %}
|
||||||
checked
|
checked
|
||||||
{% endif %}
|
{% endif %}
|
||||||
> Public
|
> Public
|
||||||
|
@ -95,8 +95,8 @@
|
||||||
class="form-check-input"
|
class="form-check-input"
|
||||||
type="radio"
|
type="radio"
|
||||||
name="visibility"
|
name="visibility"
|
||||||
value="unlisted"
|
value="UNLISTED"
|
||||||
{% if visibility and visibility == "unlisted" %}
|
{% if visibility and visibility == "UNLISTED" %}
|
||||||
checked
|
checked
|
||||||
{% endif %}
|
{% endif %}
|
||||||
> Unlisted
|
> Unlisted
|
||||||
|
@ -114,8 +114,8 @@
|
||||||
class="form-check-input"
|
class="form-check-input"
|
||||||
type="radio"
|
type="radio"
|
||||||
name="visibility"
|
name="visibility"
|
||||||
value="private"
|
value="PRIVATE"
|
||||||
{% if visibility and visibility == "private" %}
|
{% if visibility and visibility == "PRIVATE" %}
|
||||||
checked
|
checked
|
||||||
{% endif %}
|
{% endif %}
|
||||||
> Private
|
> Private
|
||||||
|
|
|
@ -9,18 +9,18 @@
|
||||||
href="{{ path }}">{{ title }}</a>
|
href="{{ path }}">{{ title }}</a>
|
||||||
{% endmacro %}
|
{% endmacro %}
|
||||||
<ul class="nav nav-tabs">
|
<ul class="nav nav-tabs">
|
||||||
{% if project.visibility.value != "public" %}
|
{% if project.visibility.value != "PUBLIC" %}
|
||||||
<li
|
<li
|
||||||
class="nav-item nav-text vis-{{project.visibility.value.lower()}}"
|
class="nav-item nav-text vis-{{project.visibility.value.lower()}}"
|
||||||
{% if project.visibility.value == "unlisted" %}
|
{% if project.visibility.value == "UNLISTED" %}
|
||||||
title="This project is only visible to those who know the URL."
|
title="This project is only visible to those who know the URL."
|
||||||
{% elif project.visibility.value == "private" %}
|
{% elif project.visibility.value == "PRIVATE" %}
|
||||||
title="This project is only visible to those who were invited to view it."
|
title="This project is only visible to those who were invited to view it."
|
||||||
{% endif %}
|
{% endif %}
|
||||||
>
|
>
|
||||||
{% if project.visibility.value == "unlisted" %}
|
{% if project.visibility.value == "UNLISTED" %}
|
||||||
Unlisted
|
Unlisted
|
||||||
{% elif project.visibility.value == "private" %}
|
{% elif project.visibility.value == "PRIVATE" %}
|
||||||
Private
|
Private
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</li>
|
</li>
|
||||||
|
|
|
@ -45,8 +45,8 @@
|
||||||
{% for project in projects %}
|
{% for project in projects %}
|
||||||
<div class="event">
|
<div class="event">
|
||||||
<h4>
|
<h4>
|
||||||
{% if project.visibility.value != 'public' %}
|
{% if project.visibility.value != 'PUBLIC' %}
|
||||||
<small class="text-muted pull-right">{{project.visibility.value}}</small>
|
<small class="text-muted pull-right">{{project.visibility.value.lower()}}</small>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<a href="{{url_for("projects.summary_GET",
|
<a href="{{url_for("projects.summary_GET",
|
||||||
owner=project.owner.canonical_name,
|
owner=project.owner.canonical_name,
|
||||||
|
|
|
@ -6,9 +6,9 @@ class User(Base, ExternalUserMixin):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
class Visibility(Enum):
|
class Visibility(Enum):
|
||||||
public = "public"
|
public = "PUBLIC"
|
||||||
unlisted = "unlisted"
|
private = "PRIVATE"
|
||||||
private = "private"
|
unlisted = "UNLISTED"
|
||||||
|
|
||||||
from hubsrht.types.event import Event, EventType
|
from hubsrht.types.event import Event, EventType
|
||||||
from hubsrht.types.feature import Feature
|
from hubsrht.types.feature import Feature
|
||||||
|
|
Loading…
Reference in New Issue