Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
dify
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ai-tech
dify
Commits
4be7f3e0
Commit
4be7f3e0
authored
Feb 26, 2024
by
takatost
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make recommended app list api public
parent
15ce6e12
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
20 deletions
+12
-20
recommended_app.py
api/controllers/console/explore/recommended_app.py
+12
-20
No files found.
api/controllers/console/explore/recommended_app.py
View file @
4be7f3e0
from
flask_login
import
current_user
from
flask_restful
import
Resource
,
fields
,
marshal_with
from
flask_restful
import
Resource
,
fields
,
marshal_with
,
reqparse
from
sqlalchemy
import
and_
from
constants.languages
import
languages
...
...
@@ -28,9 +28,6 @@ recommended_app_fields = {
'category'
:
fields
.
String
,
'position'
:
fields
.
Integer
,
'is_listed'
:
fields
.
Boolean
,
'install_count'
:
fields
.
Integer
,
'installed'
:
fields
.
Boolean
,
'editable'
:
fields
.
Boolean
,
'is_agent'
:
fields
.
Boolean
}
...
...
@@ -41,11 +38,19 @@ recommended_app_list_fields = {
class
RecommendedAppListApi
(
Resource
):
@
login_required
@
account_initialization_required
@
marshal_with
(
recommended_app_list_fields
)
def
get
(
self
):
language_prefix
=
current_user
.
interface_language
if
current_user
.
interface_language
else
languages
[
0
]
# language args
parser
=
reqparse
.
RequestParser
()
parser
.
add_argument
(
'language'
,
type
=
str
,
location
=
'args'
)
args
=
parser
.
parse_args
()
if
args
.
get
(
'language'
)
and
args
.
get
(
'language'
)
in
languages
:
language_prefix
=
args
.
get
(
'language'
)
elif
current_user
and
current_user
.
interface_language
:
language_prefix
=
current_user
.
interface_language
else
:
language_prefix
=
languages
[
0
]
recommended_apps
=
db
.
session
.
query
(
RecommendedApp
)
.
filter
(
RecommendedApp
.
is_listed
==
True
,
...
...
@@ -53,16 +58,8 @@ class RecommendedAppListApi(Resource):
)
.
all
()
categories
=
set
()
current_user
.
role
=
TenantService
.
get_user_role
(
current_user
,
current_user
.
current_tenant
)
recommended_apps_result
=
[]
for
recommended_app
in
recommended_apps
:
installed
=
db
.
session
.
query
(
InstalledApp
)
.
filter
(
and_
(
InstalledApp
.
app_id
==
recommended_app
.
app_id
,
InstalledApp
.
tenant_id
==
current_user
.
current_tenant_id
)
)
.
first
()
is
not
None
app
=
recommended_app
.
app
if
not
app
or
not
app
.
is_public
:
continue
...
...
@@ -81,9 +78,6 @@ class RecommendedAppListApi(Resource):
'category'
:
recommended_app
.
category
,
'position'
:
recommended_app
.
position
,
'is_listed'
:
recommended_app
.
is_listed
,
'install_count'
:
recommended_app
.
install_count
,
'installed'
:
installed
,
'editable'
:
current_user
.
role
in
[
'owner'
,
'admin'
],
"is_agent"
:
app
.
is_agent
}
recommended_apps_result
.
append
(
recommended_app_result
)
...
...
@@ -114,8 +108,6 @@ class RecommendedAppApi(Resource):
'app_model_config'
:
fields
.
Nested
(
model_config_fields
),
}
@
login_required
@
account_initialization_required
@
marshal_with
(
app_simple_detail_fields
)
def
get
(
self
,
app_id
):
app_id
=
str
(
app_id
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment