Remove raw IDs from some places

This commit is contained in:
2026-03-03 17:45:50 +00:00
parent 8ea2afb259
commit 506ea8a3b8
4 changed files with 87 additions and 69 deletions

View File

@@ -304,72 +304,74 @@
</div> </div>
</div> </div>
<div class="columns"> {% if profile.show_actions_editor %}
<div class="column"> <div class="columns">
<h3 class="title is-7">Actions</h3> <div class="column">
<p class="help">Enable/disable each step and use the reorder capsule to change execution order.</p> <h3 class="title is-7">Actions</h3>
<table class="table is-fullwidth is-striped is-size-7"> <p class="help">Enable/disable each step and use the reorder capsule to change execution order.</p>
<thead> <table class="table is-fullwidth is-striped is-size-7">
<tr><th scope="col">Type</th><th scope="col">Enabled</th><th scope="col">Reorder</th><th scope="col">Actions</th></tr> <thead>
</thead> <tr><th scope="col">Type</th><th scope="col">Enabled</th><th scope="col">Reorder</th><th scope="col">Actions</th></tr>
<tbody> </thead>
{% for action_row in profile.actions.all %} <tbody>
<tr> {% for action_row in profile.actions.all %}
<td> <tr>
{% if action_row.action_type == "extract_bp" %}Extract Business Plan <td>
{% elif action_row.action_type == "save_document" %}Save Document {% if action_row.action_type == "extract_bp" %}Extract Business Plan
{% elif action_row.action_type == "post_result" %}Post Result {% elif action_row.action_type == "save_document" %}Save Document
{% else %}{{ action_row.action_type }} {% elif action_row.action_type == "post_result" %}Post Result
{% endif %} {% else %}{{ action_row.action_type }}
</td>
<td>{{ action_row.enabled }}</td>
<td>
<span class="command-order-capsule">
<form method="post" class="command-order-capsule-form" aria-label="Move action {{ action_row.action_type }} up for {{ profile.name }}">
{% csrf_token %}
<input type="hidden" name="action" value="action_move">
<input type="hidden" name="command_action_id" value="{{ action_row.id }}">
<input type="hidden" name="direction" value="up">
{% if scope_service and scope_identifier %}
<input type="hidden" name="service" value="{{ scope_service }}">
<input type="hidden" name="identifier" value="{{ scope_identifier }}">
{% endif %}
<button class="button is-small is-light command-order-btn" type="submit" {% if forloop.first %}disabled{% endif %} aria-label="Move up"></button>
</form>
<form method="post" class="command-order-capsule-form" aria-label="Move action {{ action_row.action_type }} down for {{ profile.name }}">
{% csrf_token %}
<input type="hidden" name="action" value="action_move">
<input type="hidden" name="command_action_id" value="{{ action_row.id }}">
<input type="hidden" name="direction" value="down">
{% if scope_service and scope_identifier %}
<input type="hidden" name="service" value="{{ scope_service }}">
<input type="hidden" name="identifier" value="{{ scope_identifier }}">
{% endif %}
<button class="button is-small is-light command-order-btn" type="submit" {% if forloop.last %}disabled{% endif %} aria-label="Move down"></button>
</form>
</span>
</td>
<td>
<form method="post" aria-label="Update action {{ action_row.action_type }} for {{ profile.name }}">
{% csrf_token %}
<input type="hidden" name="action" value="action_update">
<input type="hidden" name="command_action_id" value="{{ action_row.id }}">
{% if scope_service and scope_identifier %}
<input type="hidden" name="service" value="{{ scope_service }}">
<input type="hidden" name="identifier" value="{{ scope_identifier }}">
{% endif %} {% endif %}
<label class="checkbox is-size-7"><input type="checkbox" name="enabled" value="1" {% if action_row.enabled %}checked{% endif %}> enabled</label> </td>
<button class="button is-link is-light is-small" type="submit">Save</button> <td>{{ action_row.enabled }}</td>
</form> <td>
</td> <span class="command-order-capsule">
</tr> <form method="post" class="command-order-capsule-form" aria-label="Move action {{ action_row.action_type }} up for {{ profile.name }}">
{% empty %} {% csrf_token %}
<tr><td colspan="4">No actions.</td></tr> <input type="hidden" name="action" value="action_move">
{% endfor %} <input type="hidden" name="command_action_id" value="{{ action_row.id }}">
</tbody> <input type="hidden" name="direction" value="up">
</table> {% if scope_service and scope_identifier %}
<input type="hidden" name="service" value="{{ scope_service }}">
<input type="hidden" name="identifier" value="{{ scope_identifier }}">
{% endif %}
<button class="button is-small is-light command-order-btn" type="submit" {% if forloop.first %}disabled{% endif %} aria-label="Move up"></button>
</form>
<form method="post" class="command-order-capsule-form" aria-label="Move action {{ action_row.action_type }} down for {{ profile.name }}">
{% csrf_token %}
<input type="hidden" name="action" value="action_move">
<input type="hidden" name="command_action_id" value="{{ action_row.id }}">
<input type="hidden" name="direction" value="down">
{% if scope_service and scope_identifier %}
<input type="hidden" name="service" value="{{ scope_service }}">
<input type="hidden" name="identifier" value="{{ scope_identifier }}">
{% endif %}
<button class="button is-small is-light command-order-btn" type="submit" {% if forloop.last %}disabled{% endif %} aria-label="Move down"></button>
</form>
</span>
</td>
<td>
<form method="post" aria-label="Update action {{ action_row.action_type }} for {{ profile.name }}">
{% csrf_token %}
<input type="hidden" name="action" value="action_update">
<input type="hidden" name="command_action_id" value="{{ action_row.id }}">
{% if scope_service and scope_identifier %}
<input type="hidden" name="service" value="{{ scope_service }}">
<input type="hidden" name="identifier" value="{{ scope_identifier }}">
{% endif %}
<label class="checkbox is-size-7"><input type="checkbox" name="enabled" value="1" {% if action_row.enabled %}checked{% endif %}> enabled</label>
<button class="button is-link is-light is-small" type="submit">Save</button>
</form>
</td>
</tr>
{% empty %}
<tr><td colspan="4">No actions.</td></tr>
{% endfor %}
</tbody>
</table>
</div>
</div> </div>
</div> {% endif %}
<form method="post" style="margin-top: 0.75rem;" aria-label="Delete profile {{ profile.name }}"> <form method="post" style="margin-top: 0.75rem;" aria-label="Delete profile {{ profile.name }}">
{% csrf_token %} {% csrf_token %}

