Пример #1
0
    def GET(self, request, response):
        self.check_viewable(self.user)
        page = HtmlPage(self, title='Accounts')
        page.header = DIV(H1(page.title),
                          utils.rst_to_html(Account.__doc__))

        if self.get_editable(self.user):
            page.append(P(FORM(INPUT(type='submit', value='Create new account'),
                               method='GET',
                               action=configuration.get_url('account'))))

        rows = [TR(TH('Account'),
                   TH('Full name'),
                   TH('Role'),
                   TH('Initials'))]
        for result in self.db.view('account/name', include_docs=True):
            doc = result.doc
            ref = A(result.key,
                    href=configuration.get_url('account', result.key))
            rows.append(TR(TD(ref),
                           TD(result.value or ''),
                           TD(doc.get('role')),
                           TD(doc.get('initials') or '')))
        page.append(TABLE(border=1, *rows))

        page.write(response)
Пример #2
0
    def GET(self, request, response):
        self.check_viewable(self.user)
        page = HtmlPage(self, title='Instruments')
        page.header = DIV(H1(page.title),
                          utils.rst_to_html(Instrument.__doc__))

        if self.get_editable(self.user):
            page.append(P(FORM(INPUT(type='submit',
                                     value='Create new instrument'),
                               method='GET',
                               action=configuration.get_url('instrument'))))

        rows = [TR(TH('Instrument'),
                   TH('Label'),
                   TH('Type'),
                   TH('Timestamp'))]
        view = self.db.view('instrument/name', include_docs=True)
        for result in view:
            doc = result.doc
            instrument = A(doc['name'],
                           href=configuration.get_url('instrument',doc['name']))
            rows.append(TR(TD(instrument),
                           TD(doc['label'] or ''),
                           TD(doc['type']),
                           TD(doc['timestamp'])))
        page.append(TABLE(border=1, *rows))

        page.write(response)
Пример #3
0
    def GET(self, request, response):
        self.check_viewable(self.user)
        page = HtmlPage(self, title='Instruments')
        page.header = DIV(H1(page.title),
                          utils.rst_to_html(Instrument.__doc__))

        if self.get_editable(self.user):
            page.append(
                P(
                    FORM(INPUT(type='submit', value='Create new instrument'),
                         method='GET',
                         action=configuration.get_url('instrument'))))

        rows = [TR(TH('Instrument'), TH('Label'), TH('Type'), TH('Timestamp'))]
        view = self.db.view('instrument/name', include_docs=True)
        for result in view:
            doc = result.doc
            instrument = A(doc['name'],
                           href=configuration.get_url('instrument',
                                                      doc['name']))
            rows.append(
                TR(TD(instrument), TD(doc['label'] or ''), TD(doc['type']),
                   TD(doc['timestamp'])))
        page.append(TABLE(border=1, *rows))

        page.write(response)
Пример #4
0
 def GET(self, request, response):
     # XXX implement check_viewable properly
     self.check_viewable(self.user)
     page = HtmlPage(self, title="Tool %s" % self.tool)
     page.header = DIV(H1(page.title), utils.rst_to_html(self.tool.__doc__))
     page.append(
         FORM(self.tool.get_view(self),
              INPUT(type='hidden',
                    name='entity',
                    value=self.tool.get_entity_tag(self.doc)),
              method='POST',
              action=self.tool.get_url()))
     page.write(response)
