Exemple #1
0
 def __init__(self,
              content_id: str,
              content: List[Content],
              options: Optional[Options] = None):
     super().__init__(content_type="custom_container",
                      content_id=content_id)
     self.content = serialized(content)
     self.options = dictionary_of_object_if_exist(options)
Exemple #2
0
 def __init__(self,
              content_id,
              title: str,
              options: Options = None,
              form_action: FormAction = None):
     super().__init__(content_type="text", content_id=content_id)
     self.title = title
     self.form_action = dictionary_of_object_if_exist(form_action)
     if options is not None:
         self.options = options.__dict__
Exemple #3
0
 def __init__(self,
              content_id: str,
              title: Optional[str] = None,
              items: List[Item] = None,
              validations_rules: Optional[List[ValidationRule]] = None,
              options: Optional[Options] = None,
              default_value: Optional[Item] = None):
     super().__init__(content_type="radiogroup", content_id=content_id)
     self.title = title
     self.items = serialized(items)
     self.validations_rules = serialized(validations_rules)
     self.options = dictionary_of_object_if_exist(options)
     self.default_value = serialized(default_value)
Exemple #4
0
    def make_dictionary(self) -> Dict[String, Any]:
        dictionary = {
            "id": self.id,
            "content": make_dictionaries_from(self.content)
        }
        header_dictionary = dictionary_of_object_if_exist(self.header)
        if header_dictionary:
            dictionary["header"] = header_dictionary
        else:
            logger = logging.getLogger('Form(make_dictionary)')
            logger.error(
                'Can not get Dictionary of Header! Header is required attribute'
            )
            return None

        if self.options:
            dictionary["options"] = dictionary_of_object_if_exist(self.options)

        if self.bottom_bar:
            dictionary["bottom_bar"] = dictionary_of_object_if_exist(
                self.bottom_bar)
        return {"form": dictionary}
Exemple #5
0
 def __init__(self,
              content_id: str,
              title: Optional[str] = None,
              text: Optional[str] = None,
              placeholder: Optional[str] = None,
              validations_rules: Optional[List[ValidationRule]] = None,
              options: Optional[Options] = None):
     super().__init__(content_type="text_area", content_id=content_id)
     self.title = title
     self.text = text
     self.validations_rules = serialized(validations_rules)
     self.placeholder = placeholder
     self.options = dictionary_of_object_if_exist(options)
Exemple #6
0
def serialized(objects: Optional[Objects]) -> Optional[Dictionaries]:
    if not isinstance(objects, Array) or objects is None:
        return None
    objects = list(map(lambda object: dictionary_of_object_if_exist(object), objects))
    objects = list(filter(None, objects))
    return objects
Exemple #7
0
def add_purified_object_dictionary_if_possible_to(dictionaries: Dictionaries,
                                                  obj: Object) -> Void:
    object_dictionary = dictionary_of_object_if_exist(obj)
    if object_dictionary is not None:
        dictionaries.append(dictionary_purified_from_none(object_dictionary))
Exemple #8
0
 def __init__(self, content_id: str, title: str, form_action: FormAction):
     super().__init__("bottom_bar", content_id)
     self.title = title
     self.form_action = dictionary_of_object_if_exist(form_action)