From: Diane Trout Date: Tue, 5 May 2015 21:18:41 +0000 (-0700) Subject: Move lanes_for from samples to experiments X-Git-Url: http://woldlab.caltech.edu/gitweb/?p=htsworkflow.git;a=commitdiff_plain;h=0bf9274007c54c59b907e94fd9b0a00097ff477a Move lanes_for from samples to experiments --- diff --git a/experiments/views.py b/experiments/views.py index 7d30bbe..1e7c3f2 100644 --- a/experiments/views.py +++ b/experiments/views.py @@ -19,6 +19,9 @@ from .models import DataRun, DataFile, FlowCell, Lane, Sequencer from .experiments import estimateFlowcellDuration, estimateFlowcellTimeRemaining, roundToDays, \ getUsersForFlowcell, \ makeEmailLaneMap +from samples.changelist import HTSChangeList +from samples.models import HTSUser + def index(request): all_runs = DataRun.objects.order_by('-run_start_time') @@ -187,3 +190,33 @@ def sequencer(request, sequencer_id): context = RequestContext(request, {'sequencer': sequencer}) return render_to_response('experiments/sequencer.html', context) + + +def lanes_for(request, username=None): + """ + Generate a report of recent activity for a user + """ + query = {} + if username is not None: + try: + user = HTSUser.objects.get(username=username) + query.update({'library__affiliations__users__id': user.id}) + except HTSUser.DoesNotExist as e: + raise Http404('User not found') + + fcl = HTSChangeList(request, Lane, + list_filter=['library__affiliations', + 'library__library_species'], + search_fields=['flowcell__flowcell_id', 'library__id', 'library__library_name'], + list_per_page=200, + model_admin=LaneOptions(Lane, None), + extra_filters=query + ) + + context = {'lanes': fcl, 'title': 'Lane Index'} + + return render_to_response( + 'samples/lanes_for.html', + context, + context_instance=RequestContext(request) + ) diff --git a/htsworkflow/urls.py b/htsworkflow/urls.py index 1bfbf3d..bb83642 100644 --- a/htsworkflow/urls.py +++ b/htsworkflow/urls.py @@ -17,8 +17,8 @@ urlpatterns = patterns('', 'experiments.views.flowcell_detail'), url(r'^inventory/', include('inventory.urls')), url(r'^library/', include('samples.urls')), - url(r'^lanes_for/$', 'samples.views.lanes_for'), - url(r'^lanes_for/(?P\w+)', 'samples.views.lanes_for'), + url(r'^lanes_for/$', 'experiments.views.lanes_for'), + url(r'^lanes_for/(?P[-_ \w]+)', 'experiments.views.lanes_for'), ### library id to admin url url(r'^library_id_to_admin_url/(?P\w+)/$', 'samples.views.library_id_to_admin_url'), diff --git a/samples/views.py b/samples/views.py index d339835..050c2a5 100644 --- a/samples/views.py +++ b/samples/views.py @@ -160,31 +160,6 @@ def library_to_flowcells(request, lib_id): context_instance=RequestContext(request)) -def lanes_for(request, username=None): - """ - Generate a report of recent activity for a user - """ - query = {} - if username is not None: - user = HTSUser.objects.get(username=username) - query.update({'library__affiliations__users__id': user.id}) - fcl = HTSChangeList(request, Lane, - list_filter=[], - search_fields=['flowcell__flowcell_id', 'library__id', 'library__library_name'], - list_per_page=200, - model_admin=LaneOptions, - queryset=Lane.objects.filter(**query) - ) - - context = {'lanes': fcl, 'title': 'Lane Index'} - - return render_to_response( - 'samples/lanes_for.html', - context, - context_instance=RequestContext(request) - ) - - def summaryhtm_fc_cnm(request, flowcell_id, cnm): """ returns a Summary.htm file if it exists.