View File

@@ -2,7 +2,7 @@
{% block content %} {% block content %}
<section class="section"><div class="container"> <section class="section"><div class="container">
<h1 class="title is-4">Group Tasks: {{ channel_display_name }}</h1> <h1 class="title is-4">Group Tasks: {{ channel_display_name }}</h1>
<p class="subtitle is-6">{{ service_label }} · {{ identifier }}</p> <p class="subtitle is-6">{{ service_label }}</p>
<article class="box"> <article class="box">
<h2 class="title is-6">Create Or Map Project</h2> <h2 class="title is-6">Create Or Map Project</h2>
<form method="post" style="margin-bottom: 0.7rem;"> <form method="post" style="margin-bottom: 0.7rem;">
@@ -68,10 +68,7 @@
<td>{{ row.project.name }}</td> <td>{{ row.project.name }}</td>
<td>{% if row.epic %}{{ row.epic.name }}{% else %}-{% endif %}</td> <td>{% if row.epic %}{{ row.epic.name }}{% else %}-{% endif %}</td>
<td> <td>
<div><code>{{ row.service }} · {{ row.channel_identifier }}</code></div> <div>{{ row.display_service_label }} · {{ row.display_channel_name }}</div>
{% if channel_display_name %}
<p class="is-size-7 has-text-dark" style="margin-top:0.2rem;">{{ channel_display_name }}</p>
{% endif %}
</td> </td>
<td>{{ row.enabled }}</td> <td>{{ row.enabled }}</td>
<td><a class="button is-small is-light" href="{% url 'tasks_project' project_id=row.project_id %}">Open Project</a></td> <td><a class="button is-small is-light" href="{% url 'tasks_project' project_id=row.project_id %}">Open Project</a></td>

View File

@@ -79,6 +79,7 @@ class CommandRoutingSettings(LoginRequiredMixin, View):
preview_profile_id = str(request.GET.get("preview_profile_id") or "").strip() preview_profile_id = str(request.GET.get("preview_profile_id") or "").strip()
for profile in profiles: for profile in profiles:
policies = ensure_variant_policies_for_profile(profile) policies = ensure_variant_policies_for_profile(profile)
profile.show_actions_editor = str(profile.slug or "").strip() != "bp"
if str(profile.slug or "").strip() == "bp": if str(profile.slug or "").strip() == "bp":
keys = BP_VARIANT_KEYS keys = BP_VARIANT_KEYS
else: else:
@@ -172,6 +173,9 @@ class CommandRoutingSettings(LoginRequiredMixin, View):
action_type="extract_bp", action_type="extract_bp",
defaults={"enabled": True, "position": 0}, defaults={"enabled": True, "position": 0},
) )
# Keep legacy action rows in storage for compatibility and for
# potential reuse by non-bp commands; bp UI now relies on
# variant policies instead of exposing the generic action matrix.
CommandAction.objects.get_or_create( CommandAction.objects.get_or_create(
profile=profile, profile=profile,
action_type="save_document", action_type="save_document",

View File

@@ -683,6 +683,21 @@ class TaskGroupDetail(LoginRequiredMixin, View):
service__in=service_keys, service__in=service_keys,
channel_identifier__in=variants, channel_identifier__in=variants,
).select_related("project", "epic") ).select_related("project", "epic")
mappings = list(mappings)
for row in mappings:
row_channel = _resolve_channel_display(
request.user,
str(getattr(row, "service", "") or ""),
str(getattr(row, "channel_identifier", "") or ""),
)
row.display_service_label = row_channel.get("service_label") or _service_label(
str(getattr(row, "service", "") or "")
)
row.display_channel_name = (
str(row_channel.get("display_name") or "").strip()
or str(channel.get("display_name") or "").strip()
or "Unknown chat"
)
tasks = ( tasks = (
DerivedTask.objects.filter( DerivedTask.objects.filter(
user=request.user, user=request.user,