Skip to content

Commit

Permalink
fix: default visibility for new published runs
Browse files Browse the repository at this point in the history
  • Loading branch information
nikochiko committed Dec 6, 2024
1 parent 44fde02 commit f2c8cb5
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions daras_ai_v2/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -815,7 +815,7 @@ def _render_publish_form(
workspace=selected_workspace,
title=published_run_title.strip(),
notes=published_run_description.strip(),
visibility=PublishedRunVisibility.UNLISTED,
visibility=self._get_default_pr_visibility(selected_workspace),
)
else:
if not self.can_user_edit_published_run(self.current_pr):
Expand Down Expand Up @@ -876,6 +876,14 @@ def _get_default_pr_title(self):
recipe_title = self.get_root_pr().title or self.title
return f"{self.request.user.first_name_possesive()} {recipe_title}"

def _get_default_pr_visibility(self, workspace: Workspace | None = None):
if not workspace:
workspace = self.current_workspace
if workspace and not workspace.is_personal:
return PublishedRunVisibility.INTERNAL
else:
return PublishedRunVisibility.UNLISTED

def _validate_published_run_title(self, title: str):
if slugify(title) in settings.DISALLOWED_TITLE_SLUGS:
raise TitleValidationError(
Expand Down Expand Up @@ -975,7 +983,7 @@ def _saved_options_modal(self):
workspace=self.current_workspace,
title=title,
notes=notes,
visibility=PublishedRunVisibility.UNLISTED,
visibility=self._get_default_pr_visibility(),
)
raise gui.RedirectException(
self.app_url(example_id=duplicate_pr.published_run_id)
Expand All @@ -989,7 +997,7 @@ def _saved_options_modal(self):
workspace=self.current_workspace,
title=title,
notes=notes,
visibility=PublishedRunVisibility.UNLISTED,
visibility=self._get_default_pr_visibility(),
)
raise gui.RedirectException(
self.app_url(example_id=new_pr.published_run_id)
Expand Down Expand Up @@ -1017,7 +1025,7 @@ def _unsaved_options_modal(self):
workspace=self.current_workspace,
title=f"{self.request.user.first_name_possesive()} {pr.title}",
notes=pr.notes,
visibility=PublishedRunVisibility(PublishedRunVisibility.UNLISTED),
visibility=self._get_default_pr_visibility(),
)
raise gui.RedirectException(
self.app_url(example_id=duplicate_pr.published_run_id)
Expand Down Expand Up @@ -1938,7 +1946,7 @@ def publish_and_redirect(self) -> typing.NoReturn | None:
workspace=self.current_workspace,
title=self._get_default_pr_title(),
notes=self.current_pr.notes,
visibility=PublishedRunVisibility(PublishedRunVisibility.UNLISTED),
visibility=self._get_default_pr_visibility(),
)
raise gui.RedirectException(pr.get_app_url())

Expand Down

0 comments on commit f2c8cb5

Please sign in to comment.