Skip to content

Commit

Permalink
start with forms
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosp420 committed Jan 26, 2015
1 parent 217ff91 commit 1d35a31
Show file tree
Hide file tree
Showing 13 changed files with 243 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Makefile
@@ -1,5 +1,5 @@
help:
@echo "serve - remove build artifacts"
@echo "serve - runserver for development"
@echo "test - use testing settings and SQlite3 database"

serve: index stats
Expand All @@ -16,7 +16,7 @@ import:
python voseq/manage.py migrate_db --dumpfile=test_db_dump.xml --settings=voseq.settings.local

index:
python voseq/manage.py rebuild_index
python voseq/manage.py rebuild_index --settings=voseq.settings.local

stats:
python voseq/manage.py create_stats --settings=voseq.settings.local
Expand Down
Empty file.
3 changes: 3 additions & 0 deletions voseq/create_dataset/admin.py
@@ -0,0 +1,3 @@
from django.contrib import admin

# Register your models here.
66 changes: 66 additions & 0 deletions voseq/create_dataset/forms.py
@@ -0,0 +1,66 @@
from django import forms

from public_interface.models import Genes
from public_interface.models import GeneSets
from public_interface.models import TaxonSets


class CreateDatasetForm(forms.Form):
file_format = forms.ChoiceField(
label='Choose file format',
choices=[
('TNT', 'TNT format'),
('NEXUS', 'NEXUS format'),
('PHY', 'PHYLIP format'),
('FASTA', 'Unaligned FASTA format'),
]
)

outgroup = forms.CharField(
label='Outgroup (code, for NEXUS and TNT)',
help_text='Voucher code for using that specimen\'s sequence as '
'outgroup in NEXUS and TNT datasets.',
)
"""
taxonset = forms.ModelChoiceField(
TaxonSets.objects.all(),
label='Choose taxonset',
required=False,
empty_label='Choose taxonset',
)
geneset = forms.ModelChoiceField(
GeneSets.objects.all(),
label='Choose geneset',
required=False,
empty_label='Choose geneset',
)
gene_codes = forms.ModelMultipleChoiceField(
Genes.objects.all(),
label='Check to select your alignment/gene',
required=False,
widget=forms.CheckboxSelectMultiple(),
)
voucher_codes = forms.CharField(
widget=forms.Textarea,
label='... and/or a list of voucher codes',
required=False,
)
"""

def clean(self):
"""Overwriting validator method of class form."""
cleaned_data = super(GenBankFastaForm, self).clean()
taxonset = cleaned_data.get("taxonset")
voucher_codes = cleaned_data.get("voucher_codes")

geneset = cleaned_data.get("geneset")
gene_codes = cleaned_data.get("gene_codes")
print(gene_codes)

if taxonset is None and voucher_codes.strip() == '':
raise forms.ValidationError("You need to enter at least some "
"voucher codes or select a taxonset.")

if geneset is None and len(gene_codes) < 1:
raise forms.ValidationError("You need to enter at least some "
"gene codes or select a geneset.")
Empty file.
3 changes: 3 additions & 0 deletions voseq/create_dataset/models.py
@@ -0,0 +1,3 @@
from django.db import models

# Create your models here.
138 changes: 138 additions & 0 deletions voseq/create_dataset/templates/create_dataset/index.html
@@ -0,0 +1,138 @@
{% extends 'public_interface/base.html' %}


{% block additional_css %}
{% load staticfiles %}
<link rel="stylesheet" href="{% static 'css/jquery-ui.min.css' %}">
<link rel="stylesheet" href="{% static 'css/jquery-ui.structure.min.css' %}">
<link rel="stylesheet" href="{% static 'css/jquery-ui.theme.min.css' %}">
{% endblock additional_css %}


{% block content %}
<div class="explorer-container">
<div class="container">
<h3>Create dataset:</h3>

<div class="alert alert-info" role="alert">
<b>Select sequences you want for a dataset by entering the voucher codes and gene codes.</b>
</div>

<div class="container">
<div class="row">

<div class="col-xs-12 col-sm-12 col-md-11 col-lg-9 col-lg-offset-1">

<form action="/genbank_fasta/results/" method="post">
<div class="panel panel-primary" style="min-width: 790px;">
<div class="panel-heading">
<h3 class="panel-title"><b>Enter the required info to make yourself a ready-to-run dataset</b></h3>
</div>



