Added custom view to display libraries, when a library is selected it says what flowc...
[htsworkflow.git] / gaworkflow / frontend / fctracker / views.py
1 # Create your views here.
2 from gaworkflow.frontend.fctracker.models import Library
3 from django.http import HttpResponse
4
5 #from django.db.models import base 
6
7 def library(request):
8     library_list = Library.objects.all() #.order_by('-pub_date')
9     rep_string = '<a href="/library/%s/">%s - %s (%s)</a>'
10     output = '<br />\n'.join([rep_string \
11       % (l.library_id,
12          l.library_id,
13          l.library_name,
14          l.library_species.scientific_name) for l in library_list])
15     return HttpResponse(output)
16
17 def library_to_flowcells(request, lib_id):
18     
19     try:
20       lib = Library.objects.get(library_id=lib_id)
21     except:
22       return HttpResponse("Library %s does not exist" % (lib_id))
23     
24     output = []
25     
26     output.extend([ '%s - Lane 1' % (fc.flowcell_id) for fc in lib.lane_1_library.all() ])
27     output.extend([ '%s - Lane 2' % (fc.flowcell_id) for fc in lib.lane_2_library.all() ])
28     output.extend([ '%s - Lane 3' % (fc.flowcell_id) for fc in lib.lane_3_library.all() ])
29     output.extend([ '%s - Lane 4' % (fc.flowcell_id) for fc in lib.lane_4_library.all() ])
30     output.extend([ '%s - Lane 5' % (fc.flowcell_id) for fc in lib.lane_5_library.all() ])
31     output.extend([ '%s - Lane 6' % (fc.flowcell_id) for fc in lib.lane_6_library.all() ])
32     output.extend([ '%s - Lane 7' % (fc.flowcell_id) for fc in lib.lane_7_library.all() ])
33     output.extend([ '%s - Lane 8' % (fc.flowcell_id) for fc in lib.lane_8_library.all() ])
34     
35     return HttpResponse('<br />\n'.join(output))