Skip to content

Commit

Permalink
Merge pull request #1005 from dimagi/cs/assistant_chip
Browse files Browse the repository at this point in the history
Show Assistant chip in version details
  • Loading branch information
SmittieC authored Dec 19, 2024
2 parents 1fe287b + f2f88e0 commit d8b5e9f
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion apps/experiments/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from django.core.validators import MaxValueValidator, MinValueValidator, validate_email
from django.db import models, transaction
from django.db.models import BooleanField, Case, Count, F, OuterRef, Q, Subquery, UniqueConstraint, When
from django.template.loader import get_template
from django.urls import reverse
from django.utils import timezone
from django.utils.translation import gettext
Expand Down Expand Up @@ -907,7 +908,14 @@ def format_custom_action_operation(op) -> str:
def _format_assistant(assistant) -> str:
if not assistant:
return ""
return assistant.name.split(f" v{assistant.version_number}")[0]
name = assistant.name.split(f" v{assistant.version_number}")[0]
template = get_template("generic/chip.html")
url = (
assistant.get_absolute_url()
if assistant.is_working_version
else assistant.working_version.get_absolute_url()
)
return template.render({"chip": Chip(label=name, url=url)})

return Version(
instance=self,
Expand Down

0 comments on commit d8b5e9f

Please sign in to comment.