コード例 #1
0
 def export_columns(cls, instances=[]):
     # TODO: flip this to instead pass arguments to a factory on table.ColumnChoice
     # only do ID and Name here, allow overrides to include e.g. metadata
     return [
         table.ColumnChoice(
             cls, 'id', _('ID'), lambda x: x.id, heading=cls.__name__ + ' ID'),
         table.ColumnChoice(
             cls, 'name', _('Name'), lambda x: x.name, heading=cls.__name__ + ' Name'),
     ]
コード例 #2
0
 def export_columns(cls):
     return [
         table.ColumnChoice(
             cls, 'type', _('Measurement Type'), lambda x: x.measurement_type.export_name()),
         table.ColumnChoice(
             cls, 'comp', _('Compartment'), lambda x: x.compartment_symbol),
         table.ColumnChoice(
             cls, 'mod', _('Measurement Updated'), lambda x: x.update_ref.mod_time),
         table.ColumnChoice(
             cls, 'x_units', _('X Units'),
             lambda x: x.x_units.unit_name if x.x_units.display else ''),
         table.ColumnChoice(
             cls, 'y_units', _('Y Units'),
             lambda x: x.y_units.unit_name if x.y_units.display else ''),
     ]
コード例 #3
0
    def get_column(self, **kwargs):
        type_context = None

        def lookup_format(instance, **kwargs):
            return self.get_default() % self.get_format_dict(instance, **kwargs)

        def lookup_meta(instance, **kwargs):
            default = self.get_default() % kwargs
            if instance:
                return instance.metadata_get(self.meta_type, default=default)
            return default

        if self.meta_type:
            type_context = self.meta_type.for_context
            lookup = lookup_meta
        else:
            type_context = None
            lookup = lookup_format
        model = {
            MetadataType.STUDY: Study,
            MetadataType.LINE: Line,
            MetadataType.ASSAY: Assay,
        }.get(type_context, None)
        return table.ColumnChoice(
            model, "worklist_column_%s" % self.pk, str(self), lookup
        )
コード例 #4
0
 def export_columns(cls, instances=[]):
     return super(Study, cls).export_columns(instances) + [
         table.ColumnChoice(cls,
                            'contact',
                            _('Contact'),
                            lambda x: x.get_contact(),
                            heading='Study Contact'),
     ]
コード例 #5
0
 def export_columns(cls, instances=[]):
     types = MetadataType.all_types_on_instances(instances)
     return super(Line, cls).export_columns(instances) + [
         table.ColumnChoice(
             cls, 'control', _('Control'), lambda x: 'T' if x.control else 'F'),
         table.ColumnChoice(
             # TODO export should handle multi-valued fields better than this
             cls, 'strain', _('Strain'),
             lambda x: '|'.join([s.name for s in x.strains.all()])),
         table.ColumnChoice(
             # TODO export should handle multi-valued fields better than this
             cls, 'csource_name', _('Carbon Source'),
             lambda x: '|'.join([c.name for c in x.carbon_source.all()])),
         table.ColumnChoice(
             # TODO export should handle multi-valued fields better than this
             cls, 'csource_label', _('Carbon Labeling'),
             lambda x: '|'.join([c.labeling for c in x.carbon_source.all()])),
         table.ColumnChoice(
             cls, 'experimenter', _('Experimenter'),
             lambda x: x.experimenter.email if x.experimenter else '',
             heading=_('Line Experimenter')),
         table.ColumnChoice(
             cls, 'contact', _('Contact'),
             lambda x: x.contact.email if x.contact else '',
             heading=_('Line Contact')),
     ] + [
         table.ColumnChoice(
             cls, 'meta.%s' % t.id, t.type_name,
             lambda x: x.meta_store.get('%s' % t.id, ''))
         for t in types
     ]