Minor UI Tweak

This commit is contained in:
2025-11-10 15:47:30 -05:00
parent d9cbce6175
commit 3c2e825210
3 changed files with 24 additions and 19 deletions
+17 -14
View File
@@ -13,33 +13,36 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
import json
"""
Policy model representing policy data and relationships.
"""
class Policy:
def __init__(self, groupid, hidden, name, parent):
self.groupid = groupid
self.hidden = hidden
self.name = name
self.parent = parent
# policy.py
def __repr__(self):
# Show all current attributes, including dynamically added ones
from dataclasses import asdict, dataclass, field
import json
from typing import Optional
@dataclass(order=True)
class Policy:
name: str
groupid: int = field(compare=False)
hidden: bool = field(compare=False)
parent: Optional[str] = field(default=None, compare=False)
def __repr__(self) -> str:
attrs = ", ".join(
f"{key}={repr(value)}" for key, value in self.__dict__.items()
)
return f"<Execution({attrs})>"
def to_dict(self):
# Return all attributes as a dictionary
return self.__dict__
def to_dict(self) -> dict:
return asdict(self)
def to_json(self):
# Convert to JSON string, handling non-serializable types gracefully
def to_json(self) -> str:
return json.dumps(self.to_dict(), default=str)