def register(self, source):
        """
        Inserts a report template into the arches db

        """
        import json

        details = {}

        with open(source) as f:
            details = json.load(f)

        try:
            uuid.UUID(details['templateid'])
        except:
            details['templateid'] = str(uuid.uuid4())
            print("Registering report template with templateid: {}".format(
                details['templateid']))

        instance = models.ReportTemplate(
            templateid=details['templateid'],
            name=details['name'],
            description=details['description'],
            component=details['component'],
            componentname=details['componentname'],
            defaultconfig=details['defaultconfig'])

        instance.save()
Exemple #2
0
    def register(self, source):
        """
        Inserts a report template into the arches db

        """
        import json

        details = {}

        with open(source) as f:
            details = json.load(f)

        try:
            uuid.UUID(details["templateid"])
        except:
            details["templateid"] = str(uuid.uuid4())
            print("Registering report template with templateid: {}".format(
                details["templateid"]))

        instance = models.ReportTemplate(
            templateid=details["templateid"],
            name=details["name"],
            description=details["description"],
            component=details["component"],
            componentname=details["componentname"],
            defaultconfig=details["defaultconfig"],
            preload_resource_data=details.get("preload_resource_data", True),
        )

        instance.save()