|
3 | 3 | from enum import Enum |
4 | 4 |
|
5 | 5 | import gooey_gui as gui |
6 | | -from django.db.models import Q |
7 | 6 | from fastapi.requests import Request |
8 | 7 | from furl import furl |
9 | 8 | from loguru import logger |
10 | 9 | from requests.models import HTTPError |
11 | 10 | from starlette.exceptions import HTTPException |
12 | 11 |
|
13 | | -from bots.models import PublishedRun, WorkflowAccessLevel, Workflow |
14 | 12 | from daras_ai_v2 import icons, paypal |
15 | 13 | from daras_ai_v2.billing import billing_page |
16 | 14 | from daras_ai_v2.fastapi_tricks import get_app_route_url, get_route_path |
17 | | -from daras_ai_v2.grid_layout_widget import grid_layout |
18 | 15 | from daras_ai_v2.manage_api_keys_widget import manage_api_keys |
19 | 16 | from daras_ai_v2.meta_content import raw_build_meta_tags |
20 | 17 | from daras_ai_v2.profiles import edit_user_profile_page |
21 | | -from daras_ai_v2.urls import paginate_queryset, paginate_button |
22 | 18 | from managed_secrets.widgets import manage_secrets_table |
23 | 19 | from payments.webhooks import PaypalWebhookHandler |
24 | 20 | from routers.custom_api_router import CustomAPIRouter |
25 | 21 | from routers.root import explore_page, page_wrapper, get_og_url_path |
26 | | -from widgets.saved_workflow import render_saved_workflow_preview |
27 | 22 | from workspaces.models import Workspace, WorkspaceInvite |
28 | 23 | from workspaces.views import invitation_page, workspaces_page |
29 | 24 | from workspaces.widgets import get_current_workspace, SWITCH_WORKSPACE_KEY |
@@ -137,10 +132,6 @@ def profile_route(request: Request): |
137 | 132 |
|
138 | 133 |
|
139 | 134 | @gui.route(app, "/saved") |
140 | | -def old_saved_route(request: Request): |
141 | | - raise gui.RedirectException(get_route_path(saved_route)) |
142 | | - |
143 | | - |
144 | 135 | @gui.route(app, "/account/saved") |
145 | 136 | def saved_route(request: Request): |
146 | 137 | from widgets.workflow_search import SearchFilters, get_filter_value_from_workspace |
@@ -240,7 +231,6 @@ class TabData(typing.NamedTuple): |
240 | 231 | class AccountTabs(TabData, Enum): |
241 | 232 | profile = TabData(title=f"{icons.profile} Profile", route=profile_route) |
242 | 233 | members = TabData(title=f"{icons.company} Members", route=members_route) |
243 | | - saved = TabData(title=f"{icons.save} Saved", route=saved_route) |
244 | 234 | api_keys = TabData(title=f"{icons.api} API Keys", route=api_keys_route) |
245 | 235 | billing = TabData(title=f"{icons.billing} Billing", route=account_route) |
246 | 236 |
|
@@ -274,84 +264,6 @@ def profile_tab(request: Request, workspace: Workspace): |
274 | 264 | return edit_user_profile_page(workspace=workspace) |
275 | 265 |
|
276 | 266 |
|
277 | | -def all_saved_runs_tab(request: Request): |
278 | | - workspace = get_current_workspace(request.user, request.session) |
279 | | - pr_filter = Q(workspace=workspace) |
280 | | - if workspace.is_personal: |
281 | | - pr_filter |= Q(created_by=request.user, workspace__isnull=True) |
282 | | - else: |
283 | | - pr_filter &= ( |
284 | | - ~Q(workspace_access=WorkflowAccessLevel.VIEW_ONLY) |
285 | | - | Q(created_by=request.user) |
286 | | - | ~Q(public_access=WorkflowAccessLevel.VIEW_ONLY) |
287 | | - ) |
288 | | - |
289 | | - qs = PublishedRun.objects.select_related( |
290 | | - "workspace", "created_by", "saved_run" |
291 | | - ).filter(pr_filter) |
292 | | - |
293 | | - prs, cursor = paginate_queryset( |
294 | | - qs=qs, ordering=["-updated_at"], cursor=request.query_params |
295 | | - ) |
296 | | - |
297 | | - gui.write("# Saved Workflows") |
298 | | - explore_path = get_route_path(explore_page) |
299 | | - |
300 | | - if not prs: |
301 | | - # empty state |
302 | | - if workspace.is_personal: |
303 | | - gui.caption( |
304 | | - f""" |
305 | | - You haven't saved any workflows yet. To get started, \ |
306 | | - [Explore our workflows]({explore_path}) and tap **Save** \ |
307 | | - to make one your own. |
308 | | - """ |
309 | | - ) |
310 | | - else: |
311 | | - gui.caption( |
312 | | - f""" |
313 | | - Your team hasn't shared any saved workflows yet. To get started, \ |
314 | | - [Explore our workflows]({explore_path}) and tap **Save** to \ |
315 | | - collaborate together. |
316 | | - """ |
317 | | - ) |
318 | | - return |
319 | | - |
320 | | - if workspace.is_personal: |
321 | | - if handle := workspace.handle: |
322 | | - gui.caption( |
323 | | - f""" |
324 | | - All your Saved workflows are here, with public ones listed on your \ |
325 | | - profile page at {handle.get_app_url()}. |
326 | | - """ |
327 | | - ) |
328 | | - else: |
329 | | - edit_profile_url = AccountTabs.profile.url_path |
330 | | - gui.caption( |
331 | | - f""" |
332 | | - All your Saved workflows are here. Public ones will be listed on \ |
333 | | - your profile page if you [create a username]({edit_profile_url}). |
334 | | - """ |
335 | | - ) |
336 | | - else: |
337 | | - workspace_name = workspace.display_name(request.user) |
338 | | - gui.caption( |
339 | | - f"Saved workflows of **{workspace_name}** are here and visible & editable by other workspace members." |
340 | | - ) |
341 | | - |
342 | | - def _render_run(pr: PublishedRun): |
343 | | - workflow = Workflow(pr.workflow) |
344 | | - render_saved_workflow_preview( |
345 | | - workflow.page_cls, |
346 | | - pr, |
347 | | - workflow_pill=f"{workflow.emoji} {workflow.short_title}", |
348 | | - ) |
349 | | - |
350 | | - grid_layout(1, prs, _render_run) |
351 | | - |
352 | | - paginate_button(url=request.url, cursor=cursor) |
353 | | - |
354 | | - |
355 | 267 | def api_keys_tab(request: Request): |
356 | 268 | workspace = get_current_workspace(request.user, request.session) |
357 | 269 |
|
|
0 commit comments