mirror of
https://github.com/jupyterhub/jupyterhub.git
synced 2025-10-14 21:43:01 +00:00
WIP
This commit is contained in:

committed by
Duc Trung LE

parent
0e437224d0
commit
28464f9c47
@@ -0,0 +1,29 @@
|
|||||||
|
"""Add from_config column to the services table
|
||||||
|
|
||||||
|
Revision ID: 3c2384c5aae1
|
||||||
|
Revises: 0eee8c825d24
|
||||||
|
Create Date: 2023-02-27 16:22:26.196231
|
||||||
|
"""
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision = '3c2384c5aae1'
|
||||||
|
down_revision = '0eee8c825d24'
|
||||||
|
branch_labels = None
|
||||||
|
depends_on = None
|
||||||
|
|
||||||
|
from alembic import op
|
||||||
|
import sqlalchemy as sa
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade():
|
||||||
|
engine = op.get_bind().engine
|
||||||
|
tables = sa.inspect(engine).get_table_names()
|
||||||
|
if 'services' in tables:
|
||||||
|
op.add_column(
|
||||||
|
'services',
|
||||||
|
sa.Column('from_config', sa.Boolean, nullable=False, default=True),
|
||||||
|
)
|
||||||
|
op.execute('UPDATE services SET from_config = true')
|
||||||
|
|
||||||
|
def downgrade():
|
||||||
|
op.drop_column('services', sa.Column('from_config'))
|
@@ -28,6 +28,12 @@ class ServiceAPIHandler(APIHandler):
|
|||||||
service = self.services[service_name]
|
service = self.services[service_name]
|
||||||
self.write(json.dumps(self.service_model(service)))
|
self.write(json.dumps(self.service_model(service)))
|
||||||
|
|
||||||
|
@needs_scope('read:services', 'read:services:name', 'read:roles:services')
|
||||||
|
def post(self, service_name):
|
||||||
|
model = self.get_json_body()
|
||||||
|
print('############', model)
|
||||||
|
self.write('ok')
|
||||||
|
|
||||||
|
|
||||||
default_handlers = [
|
default_handlers = [
|
||||||
(r"/api/services", ServiceListAPIHandler),
|
(r"/api/services", ServiceListAPIHandler),
|
||||||
|
@@ -2371,7 +2371,7 @@ class JupyterHub(Application):
|
|||||||
orm_service = orm.Service.find(self.db, name=name)
|
orm_service = orm.Service.find(self.db, name=name)
|
||||||
if orm_service is None:
|
if orm_service is None:
|
||||||
# not found, create a new one
|
# not found, create a new one
|
||||||
orm_service = orm.Service(name=name)
|
orm_service = orm.Service(name=name, from_config=True)
|
||||||
self.db.add(orm_service)
|
self.db.add(orm_service)
|
||||||
if spec.get('admin', False):
|
if spec.get('admin', False):
|
||||||
self.log.warning(
|
self.log.warning(
|
||||||
|
@@ -416,6 +416,9 @@ class Service(Base):
|
|||||||
ondelete='SET NULL',
|
ondelete='SET NULL',
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
from_config = Column(Boolean, default=True)
|
||||||
|
|
||||||
oauth_client = relationship(
|
oauth_client = relationship(
|
||||||
'OAuthClient',
|
'OAuthClient',
|
||||||
back_populates="service",
|
back_populates="service",
|
||||||
|
Reference in New Issue
Block a user