How to use rdmo - 10 common examples

To help you get started, we’ve selected a few rdmo examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github rdmorganiser / rdmo / rdmo / conditions / tests.py View on Github external
class ConditionTests(TestModelViewsetMixin, ConditionsTestCase):

    instances = Condition.objects.all()
    url_names = {
        'viewset': 'internal-conditions:condition'
    }

    def prepare_create_instance(self, instance):
        instance.key += '_new'
        return instance


class AttributeTests(TestListViewsetMixin, ConditionsTestCase):

    instances = Attribute.objects.all()
    url_names = {
        'viewset': 'internal-conditions:attribute'
    }


class RelationTests(TestListViewsetMixin, ConditionsTestCase):

    url_names = {
        'viewset': 'internal-conditions:relation'
    }
    status_map = {
        'list_viewset': {'editor': 200, 'reviewer': 200, 'api': 200, 'user': 200, 'anonymous': 403}
    }


class ConditionExportTests(TestExportViewMixin, ConditionsTestCase):
github rdmorganiser / rdmo / rdmo / domain / tests.py View on Github external
class ValueTypeTests(TestListViewsetMixin, DomainTestCase):

    url_names = {
        'viewset': 'internal-domain:valuestype'
    }
    status_map = {
        'list_viewset': {
            'editor': 200, 'reviewer': 200, 'reviewer': 200, 'api': 200, 'user': 200, 'anonymous': 403
        }
    }


class OptionSetTests(TestListViewsetMixin, TestRetrieveViewsetMixin, DomainTestCase):

    instances = OptionSet.objects.all()
    url_names = {
        'viewset': 'internal-domain:optionset'
    }


class ConditionTests(TestListViewsetMixin, TestRetrieveViewsetMixin, DomainTestCase):

    instances = Condition.objects.all()
    url_names = {
        'viewset': 'internal-domain:condition'
    }


class DomainExportTests(TestExportViewMixin, DomainTestCase):

    url_names = {
github rdmorganiser / rdmo / rdmo / questions / tests.py View on Github external
class CatalogTests(TestModelViewsetMixin, QuestionsTestCase):

    instances = Catalog.objects.all()
    url_names = {
        'viewset': 'internal-questions:catalog'
    }

    def prepare_create_instance(self, instance):
        instance.key += '_new'
        return instance


class SectionTests(TestModelViewsetMixin, QuestionsTestCase):

    instances = Section.objects.all()
    url_names = {
        'viewset': 'internal-questions:section'
    }

    def prepare_create_instance(self, instance):
        instance.key += '_new'
        return instance


class SubsectionTests(TestModelViewsetMixin, QuestionsTestCase):

    instances = Subsection.objects.all()
    url_names = {
        'viewset': 'internal-questions:subsection'
    }
github rdmorganiser / rdmo / rdmo / domain / tests.py View on Github external
'editor': 200, 'reviewer': 200, 'reviewer': 200, 'api': 200, 'user': 200, 'anonymous': 403
        }
    }


class OptionSetTests(TestListViewsetMixin, TestRetrieveViewsetMixin, DomainTestCase):

    instances = OptionSet.objects.all()
    url_names = {
        'viewset': 'internal-domain:optionset'
    }


class ConditionTests(TestListViewsetMixin, TestRetrieveViewsetMixin, DomainTestCase):

    instances = Condition.objects.all()
    url_names = {
        'viewset': 'internal-domain:condition'
    }


class DomainExportTests(TestExportViewMixin, DomainTestCase):

    url_names = {
        'list_view': 'domain',
        'export_view': 'domain_export'
    }
    export_formats = ('xml', 'html', 'rtf', 'csv')


class DomainImportTests(TestImportViewMixin, TestCase):
github rdmorganiser / rdmo / rdmo / tasks / imports.py View on Github external
task_uri = get_uri(task_node, nsmap)

        try:
            task = Task.objects.get(uri=task_uri)
        except Task.DoesNotExist:
            task = Task()
            log.info('Task not in db. Created with uri ' + task_uri)
        else:
            log.info('Task does exist. Loaded from uri ' + task_uri)

        task.uri_prefix = task_uri.split('/tasks/')[0]
        task.key = task_uri.split('/')[-1]

        try:
            attribute_uri = get_uri(task_node, nsmap, 'attrib')
            task.attribute = Attribute.objects.get(uri=attribute_uri)
        except (AttributeError, Attribute.DoesNotExist, KeyError):
            task.attribute = None

        for element in task_node.findall('title'):
            setattr(task, 'title_' + element.attrib['lang'], element.text)
        for element in task_node.findall('text'):
            setattr(task, 'text_' + element.attrib['lang'], element.text)

        log.info('Task saving to "' + str(task_uri) + '"')
        task.save()

        # TODO: finalize timeframe
        timeframe = TimeFrame()
        timeframe_node = task_node.find('timeframe')
        timeframe.start_attribute = timeframe_node.find('start_attribute').get(get_ns_tag('dc:uri', nsmap))
        timeframe.end_attribute = timeframe_node.find('end_attribute').get(get_ns_tag('dc:uri', nsmap))
