Skip to content

Commit

Permalink
Merge pull request #158 from biocore/env_source_creation
Browse files Browse the repository at this point in the history
Environmental source creation
  • Loading branch information
wasade committed May 17, 2020
2 parents 5cd4253 + 5cef733 commit 373e795
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 5 deletions.
21 changes: 21 additions & 0 deletions microsetta_private_api/example/client.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,27 @@ paths:
schema:
type: string

'/accounts/{account_id}/sources/':
post:
operationId: microsetta_private_api.example.client_impl.post_source
tags:
- Sources
parameters:
- $ref: '#/components/parameters/account_id'
requestBody:
content:
application/x-www-form-urlencoded:
schema:
type: object
additionalProperties: true
responses:
'200':
description: List of sources page
content:
text/html:
schema:
type: string

'/accounts/{account_id}/sources/{source_id}':
get:
operationId: microsetta_private_api.example.client_impl.get_source
Expand Down
15 changes: 15 additions & 0 deletions microsetta_private_api/example/client_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,21 @@ def post_workflow_create_human_source(body):
return redirect(WORKFLOW_URL)


def post_source(account_id, body):
next_state, current_state = determine_workflow_state()
if next_state != ALL_DONE:
return redirect(WORKFLOW_URL)

acct_id = current_state["account_id"]
do_return, sources_output, _ = ApiRequest.post(
"/accounts/{0}/sources".format(acct_id), json=body)

if do_return:
return sources_output

return redirect('/accounts/%s' % acct_id)


def get_workflow_claim_kit_samples():
next_state, current_state = determine_workflow_state()
if next_state != NEEDS_SAMPLE:
Expand Down
54 changes: 49 additions & 5 deletions microsetta_private_api/templates/account.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,63 @@
{% set page_title = "Sources" %}
{% set show_breadcrumbs = True %}
{% block head %}
<script src="/static/vendor/js/jquery-3.4.1.min.js"></script>
<script src="/static/vendor/js/jquery.validate.min.js"></script>
<script>
$(document).ready(function() {
// Initialize form validation
$("form[name='new_source_form']").validate({
// Specify validation rules
rules: {
// The key name on the left side is the name attribute
// of an input field. Validation rules are defined
// on the right side
// TODO: Nothing here keeps someone from e.g. naming all their sources "Bob", etc
source_name: "required",
source_type: "required"
}
});
});
</script>
{% endblock %}
{% block content %}
<div class="container">
{% if sources|length > 0 %}
Sources:
Choose a source:
<div class="list-group">
{% for source in sources %}
<a href="/accounts/{{acct_id}}/sources/{{ source.source_id }}"
class="list-group-item list-group-item-action {{loop.cycle('odd', 'even') }}">
{{ source.source_name }}
</a>
<div class="container list-group-item {{loop.cycle('odd', 'even') }}">
<div class="row">
<div class="col-sm">
<a href="/accounts/{{acct_id}}/sources/{{ source.source_id|e }}">
{{ source.source_name|e}}
</a>
</div>
<div class="col-sm">
{{source.source_type|e}}
</div>
</div>
</div>
{% endfor %}
</div>
<p>
or
</p>
{% endif %}
</div>
<div class="container">
Create a new environmental source:
<form method="post" name="new_source_form" action="/accounts/{{acct_id}}/sources/">
<div class="form-group">
<label for="source_name" name="source_name_label">Name</label>
<input id="source_name" name="source_name" class="form-control" type="text"/>
<input id="source_type" name="source_type" type="hidden" value="environmental" />
<br />
<label for="source_description" name="source_description_label">Description</label>
<input id="source_description" name="source_description" class="form-control" type="text"/>
</div>
<input type="submit" class="btn btn-primary" value="Create Source"/>
</form>
</div>
{% endblock %}

0 comments on commit 373e795

Please sign in to comment.