Пример #5
0
    def GET(self, request, response):
        self.check_viewable(self.user)
        page = HtmlPage(self, title='Tasks')
        page.header = DIV(H1(page.title),
                          utils.rst_to_html(Task.__doc__))

        if self.get_editable(self.user):
            page.append(P(FORM(INPUT(type='submit',
                                     value='Create new task'),
                               method='GET',
                               action=configuration.get_url('task'))))

        operator = self.get_selected_operator(request)
        page.append(P(self.get_operator_select_form('tasks',operator)))

        if operator:
            view = self.db.view('task/operator', include_docs=True)
            result = view[operator]
        else:
            result = self.db.view('task/name', include_docs=True)
        tasks = [r.doc for r in result]
        tasks.sort(lambda i, j: cmp(i['name'], i['name']))

        rows = [TR(TH('Task'),
                   TH('Runname'),
                   TH('Protocol'),
                   TH('Instrument'),
                   TH('Operator'),
                   TH('Timestamp'))]
        for row in result:
            doc = row.doc
            task = A(doc['name'], href=configuration.get_entity_url(doc))
            url = configuration.get_url('protocol', doc['protocol'])
            protocol = A(doc['protocol'], href=url)
            instrument = doc.get('instrument') or ''
            if instrument:
                url = configuration.get_url('instrument', instrument)
                instrument = A(instrument, href=url)
            operator = doc.get('operator') or ''
            if operator:
                url = configuration.get_url('account', operator)
                operator = A(operator, href=url)
            rows.append(TR(TD(task),
                           TD(doc.get('runname') or ''),
                           TD(protocol),
                           TD(instrument),
                           TD(operator),
                           TD(doc['timestamp'])))
        page.append(TABLE(border=1, *rows))

        page.write(response)
Пример #6
0
    def GET(self, request, response):
        title = 'slog: simple lab tracking'
        page = HtmlPage(self, title=title)
        page.header = DIV(H1('slog: simple lab tracking'),
                          utils.rst_to_html("""Slog is a simple tracking system
for the lab. It consists of a number of types of entities representing things
to which information is attached. The entities have defined relationships
to each other. A log of who did what when to an entity is maintained.
A log entry also contains a snapshot of the information for an entity before
the change."""))
        page.append(H2('Types of entities in the system'))
        rows = []
        for klass in [Account,
                      Project,
                      Sample,
                      Workset,
                      Protocol,
                      Task,
                      Instrument]:
            rows.append(TR(TH(klass.__name__),
                           TD(utils.rst_to_html(klass.__doc__))))
        page.append(TABLE(*rows))
        page.write(response)
Пример #7
0
 def GET(self, request, response):
     # XXX implement check_viewable properly
     self.check_viewable(self.user)
     page = HtmlPage(self, title="Tool %s" % self.tool)
     page.header = DIV(H1(page.title), utils.rst_to_html(self.tool.__doc__))
     page.append(
         FORM(
             self.tool.get_view(self),
             INPUT(type="hidden", name="entity", value=self.tool.get_entity_tag(self.doc)),
             method="POST",
             action=self.tool.get_url(),
         )
     )
     page.write(response)
Пример #8
0
    def GET(self, request, response):
        self.check_viewable(self.user)
        page = HtmlPage(self, title='Worksets')
        page.header = DIV(H1(page.title),
                          utils.rst_to_html(Workset.__doc__))

        if self.get_editable(self.user):
            page.append(P(FORM(INPUT(type='submit', value='Create new workset'),
                               method='GET',
                               action=configuration.get_url('workset'))))

        operator = self.get_selected_operator(request)
        page.append(P(self.get_operator_select_form('worksets', operator)))

        if operator:
            view = self.db.view('workset/operator', include_docs=True)[operator]
        else:
            view = self.db.view('workset/name', include_docs=True)
        worksets = [r.doc for r in view]
        worksets.sort(lambda i, j: cmp(i['name'], i['name']))

        rows = [TR(TH('Workset'),
                   TH('Operator'),
                   TH('Samples'),
                   TH('Timestamp'))]
        for workset in worksets:
            operator = workset.get('operator')
            if operator:
                url = configuration.get_url('account', operator)
                operator = A(operator, href=url)
            else:
                operator = ''
            samples = workset.get('samples', [])
            for i, sample in enumerate(samples):
                url = configuration.get_url('sample', sample)
                samples[i] = str(A(sample, href=url))
            samples = ', '.join(samples)

            url = configuration.get_url('workset', workset['name'])
            rows.append(TR(TD(A(workset['name'], href=url)),
                           TD(operator),
                           TD(samples),
                           TD(workset['timestamp'])))
        page.append(TABLE(border=1, *rows))

        page.write(response)
Пример #9
0
    def GET(self, request, response):
        self.check_viewable(self.user)
        page = HtmlPage(self, title='Tasks')
        page.header = DIV(H1(page.title), utils.rst_to_html(Task.__doc__))

        if self.get_editable(self.user):
            page.append(
                P(
                    FORM(INPUT(type='submit', value='Create new task'),
                         method='GET',
                         action=configuration.get_url('task'))))

        operator = self.get_selected_operator(request)
        page.append(P(self.get_operator_select_form('tasks', operator)))

        if operator:
            view = self.db.view('task/operator', include_docs=True)
            result = view[operator]
        else:
            result = self.db.view('task/name', include_docs=True)
        tasks = [r.doc for r in result]
        tasks.sort(lambda i, j: cmp(i['name'], i['name']))

        rows = [
            TR(TH('Task'), TH('Runname'), TH('Protocol'), TH('Instrument'),
               TH('Operator'), TH('Timestamp'))
        ]
        for row in result:
            doc = row.doc
            task = A(doc['name'], href=configuration.get_entity_url(doc))
            url = configuration.get_url('protocol', doc['protocol'])
            protocol = A(doc['protocol'], href=url)
            instrument = doc.get('instrument') or ''
            if instrument:
                url = configuration.get_url('instrument', instrument)
                instrument = A(instrument, href=url)
            operator = doc.get('operator') or ''
            if operator:
                url = configuration.get_url('account', operator)
                operator = A(operator, href=url)
            rows.append(
                TR(TD(task), TD(doc.get('runname') or ''), TD(protocol),
                   TD(instrument), TD(operator), TD(doc['timestamp'])))
        page.append(TABLE(border=1, *rows))

        page.write(response)
Пример #10
0
    def GET(self, request, response):
        self.check_viewable(self.user)
        page = HtmlPage(self, title='Worksets')
        page.header = DIV(H1(page.title), utils.rst_to_html(Workset.__doc__))

        if self.get_editable(self.user):
            page.append(
                P(
                    FORM(INPUT(type='submit', value='Create new workset'),
                         method='GET',
                         action=configuration.get_url('workset'))))

        operator = self.get_selected_operator(request)
        page.append(P(self.get_operator_select_form('worksets', operator)))

        if operator:
            view = self.db.view('workset/operator',
                                include_docs=True)[operator]
        else:
            view = self.db.view('workset/name', include_docs=True)
        worksets = [r.doc for r in view]
        worksets.sort(lambda i, j: cmp(i['name'], i['name']))

        rows = [
            TR(TH('Workset'), TH('Operator'), TH('Samples'), TH('Timestamp'))
        ]
        for workset in worksets:
            operator = workset.get('operator')
            if operator:
                url = configuration.get_url('account', operator)
                operator = A(operator, href=url)
            else:
                operator = ''
            samples = workset.get('samples', [])
            for i, sample in enumerate(samples):
                url = configuration.get_url('sample', sample)
                samples[i] = str(A(sample, href=url))
            samples = ', '.join(samples)

            url = configuration.get_url('workset', workset['name'])
            rows.append(
                TR(TD(A(workset['name'], href=url)), TD(operator), TD(samples),
                   TD(workset['timestamp'])))
        page.append(TABLE(border=1, *rows))

        page.write(response)
Пример #11
0
    def GET(self, request, response):
        self.check_viewable(self.user)
        page = HtmlPage(self, title='Samples')
        page.header = DIV(H1(page.title),
                          utils.rst_to_html(Sample.__doc__))

        if self.user.get('role') in ('admin', 'manager', 'engineer'):
            operator = self.get_selected_operator(request)
            page.append(P(self.get_operator_select_form('samples', operator)))
        else:                           # Customer can only view his own samples
            operator = self.user['name']
        view = self.db.view('project/customer')
        if operator:
            result = list(view[operator])
        else:
            result = list(view)
        projects = [r.value for r in result]

        rows = [TR(TH('Project'),
                   TH('Sample'),
                   TH('Customername'))]
        for project in projects:
            link_project = A(project,
                             href=configuration.get_url('project', project))
            view = self.db.view('sample/project', include_docs=True)
            samples = [r.doc for r in view[project]]
            if samples:
                samples.sort(lambda i, j: cmp(i['name'], j['name']))
                for sample in samples:
                    if link_project:
                        cells = [TD(link_project, rowspan=len(samples))]
                        link_project = None # Skip after first row
                    else:
                        cells = []
                    url = configuration.get_entity_url(sample)
                    cells.append(TD(A(sample['name'], href=url)))
                    cells.append(TD(sample.get('customername') or ''))
                    rows.append(TR(*cells))
            else:
                rows.append(TR(TD(link_project)))
        page.append(TABLE(border=1, *rows))
        page.write(response)
Пример #12
0
    def GET(self, request, response):
        self.check_viewable(self.user)
        page = HtmlPage(self, title='Protocols')
        page.header = DIV(H1(page.title), utils.rst_to_html(Protocol.__doc__))

        if self.get_editable(self.user):
            page.append(
                P(
                    FORM(INPUT(type='submit', value='Create new protocol'),
                         method='GET',
                         action=configuration.get_url('protocol'))))

        view = self.db.view('protocol/name', include_docs=True)
        rows = [TR(TH('Protocol'), TH('Timestamp'))]
        for result in view:
            doc = result.doc
            protocol = A(doc['name'],
                         href=configuration.get_url('protocol', doc['name']))
            rows.append(TR(TD(protocol), TD(doc['timestamp'])))
        page.append(TABLE(border=1, *rows))

        page.write(response)
Пример #13
0
    def GET(self, request, response):
        self.check_viewable(self.user)
        page = HtmlPage(self, title='Samples')
        page.header = DIV(H1(page.title), utils.rst_to_html(Sample.__doc__))

        if self.user.get('role') in ('admin', 'manager', 'engineer'):
            operator = self.get_selected_operator(request)
            page.append(P(self.get_operator_select_form('samples', operator)))
        else:  # Customer can only view his own samples
            operator = self.user['name']
        view = self.db.view('project/customer')
        if operator:
            result = list(view[operator])
        else:
            result = list(view)
        projects = [r.value for r in result]

        rows = [TR(TH('Project'), TH('Sample'), TH('Customername'))]
        for project in projects:
            link_project = A(project,
                             href=configuration.get_url('project', project))
            view = self.db.view('sample/project', include_docs=True)
            samples = [r.doc for r in view[project]]
            if samples:
                samples.sort(lambda i, j: cmp(i['name'], j['name']))
                for sample in samples:
                    if link_project:
                        cells = [TD(link_project, rowspan=len(samples))]
                        link_project = None  # Skip after first row
                    else:
                        cells = []
                    url = configuration.get_entity_url(sample)
                    cells.append(TD(A(sample['name'], href=url)))
                    cells.append(TD(sample.get('customername') or ''))
                    rows.append(TR(*cells))
            else:
                rows.append(TR(TD(link_project)))
        page.append(TABLE(border=1, *rows))
        page.write(response)
Пример #14
0
    def GET(self, request, response):
        self.check_viewable(self.user)
        page = HtmlPage(self, title='Projects')
        page.header = DIV(H1(page.title),
                          utils.rst_to_html(Project.__doc__))

        if self.get_editable(self.user):
            page.append(P(FORM(INPUT(type='submit', value='Create new project'),
                               method='GET',
                               action=configuration.get_url('project'))))

        view = self.db.view('sample/project_count', group=True)
        counts = dict([(r.key, r.value) for r in view])
        rows = [TR(TH('Project'),
                   TH('Label'),
                   TH('Customer'),
                   TH('# Samples'),
                   TH('Timestamp'))]
        view = self.db.view('project/timestamp',
                            descending=True,
                            include_docs=True)
        for result in view:
            doc = result.doc
            project = A(doc['name'],
                        href=configuration.get_url('project', doc['name']))
            # Defensive programming: in reality always defined
            customer = doc.get('customer')
            if customer:
                customer = A(customer,
                             href=configuration.get_url('account', customer))
            rows.append(TR(TD(project),
                           TD(result.value or ''),
                           TD(customer),
                           TD(str(counts.get(doc['name'], 0))),
                           TD(result.key)))
        page.append(TABLE(border=1, *rows))

        page.write(response)
Пример #15
0
    def GET(self, request, response):
        self.check_viewable(self.user)
        page = HtmlPage(self, title='Accounts')
        page.header = DIV(H1(page.title), utils.rst_to_html(Account.__doc__))

        if self.get_editable(self.user):
            page.append(
                P(
                    FORM(INPUT(type='submit', value='Create new account'),
                         method='GET',
                         action=configuration.get_url('account'))))

        rows = [TR(TH('Account'), TH('Full name'), TH('Role'), TH('Initials'))]
        for result in self.db.view('account/name', include_docs=True):
            doc = result.doc
            ref = A(result.key,
                    href=configuration.get_url('account', result.key))
            rows.append(
                TR(TD(ref), TD(result.value or ''), TD(doc.get('role')),
                   TD(doc.get('initials') or '')))
        page.append(TABLE(border=1, *rows))

        page.write(response)
Пример #16
0
    def GET(self, request, response):
        self.check_viewable(self.user)
        page = HtmlPage(self, title='Projects')
        page.header = DIV(H1(page.title), utils.rst_to_html(Project.__doc__))

        if self.get_editable(self.user):
            page.append(
                P(
                    FORM(INPUT(type='submit', value='Create new project'),
                         method='GET',
                         action=configuration.get_url('project'))))

        view = self.db.view('sample/project_count', group=True)
        counts = dict([(r.key, r.value) for r in view])
        rows = [
            TR(TH('Project'), TH('Label'), TH('Customer'), TH('# Samples'),
               TH('Timestamp'))
        ]
        view = self.db.view('project/timestamp',
                            descending=True,
                            include_docs=True)
        for result in view:
            doc = result.doc
            project = A(doc['name'],
                        href=configuration.get_url('project', doc['name']))
            # Defensive programming: in reality always defined
            customer = doc.get('customer')
            if customer:
                customer = A(customer,
                             href=configuration.get_url('account', customer))
            rows.append(
                TR(TD(project), TD(result.value or ''), TD(customer),
                   TD(str(counts.get(doc['name'], 0))), TD(result.key)))
        page.append(TABLE(border=1, *rows))

        page.write(response)
Пример #17
0
    def GET(self, request, response):
        self.check_viewable(self.user)
        page = HtmlPage(self, title='Protocols')
        page.header = DIV(H1(page.title),
                          utils.rst_to_html(Protocol.__doc__))

        if self.get_editable(self.user):
            page.append(P(FORM(INPUT(type='submit',
                                     value='Create new protocol'),
                               method='GET',
                               action=configuration.get_url('protocol'))))

        view = self.db.view('protocol/name', include_docs=True)
        rows = [TR(TH('Protocol'),
                   TH('Timestamp'))]
        for result in view:
            doc = result.doc
            protocol = A(doc['name'],
                        href=configuration.get_url('protocol', doc['name']))
            rows.append(TR(TD(protocol),
                           TD(doc['timestamp'])))
        page.append(TABLE(border=1, *rows))

        page.write(response)