def _get_popup_content(self): """ Return module's data rendering """ selected_elements = [self.data] template = AbstractModule.render_template( 'core_module_periodic_table_app/periodic.html', {'selected_elements': selected_elements}) return AbstractModule.render_template( 'core_module_periodic_table_app/periodic_simple.html', {'periodic_table': template})
def get_chemical_composition_popup_content(data, edit_template): """ Chemical_composition module's rendering """ # rendering data in the periodic table template = AbstractModule.render_template('core_module_periodic_table_app/periodic.html', {'selected_elements': get_periodic_table_selected_elements(data)}) # rendering both form in the popup template return AbstractModule.render_template('core_module_chemical_composition_app/chemical_composition.html', {'periodic_table': template, 'data_template': edit_template})
def _get_popup_content(self): """Return module's data rendering""" selected_elements = [self.data] template = AbstractModule.render_template( "core_module_periodic_table_app/periodic.html", {"selected_elements": selected_elements}, ) return AbstractModule.render_template( "core_module_periodic_table_app/periodic_simple.html", {"periodic_table": template}, )
def get_chemical_composition_popup_content(data, edit_template): """Chemical_composition module's rendering""" # rendering data in the periodic table template = AbstractModule.render_template( "core_module_periodic_table_app/periodic.html", {"selected_elements": get_periodic_table_selected_elements(data)}, ) # rendering both form in the popup template return AbstractModule.render_template( "core_module_chemical_composition_app/chemical_composition.html", { "periodic_table": template, "data_template": edit_template, }, )
def render_blob_host_data(data, error): """Render blob host data Args: data: error: Returns: """ context = {} if error is not None: context["error"] = error else: """We have to unescape the string before the graphical render""" context["handle"] = XmlEntities.unescape_xml_entities(data)[0] """Even if we have unescaped the graphical version of the data we have to display the warning message if there are xml predefined entities""" data_xml_entities = XmlEntities() data_xml_entities.escape_xml_entities(data) if (data_xml_entities.number_of_subs_made > 0 or len( re.findall(r"((&)|(>)|(<)|(')|("))", data)) > 0): context["xml_entities_warning"] = True return AbstractModule.render_template( "core_module_blob_host_app/blob_host_display.html", context)
def _render_module(self, request): """Return module's rendering Args: request: Returns: """ options_html = "" if self.selected not in list(self.options.keys()): self.selected = None for key, val in list(self.options.items()): if self.selected is not None and key == self.selected: options_html += ("<option value='" + key + "' selected>" + val + "</option>") else: options_html += "<option value='" + key + "'>" + val + "</option>" params = {"options": options_html} if self.label is not None: params.update({"label": self.label}) if self.disabled is not None: params.update({"disabled": self.disabled}) return AbstractModule.render_template( "core_parser_app/builtin/options.html", params)
def _render_module(self, request): """Return module's rendering Args: request: Returns: """ params = {} if self.label is not None: params.update({"label": self.label}) if self.default_value is not None: params.update({"default_value": self.default_value}) if self.disabled is not None: params.update({"disabled": self.disabled}) if self.placeholder is not None: params.update({"placeholder": self.placeholder}) return AbstractModule.render_template( "core_parser_app/builtin/input.html", params)
def _get_popup_content(self): """ Return popup content Returns: """ return AbstractModule.render_template('core_module_excel_uploader_app/excel_uploader.html', {'form': ExcelUploaderForm()})
def _get_popup_content(self): """ Return popup content Returns: """ return AbstractModule.render_template( 'core_module_blob_host_app/blob_host.html', {'form': BLOBHostForm()})
def _render_module(self, request): """ Return module's rendering Args: request: Returns: """ params = {"label": self.label, 'data': self.data} return AbstractModule.render_template( 'core_parser_app/builtin/textarea.html', params)
def _render_module(self, request): """ Return the module rendering Args: request: Returns: """ params = {"button_label": self.button_label} if self.label is not None: params.update({"label": self.label}) if self.default_value is not None: params.update({"default_value": self.default_value}) return AbstractModule.render_template( 'core_parser_app/builtin/input_button.html', params)
def _render_module(self, request): """ Return module's rendering Args: request: Returns: """ params = { "popup_content": self._get_popup_content(), "button_label": self.button_label, } return AbstractModule.render_template( 'core_parser_app/builtin/popup.html', params)
def _render_module(self, request): """ Return module's rendering Args: request: Returns: """ params = {'class': self.modclass} if self.label is not None: params.update({"label": self.label}) if self.default_value is not None: params.update({"default_value": self.default_value}) if self.disabled is not None: params.update({"disabled": self.disabled}) return AbstractModule.render_template('core_parser_app/builtin/sync_input.html', params)
def render_blob_host_data(data, error): """ Render blob host data Args: data: error: Returns: """ context = {} if error is not None: context['error'] = error else: context['handle'] = data return AbstractModule.render_template( 'core_module_blob_host_app/blob_host_display.html', context)
def _render_module(self, request): """Return the module Args: request: Returns: """ # Compute number of items in each columns col_nb = 3 opt_nb = len(self.options) max_item_nb = int(ceil(old_div(opt_nb, col_nb))) # Parameters initialization params = { "column1": "", "column2": "", "column3": "", } item_nb = 0 col_id = 1 checkboxes_html = "" # Filling the parameters for key, val in list(self.options.items()): if item_nb == max_item_nb: params["column" + str(col_id)] = checkboxes_html checkboxes_html = "" item_nb = 0 col_id += 1 checkboxes_html += CheckboxesModule._create_html_checkbox( key, val, checked=(key in self.selected)) item_nb += 1 params["column" + str(col_id)] = checkboxes_html if self.label is not None: params.update({"label": self.label}) return AbstractModule.render_template( "core_parser_app/builtin/checkboxes.html", params)
def _get_popup_content(self): """Return popup content Returns: """ module_id = None if self.request: module_id = self.request.GET.get("module_id", None) # create the from and set an unique id form = ExcelUploaderForm() form.fields["file"].widget.attrs.update( {"id": "file-input-%s" % str(module_id)}) return AbstractModule.render_template( "core_module_excel_uploader_app/excel_uploader.html", {"form": ExcelUploaderForm()}, )
def _render_module(self, request): """Return the module Args: request: Returns: """ params = {} if self.data != "": params["value"] = self.data if self.label is not None: params.update({"label": self.label}) return AbstractModule.render_template( "core_parser_app/builtin/autocomplete.html", params)
def _render_module(self, request): """Return module's rendering Args: request: Returns: """ module_id = None if self.request: module_id = self.request.GET.get("module_id", None) params = { "popup_content": self._get_popup_content(), "module_id": module_id, "button_label": self.button_label, } return AbstractModule.render_template( "core_parser_app/builtin/popup.html", params)
def _get_popup_content(self): """Return popup content Returns: """ module_id = None if self.request: module_id = self.request.GET.get("module_id", None) # create the from and set an unique id form = BLOBHostForm() form.fields["file"].widget.attrs.update( {"id": "file-input-%s" % str(module_id)}) return AbstractModule.render_template( "core_module_blob_host_app/blob_host.html", { "form": form, "module_id": module_id, }, )
def _render_module(self, request): # get the xml path of the element on which the module is placed xml_xpath = request.GET.get('xml_xpath', None) # xml path is provided if xml_xpath is not None: try: # create unique field id from xpath field_id = re.sub('[/.:\[\]]', '', xml_xpath) # split the xpath split_xml_xpath = xml_xpath.split('/') # get the last element of the xpath xml_element = split_xml_xpath[-1] # check if namespace is present if ":" in xml_element: # split element name split_xml_element = xml_element.split(":") # only keep element name if namespace is present xml_element = split_xml_element[-1] # get registry template template = template_registry_api.get_current_registry_template( ) # get all refinements for this template refinements = refinement_api.get_all_filtered_by_template_hash( template.hash) # get the refinement for the xml element refinement = refinements.get(xsd_name=xml_element) # initialize reload data for the form reload_form_data = {} # data to reload were provided if self.data != '': # build filed for the refinement form for the current xml element refinement_form_field = "{0}-{1}".format( RefinementForm.prefix, field_id) # get the categories for the current refinement categories = category_api.get_all_filtered_by_refinement_id( refinement.id) # Initialize list of categories id reload_categories_id_list = [] # load list of data to reload from XML reload_data = XSDTree.fromstring("<root>" + self.data + "</root>") # Iterate xml elements for reload_data_element in list(reload_data): try: if len(reload_data_element) > 0: # The xml element to be reloaded is the child element child = reload_data_element[0] # get its value selected_value = child.text # find the corresponding category and add its id to the list reload_categories_id_list.append( categories.get(value=selected_value).id) except Exception, e: raise ModuleError( "Something went wrong when reloading data from XML." + e.message) # set data to reload in the form reload_form_data[ refinement_form_field] = reload_categories_id_list return AbstractModule.render_template( 'core_module_fancy_tree_registry_app/fancy_tree.html', { 'form': RefinementForm(refinement=refinement, field_id=field_id, data=reload_form_data) }) except Exception, e: raise ModuleError( "Something went wrong when rendering the module: " + e.message)
def _render_module(self, request): # get the xml path of the element on which the module is placed xml_xpath = request.GET.get("xml_xpath", None) # xml path is provided if xml_xpath is not None: try: # create unique field id from xpath field_id = re.sub("[/.:\[\]]", "", xml_xpath) # split the xpath split_xml_xpath = xml_xpath.split("/") # get the last element of the xpath xml_element = split_xml_xpath[-1] # check if namespace is present if ":" in xml_element: # split element name split_xml_element = xml_element.split(":") # only keep element name if namespace is present xml_element = split_xml_element[-1] # get registry template template = template_registry_api.get_current_registry_template( request=request) # get all refinements for this template refinements = refinement_api.get_all_filtered_by_template_hash( template.hash) # get the refinement for the xml element refinement = refinements.get(xsd_name=xml_element) # initialize reload data for the form reload_form_data = {} # data to reload were provided if self.data != "": # build filed for the refinement form for the current xml element refinement_form_field = "{0}-{1}".format( RefinementForm.prefix, field_id) # get the categories for the current refinement categories = category_api.get_all_filtered_by_refinement_id( refinement.id) # Initialize list of categories id reload_categories_id_list = [] # load list of data to reload from XML reload_data = XSDTree.fromstring("<root>" + self.data + "</root>") # Iterate xml elements for reload_data_element in list(reload_data): try: if len(reload_data_element) > 0: # The xml element to be reloaded is the child element child = reload_data_element[0] # get its value selected_value = child.text # find the corresponding category and add its id to the list category = categories.get(value=selected_value) # if the element is an unspecified element if category.slug.startswith(UNSPECIFIED_LABEL): # get the parent category selected_value += CATEGORY_SUFFIX category = categories.get( value=selected_value) reload_categories_id_list.append(category.id) except Exception as e: raise ModuleError( "Something went wrong when reloading data from XML." + str(e)) # set data to reload in the form reload_form_data[ refinement_form_field] = reload_categories_id_list return AbstractModule.render_template( "core_module_fancy_tree_registry_app/fancy_tree.html", { "form": RefinementForm( refinement=refinement, field_id=field_id, data=reload_form_data, ) }, ) except Exception as e: raise ModuleError( "Something went wrong when rendering the module: " + str(e)) else: raise ModuleError( "xml_xpath was not found in request GET parameters.")