M gitsrht/access.py => gitsrht/access.py +4 -4
@@ 1,7 1,7 @@
from datetime import datetime
from enum import IntFlag
from flask import abort, current_app, request, redirect, url_for
-from gitsrht.types import Access, AccessMode, Repository, Redirect, User, RepoVisibility
+from gitsrht.types import Access, AccessMode, Repository, Redirect, User, Visibility
from srht.database import db
from srht.oauth import current_user
import sqlalchemy as sa
@@ 60,8 60,8 @@ def get_access(repo, user=None):
# Just pretend they have full access for long enough to do the redirect
return UserAccess.read | UserAccess.write | UserAccess.manage
if not user:
- if repo.visibility == RepoVisibility.PUBLIC or \
- repo.visibility == RepoVisibility.UNLISTED:
+ if repo.visibility == Visibility.PUBLIC or \
+ repo.visibility == Visibility.UNLISTED:
return UserAccess.read
return UserAccess.none
if repo.owner_id == user.id:
@@ 76,7 76,7 @@ def get_access(repo, user=None):
return UserAccess.read
else:
return UserAccess.read | UserAccess.write
- if repo.visibility == RepoVisibility.PRIVATE:
+ if repo.visibility == Visibility.PRIVATE:
return UserAccess.none
return UserAccess.read
M gitsrht/blueprints/api/info.py => gitsrht/blueprints/api/info.py +2 -2
@@ 1,7 1,7 @@
from flask import Blueprint, Response, current_app, request
import gitsrht.repos as repos
from gitsrht.access import UserAccess
-from gitsrht.types import Access, Repository, User, RepoVisibility
+from gitsrht.types import Access, Repository, User, Visibility
from gitsrht.webhooks import UserWebhook
from gitsrht.blueprints.api import get_user, get_repo
from srht.api import paginated_response
@@ 27,7 27,7 @@ def repos_by_user_GET(username):
.filter(or_(
Access.user_id == current_token.user_id,
and_(
- Repository.visibility == RepoVisibility.PUBLIC,
+ Repository.visibility == Visibility.PUBLIC,
Access.id.is_(None))
)))
return paginated_response(Repository.id, repos)
M gitsrht/blueprints/public.py => gitsrht/blueprints/public.py +3 -3
@@ 4,7 4,7 @@ from srht.config import cfg
from srht.flask import paginate_query
from srht.oauth import current_user
from srht.search import search_by
-from gitsrht.types import Access, Repository, User, RepoVisibility
+from gitsrht.types import Access, Repository, User, Visibility
from sqlalchemy import and_, or_
public = Blueprint('public', __name__)
@@ 34,10 34,10 @@ def user_index(username):
Access.repo_id == Repository.id)
.filter(or_(
Access.user_id == current_user.id,
- Repository.visibility == RepoVisibility.PUBLIC,
+ Repository.visibility == Visibility.PUBLIC,
)))
elif not current_user:
- repos = repos.filter(Repository.visibility == RepoVisibility.PUBLIC)
+ repos = repos.filter(Repository.visibility == Visibility.PUBLIC)
search_error = None
try:
M gitsrht/types/__init__.py => gitsrht/types/__init__.py +2 -2
@@ 89,7 89,7 @@ class Redirect(Base):
def new_repo(cls):
return sa.orm.relationship('Repository')
-class RepoVisibility(Enum):
+class Visibility(Enum):
# NOTE: SQLAlchemy uses the enum member names, not the values.
# The values are used by templates. Therfore, we capitalize both.
PUBLIC = 'PUBLIC'
@@ 115,7 115,7 @@ class Repository(Base):
name = sa.Column(sa.Unicode(256), nullable=False)
description = sa.Column(sa.Unicode(1024))
path = sa.Column(sa.Unicode(1024))
- visibility = sa.Column(postgresql.ENUM(RepoVisibility), nullable=False)
+ visibility = sa.Column(postgresql.ENUM(Visibility), nullable=False)
readme = sa.Column(sa.Unicode)
clone_status = sa.Column(postgresql.ENUM(
'NONE', 'IN_PROGRESS', 'COMPLETE', 'ERROR', name='clone_status'), nullable=False)