github rdmorganiser / rdmo / rdmo / domain / utils.py View on Github external
def import_attribute(attribute_node, nsmap, parent=None):

    uri = attribute_node[get_ns_tag('dc:uri', nsmap)].text

    try:
        attribute = Attribute.objects.get(uri=uri)
    except Attribute.DoesNotExist:
        attribute = Attribute()

    attribute.parent = parent
    attribute.uri_prefix = uri.split('/domain/')[0]
    attribute.key = uri.split('/')[-1]
    attribute.comment = attribute_node[get_ns_tag('dc:comment', nsmap)]
    attribute.is_collection = attribute_node['is_collection'] == 'True'
    attribute.value_type = attribute_node['value_type']
    attribute.unit = attribute_node['unit']
    attribute.save()

    if hasattr(attribute_node, 'range'):
        import_verbose_name(attribute_node.range, attribute)

    if hasattr(attribute_node, 'verbosename'):
        import_verbose_name(attribute_node.verbosename, attribute)
github rdmorganiser / rdmo / rdmo / domain / utils.py View on Github external
def import_attribute(attribute_node, nsmap, parent=None):

    uri = attribute_node[get_ns_tag('dc:uri', nsmap)].text

    try:
        attribute = Attribute.objects.get(uri=uri)
    except Attribute.DoesNotExist:
        attribute = Attribute()

    attribute.parent = parent
    attribute.uri_prefix = uri.split('/domain/')[0]
    attribute.key = uri.split('/')[-1]
    attribute.comment = attribute_node[get_ns_tag('dc:comment', nsmap)]
    attribute.is_collection = attribute_node['is_collection'] == 'True'
    attribute.value_type = attribute_node['value_type']
    attribute.unit = attribute_node['unit']
    attribute.save()

    if hasattr(attribute_node, 'range'):
        import_verbose_name(attribute_node.range, attribute)

    if hasattr(attribute_node, 'verbosename'):
        import_verbose_name(attribute_node.verbosename, attribute)
github rdmorganiser / rdmo / rdmo / conditions / utils.py View on Github external
def import_conditions(conditions_node):

    nsmap = conditions_node.nsmap

    for condition_node in conditions_node.iterchildren():
        condition_uri = condition_node[get_ns_tag('dc:uri', nsmap)].text

        try:
            condition = Condition.objects.get(uri=condition_uri)
        except Condition.DoesNotExist:
            condition = Condition()

        condition.uri_prefix = condition_uri.split('/conditions/')[0]
        condition.key = condition_uri.split('/')[-1]
        condition.comment = condition_node[get_ns_tag('dc:comment', nsmap)]
        condition.relation = condition_node['relation']

        try:
            source_uri = condition_node['source'].get(get_ns_tag('dc:uri', nsmap))
            condition.source = Attribute.objects.get(uri=source_uri)
        except (AttributeError, Attribute.DoesNotExist):
            condition.source = None

        try:
            condition.target_text = condition_node['target_text']
github rdmorganiser / rdmo / rdmo / domain / utils.py View on Github external
def import_attribute(attribute_node, nsmap, parent=None):

    uri = attribute_node[get_ns_tag('dc:uri', nsmap)].text

    try:
        attribute = Attribute.objects.get(uri=uri)
    except Attribute.DoesNotExist:
        attribute = Attribute()

    attribute.parent = parent
    attribute.uri_prefix = uri.split('/domain/')[0]
    attribute.key = uri.split('/')[-1]
    attribute.comment = attribute_node[get_ns_tag('dc:comment', nsmap)]
    attribute.is_collection = attribute_node['is_collection'] == 'True'
    attribute.value_type = attribute_node['value_type']
    attribute.unit = attribute_node['unit']
    attribute.save()

    if hasattr(attribute_node, 'range'):
        import_verbose_name(attribute_node.range, attribute)

    if hasattr(attribute_node, 'verbosename'):
github rdmorganiser / rdmo / rdmo / tasks / imports.py View on Github external
def import_tasks(tasks_node):
    log.info('Importing conditions')
    nsmap = get_ns_map(tasks_node.getroot())

    for task_node in tasks_node.findall('task'):
        task_uri = get_uri(task_node, nsmap)

        try:
            task = Task.objects.get(uri=task_uri)
        except Task.DoesNotExist:
            task = Task()
            log.info('Task not in db. Created with uri ' + task_uri)
        else:
            log.info('Task does exist. Loaded from uri ' + task_uri)

        task.uri_prefix = task_uri.split('/tasks/')[0]
        task.key = task_uri.split('/')[-1]

        try:
            attribute_uri = get_uri(task_node, nsmap, 'attrib')
            task.attribute = Attribute.objects.get(uri=attribute_uri)
        except (AttributeError, Attribute.DoesNotExist, KeyError):
            task.attribute = None

        for element in task_node.findall('title'):
            setattr(task, 'title_' + element.attrib['lang'], element.text)