swissvotes.models.policy_area ============================= .. py:module:: swissvotes.models.policy_area Classes ------- .. autoapisummary:: swissvotes.models.policy_area.PolicyArea swissvotes.models.policy_area.PolicyAreaDefinition Module Contents --------------- .. py:class:: PolicyArea(value: str | list[int]) PolicyArea(value: decimal.Decimal, level: int) Helper class for handling of descriptors. There are three levels of descriptors, each new level refining the given category. Policy areas are internally represented as a string value containing the descriptor of all three levels separated by a comma, e.g. "1.12.121". Policy areas are stored in the dataset as float, with the pre-decimal part refering to the first level category and the decimal part to the category of the given level. For example: Level 1 descriptor "1": 1 Level 2 descriptor "1.12": 1.12 Level 3 descriptor "1.12.121": 1.121 .. py:method:: __repr__() -> str .. py:method:: __eq__(other: object) -> bool .. py:property:: level :type: int .. py:property:: descriptor :type: int Returns the highest descriptor, e.g. 121 if "1.12.121". .. py:property:: descriptor_path :type: list[int] Returns all descriptors, e.g [1, 12, 121] if "1.12.121". .. py:property:: descriptor_decimal :type: decimal.Decimal Returns the descriptor as float for the dataset, e.g 1.121 if "1.12.121". .. py:property:: label :type: str Returns a translatable label of the highest descriptor, e.g. "Bundesverfassung" if "1.12.121". .. py:property:: label_path :type: list[str] Returns translatable labels for all descriptor levels, e.g. ["Staatsordnung", "Politisches System", "Bundesverfassung"] if "1.12.121". .. py:method:: html(request: onegov.swissvotes.request.SwissvotesRequest) -> markupsafe.Markup .. py:class:: PolicyAreaDefinition(path: list[int] | None = None, label: str | None = None, children: list[PolicyAreaDefinition] | None = None) Helper class for all the policy areas and their translatable labels. Example: Get the label of the policy area "1.12.121": PolicyAreaDefinition.all().get(1).get(12).get(121).label .. py:attribute:: path :value: [] .. py:attribute:: decimal :value: None .. py:attribute:: value :value: None .. py:attribute:: label :value: None .. py:attribute:: children :value: [] .. py:attribute:: index .. py:method:: get(key: int) -> PolicyAreaDefinition | None Returns the child with the given value. .. py:method:: all() -> PolicyAreaDefinition :staticmethod: Returns the tree of all policy areas.