2025-11-29 22:21:06 +01:00
|
|
|
"""
|
|
|
|
|
Silique (https://www.silique.fr)
|
2026-01-04 19:16:18 +01:00
|
|
|
Copyright (C) 2025-2026
|
2025-11-29 22:21:06 +01:00
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify it
|
|
|
|
|
under the terms of the GNU Lesser General Public License as published by the
|
|
|
|
|
Free Software Foundation, either version 3 of the License, or (at your
|
|
|
|
|
option) any later version.
|
|
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
|
|
|
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
|
|
|
|
|
details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Lesser General Public License
|
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
from ..i18n import _
|
|
|
|
|
from .two_columns import Tabular as TwoTabular
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Tabular(TwoTabular):
|
|
|
|
|
"""The three columns tabular"""
|
|
|
|
|
|
|
|
|
|
name = "three_columns"
|
|
|
|
|
level = 30
|
|
|
|
|
|
|
|
|
|
def clear(self):
|
|
|
|
|
super().clear()
|
|
|
|
|
self.third_column = False
|
|
|
|
|
|
|
|
|
|
def _add(self) -> tuple:
|
|
|
|
|
first_column = self.add_first_column()
|
2026-03-29 11:01:15 +02:00
|
|
|
second_column = self.get_column(
|
|
|
|
|
self.description,
|
|
|
|
|
self.help_,
|
|
|
|
|
self.validators,
|
|
|
|
|
self.choices,
|
|
|
|
|
self.examples,
|
|
|
|
|
self.tags,
|
|
|
|
|
*self.calculated_properties,
|
|
|
|
|
)
|
2025-11-29 22:21:06 +01:00
|
|
|
if second_column:
|
|
|
|
|
self.second_column = True
|
|
|
|
|
third_column = self.get_column(self.default)
|
|
|
|
|
if third_column:
|
|
|
|
|
self.third_column = True
|
|
|
|
|
return first_column, second_column, third_column
|
|
|
|
|
|
|
|
|
|
def headers(self) -> tuple:
|
|
|
|
|
headers = super().headers()
|
|
|
|
|
if self.third_column:
|
|
|
|
|
headers.append(_("Default value"))
|
|
|
|
|
return headers
|
|
|
|
|
|
|
|
|
|
def get_columns(self):
|
|
|
|
|
for column in self.columns:
|
|
|
|
|
ret = [column[0]]
|
|
|
|
|
if self.second_column:
|
|
|
|
|
ret.append(column[1])
|
|
|
|
|
if self.third_column:
|
|
|
|
|
ret.append(column[2])
|
|
|
|
|
yield ret
|
|
|
|
|
|
|
|
|
|
def set_default(self):
|
|
|
|
|
if "default" in self.informations:
|
|
|
|
|
self.default = self.formatter.convert_section_to_string(
|
2026-03-29 11:01:15 +02:00
|
|
|
"default",
|
|
|
|
|
self.informations,
|
|
|
|
|
self.modified_attributes,
|
|
|
|
|
multi=self.multi,
|
|
|
|
|
section_name=False,
|
|
|
|
|
)
|
2025-11-29 22:21:06 +01:00
|
|
|
else:
|
|
|
|
|
self.default = None
|
|
|
|
|
|
|
|
|
|
def set_choices(self):
|
2026-03-29 11:01:15 +02:00
|
|
|
self.default_is_already_set, self.choices = (
|
|
|
|
|
self.formatter.convert_choices_to_string(
|
|
|
|
|
self.informations, self.modified_attributes, with_default=False
|
|
|
|
|
)
|
2025-11-29 22:21:06 +01:00
|
|
|
)
|