From: Christian Heller <c.heller@plomlompom.de>
Date: Thu, 6 Jun 2024 01:54:54 +0000 (+0200)
Subject: For Processes and Conditions, in edit page title warn if creation NEW.
X-Git-Url: https://plomlompom.com/repos/%7B%7Bdb.prefix%7D%7D/static/%7B%7B%20web_path%20%7D%7D/%7B%7Bprefix%7D%7D/day?a=commitdiff_plain;h=4c546e0133670dd10aec890c3cea6329c3a29663;p=plomtask

For Processes and Conditions, in edit page title warn if creation NEW.
---

diff --git a/plomtask/http.py b/plomtask/http.py
index ea1358a..2d5db82 100644
--- a/plomtask/http.py
+++ b/plomtask/http.py
@@ -214,7 +214,7 @@ class TaskHandler(BaseHTTPRequestHandler):
         id_ = self.params.get_int_or_none('id')
         c = Condition.by_id(self.conn, id_, create=True)
         ps = Process.all(self.conn)
-        return {'condition': c,
+        return {'condition': c, 'is_new': c.id_ is None,
                 'enabled_processes': [p for p in ps if c in p.conditions],
                 'disabled_processes': [p for p in ps if c in p.blockers],
                 'enabling_processes': [p for p in ps if c in p.enables],
@@ -240,7 +240,7 @@ class TaskHandler(BaseHTTPRequestHandler):
         if title_64:
             title = b64decode(title_64.encode()).decode()
             process.title.set(title)
-        return {'process': process,
+        return {'process': process, 'is_new': process.id_ is None,
                 'steps': process.get_steps(self.conn),
                 'owners': process.used_as_step_by(self.conn),
                 'n_todos': len(Todo.by_process_id(self.conn, process.id_)),
diff --git a/templates/condition.html b/templates/condition.html
index 6b28a52..b20b5fe 100644
--- a/templates/condition.html
+++ b/templates/condition.html
@@ -4,7 +4,7 @@
 
 
 {% block content %}
-<h3>condition</h3>
+<h3>{% if is_new %}NEW {% endif %}condition</h3>
 <form action="condition?id={{condition.id_ or ''}}" method="POST">
 <table>
 
diff --git a/templates/process.html b/templates/process.html
index bc8d6e6..f073a57 100644
--- a/templates/process.html
+++ b/templates/process.html
@@ -40,7 +40,7 @@ add sub-step: <input name="new_step_to_{{step_id}}" list="step_candidates" autoc
 
 
 {% block content %}
-<h3>process</h3>
+<h3>{% if is_new %}NEW {% endif %}process</h3>
 <form action="process?id={{process.id_ or ''}}" method="POST">
 <table>