-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[IMP] cetmix_tower_server: implement UI updates #185
base: 14.0-dev
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,7 +44,15 @@ class CxTowerPlanLine(models.Model): | |
help="Actions trigger based on command result." | ||
" If empty next command will be executed", | ||
) | ||
command_code = fields.Text(related="command_id.code", readonly=True) | ||
command_code = fields.Text( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This approach doesn't allow to check those lines if required. |
||
string="Code", compute="_compute_command_code", readonly=True | ||
) | ||
plan_line_ids = fields.One2many( | ||
comodel_name="cx.tower.plan.line", | ||
compute="_compute_plan_line_ids", | ||
string="Plan Lines", | ||
readonly=True, | ||
) | ||
action = fields.Selection(related="command_id.action", readonly=True) | ||
tag_ids = fields.Many2many(related="command_id.tag_ids", readonly=True) | ||
access_level = fields.Selection( | ||
|
@@ -88,6 +96,31 @@ def _check_command_id(self): | |
visited_plans = set() | ||
self._check_recursive_plan(line.command_id, visited_plans) | ||
|
||
@api.depends("command_id", "action") | ||
def _compute_command_code(self): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No need to compute anything. Just hide this field if command action is not SSH or Python. |
||
""" | ||
Compute the preview of the command based on its action. | ||
""" | ||
for line in self: | ||
if line.action == "file_using_template": | ||
line.command_code = line.command_id.code or "No template code available" | ||
elif line.action == "plan": | ||
line.command_code = False | ||
elif line.action != "plan": | ||
line.command_code = "No preview available" | ||
|
||
@api.depends("command_id", "action") | ||
def _compute_plan_line_ids(self): | ||
""" | ||
Compute the related plan lines if the action is "plan". | ||
""" | ||
for line in self: | ||
if line.action == "plan": | ||
flight_plan = line.command_id.flight_plan_id | ||
line.plan_line_ids = flight_plan.line_ids if flight_plan else [] | ||
else: | ||
line.plan_line_ids = False | ||
|
||
def _check_recursive_plan(self, command, visited_plans): | ||
""" | ||
Recursively check if the command plan creates a cycle. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to show all these fields. Just show the related flight_plan_line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is still pending.