{{ form.as_p }}
<i class="fa fa-exclamation-triangle"></i> Warning! your dataset will not necessarily be properly aligned!
<a title="You need to be sure that your data is aligned!" href="#"><i class="fa fa-question-circle"></i></a>
{% csrf_token %}

{% for i in form.non_field_errors %}
<div class="alert alert-warning">{{ i }}</div>
{% endfor %}
<table class="table table-bordered"><!-- big -->
<tr>
<td>
<table class="table table-bordered">
<tr>
<td>
<label for="id_taxonset">Choose taxonset: </label>
</td>
<td>
{% for i in form.taxonset.errors %}
<div class="alert alert-warning">{{ i }}</div>
{% endfor %}
{{ form.taxonset }}
</td>
</tr>
<tr>
<td>
<label for="id_voucher_codes">... and/or a list of voucher codes: </label>
</td>
<td>
{% for i in form.voucher_codes.errors %}
<div class="alert alert-warning">{{ i }}</div>
{% endfor %}
{{ form.voucher_codes }}
</td>
</tr>
</table>
</td>

<td>
<table class="table table-bordered">
<tr>
<td>
<label for="id_geneset">Choose geneset: </label>
</td>
<td>
{% for i in form.geneset.errors %}
<div class="alert alert-warning">{{ i }}</div>
{% endfor %}
{{ form.geneset }}
</td>
</tr>
<tr>
<td>
Check to select your alignment/gene:<br />
<br />
(if geneset chosen, adds extra genes)
</td>
<td>
<table class="table table-condensed table-striped">
<tr>
{% for i in form.gene_codes %}
<td>
{{ i }}
</td>
{% endfor %}
</tr>
</table>
</td>
</tr>
</table>
</td>

</tr>
</table><!-- big -->

</div><!-- panel -->

<button type="submit" class="btn btn-info" id="submit_button">
Make GenBank FASTA1
</button>
</form>







</div><!-- col -->

</div><!-- row -->
</div><!-- container -->


</div>
</div>
{% endblock content %}


{% block additional_javascript_footer %}
<script>
$(function() {
$( document ).tooltip();
});
</script>
{% endblock additional_javascript_footer %}
3 changes: 3 additions & 0 deletions voseq/create_dataset/tests.py
@@ -0,0 +1,3 @@
from django.test import TestCase

# Create your tests here.
10 changes: 10 additions & 0 deletions voseq/create_dataset/urls.py
@@ -0,0 +1,10 @@
from django.conf.urls import patterns
from django.conf.urls import url

from . import views


urlpatterns = patterns(
'',
url(r'^/$', views.index, name='index'),
)
14 changes: 14 additions & 0 deletions voseq/create_dataset/views.py
@@ -0,0 +1,14 @@
from django.shortcuts import render

from .forms import CreateDatasetForm


def index(request):
form = CreateDatasetForm()

return render(request,
'create_dataset/index.html',
{
'form': form,
},
)
Expand Up @@ -104,6 +104,7 @@
<ul class="dropdown-menu" role="menu">
<li><a href="/genes/">View genes</a></li>
<li><a href="/blast_new/">Blast new sequence</a></li>
<li><a href="/create_dataset/">Create new dataset</a></li>
<li><a href="/genbank_fasta/">Create GenBank FASTA file</a></li>
</ul>
</div>
Expand Down
1 change: 1 addition & 0 deletions voseq/voseq/settings/base.py
Expand Up @@ -40,6 +40,7 @@
# my apps
'core',
'public_interface',
'create_dataset',
'blast_local',
'blast_local_full',
'blast_ncbi',
Expand Down
2 changes: 2 additions & 0 deletions voseq/voseq/urls.py
Expand Up @@ -3,12 +3,14 @@

urlpatterns = patterns(
'',
url(r'^create_dataset', include('create_dataset.urls', namespace='create_dataset')),
url(r'^genbank_fasta', include('genbank_fasta.urls', namespace='genbank_fasta')),
url(r'^blast_local', include('blast_local.urls', namespace='blast_local')),
url(r'^blast_local_full', include('blast_local_full.urls', namespace='blast_local_full')),
url(r'^blast_ncbi', include('blast_ncbi.urls', namespace='blast_ncbi')),
url(r'^blast_new', include('blast_new.urls', namespace='blast_new')),
url(r'^genes', include('view_genes.urls', namespace='view_genes')),
url(r'^', include('public_interface.urls', namespace='public_interace')),

url(r'^admin/', include(admin.site.urls)),
)

0 comments on commit 1d35a31

Please sign in to comment.