[go: nahoru, domu]

Skip to content

Commit

Permalink
Merge pull request #16787 from jmchilton/tool_shed_2
Browse files Browse the repository at this point in the history
Initial bug fixes for tool shed 2.
  • Loading branch information
mvdbeek committed Oct 4, 2023
2 parents 605d8ca + 76c560f commit f51f64b
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 12 deletions.
4 changes: 3 additions & 1 deletion lib/tool_shed/managers/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from tool_shed.webapp.model import User
from tool_shed_client.schema import (
CreateUserRequest,
User as ApiUser,
UserV2 as ApiUser,
)


Expand Down Expand Up @@ -58,9 +58,11 @@ def api_create_user(trans: ProvidesUserContext, request: CreateUserRequest) -> A


def get_api_user(app: ToolShedApp, user: User) -> ApiUser:
admin = app.config.is_admin_user(user)
return ApiUser(
id=app.security.encode_id(user.id),
username=user.username,
is_admin=admin,
)


Expand Down
2 changes: 1 addition & 1 deletion lib/tool_shed/webapp/api2/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
from tool_shed.webapp.model import User as SaUser
from tool_shed_client.schema import (
CreateUserRequest,
User,
UserV2 as User,
)
from . import (
depends,
Expand Down
4 changes: 1 addition & 3 deletions lib/tool_shed/webapp/frontend/src/components/ShedToolbar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,11 @@ defineProps({
required: true,
},
})
// TODO: recover from the API
const ADMINS = ["jmchilton"]
const authStore = useAuthStore()
void authStore.setup()
const admin = computed(() => authStore.user && ADMINS.indexOf(authStore.user.username) > -1)
const admin = computed(() => authStore.user && authStore.user.is_admin)
</script>
<template>
<q-toolbar class="bg-primary glossy text-white">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ const toolsYaml = computed(
<revision-actions
:repository-id="repositoryId"
:current-metadata="currentMetadata"
v-if="currentMetadata"
v-if="currentMetadata && can_manage"
@update="onUpdate"
/>
</revision-select>
Expand Down
14 changes: 8 additions & 6 deletions lib/tool_shed/webapp/frontend/src/schema/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1007,10 +1007,12 @@ export interface components {
/** Email */
email: string
}
/** User */
User: {
/** UserV2 */
UserV2: {
/** Id */
id: string
/** Is Admin */
is_admin: boolean
/** Username */
username: string
}
Expand Down Expand Up @@ -1786,7 +1788,7 @@ export interface operations {
/** @description Successful Response */
200: {
content: {
"application/json": components["schemas"]["User"][]
"application/json": components["schemas"]["UserV2"][]
}
}
}
Expand All @@ -1805,7 +1807,7 @@ export interface operations {
/** @description Successful Response */
200: {
content: {
"application/json": components["schemas"]["User"]
"application/json": components["schemas"]["UserV2"]
}
}
/** @description Validation Error */
Expand All @@ -1825,7 +1827,7 @@ export interface operations {
/** @description Successful Response */
200: {
content: {
"application/json": components["schemas"]["User"]
"application/json": components["schemas"]["UserV2"]
}
}
}
Expand All @@ -1845,7 +1847,7 @@ export interface operations {
/** @description Successful Response */
200: {
content: {
"application/json": components["schemas"]["User"]
"application/json": components["schemas"]["UserV2"]
}
}
/** @description Validation Error */
Expand Down
4 changes: 4 additions & 0 deletions lib/tool_shed_client/schema/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ class User(BaseModel):
username: str


class UserV2(User):
is_admin: bool


class Category(BaseModel):
id: str
name: str
Expand Down

0 comments on commit f51f64b

Please sign in to comment.