PageRenderTime 16ms CodeModel.GetById 10ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/templates/requests/common/add_samples.mako

https://bitbucket.org/cistrome/cistrome-harvard/
Mako | 128 lines | 118 code | 8 blank | 2 comment | 8 complexity | 5e0eb095a25ac604f7033a208a699ea9 MD5 | raw file
  1<%inherit file="/base.mako"/>
  2<%namespace file="/message.mako" import="render_msg" />
  3<%namespace file="/requests/common/common.mako" import="common_javascripts" />
  4<%namespace file="/requests/common/common.mako" import="render_samples_grid" />
  5<%namespace file="/requests/common/common.mako" import="render_request_type_sample_form_grids" />
  6<%namespace file="/requests/common/common.mako" import="render_samples_messages" />
  7
  8<%def name="stylesheets()">
  9    ${parent.stylesheets()}
 10    ${h.css( "library" )}
 11</%def>
 12
 13<%def name="javascripts()">
 14   ${parent.javascripts()}
 15   ${common_javascripts()}
 16</%def>
 17
 18<%
 19    from galaxy.web.framework.helpers import time_ago
 20
 21    is_admin = cntrller == 'requests_admin' and trans.user_is_admin()
 22    is_complete = request.is_complete
 23    is_submitted = request.is_submitted
 24    is_unsubmitted = request.is_unsubmitted
 25    if is_admin:
 26       can_add_samples = not is_complete
 27    else:
 28       can_add_samples = is_unsubmitted
 29    can_delete_samples = request.samples and not is_complete
 30    can_edit_samples = request.samples and ( is_admin or not is_complete )
 31    can_edit_request = ( is_admin and not request.is_complete ) or request.is_unsubmitted
 32    can_reject = is_admin and is_submitted
 33    can_submit = request.samples and is_unsubmitted
 34%>
 35
 36<br/><br/>
 37
 38<ul class="manage-table-actions">
 39    %if can_edit_samples:
 40        <li><a class="action-button" href="${h.url_for( controller='requests_common', action='edit_samples', cntrller=cntrller, id=trans.security.encode_id( request.id ) )}">Edit samples</a></li>
 41    %endif
 42    %if can_submit:
 43        <li><a class="action-button" confirm="More samples cannot be added to this request after it is submitted. Click OK to submit." href="${h.url_for( controller='requests_common', action='submit_request', cntrller=cntrller, id=trans.security.encode_id( request.id ) )}">Submit request</a></li>
 44    %endif
 45    <li><a class="action-button" id="request-${request.id}-popup" class="menubutton">Request Actions</a></li>
 46    <div popupmenu="request-${request.id}-popup">
 47        <a class="action-button" href="${h.url_for( controller='requests_common', action='view_request', cntrller=cntrller, id=trans.security.encode_id( request.id ) )}">Browse this request</a>
 48        %if can_edit_request:
 49            <a class="action-button" href="${h.url_for( controller='requests_common', action='edit_basic_request_info', cntrller=cntrller, id=trans.security.encode_id( request.id ) )}">Edit this request</a>
 50        %endif
 51        <a class="action-button" href="${h.url_for( controller='requests_common', action='view_request_history', cntrller=cntrller, id=trans.security.encode_id( request.id ) )}">View history</a>
 52        %if can_reject:
 53            <a class="action-button" href="${h.url_for( controller='requests_admin', action='reject_request', cntrller=cntrller, id=trans.security.encode_id( request.id ) )}">Reject this request</a>
 54        %endif
 55    </div>
 56</ul>
 57
 58${render_samples_messages(request, is_admin, is_submitted, message, status)}
 59
 60<div class="toolFormBody">
 61    <form id="add_samples" name="add_samples" action="${h.url_for( controller='requests_common', action='add_samples', cntrller=cntrller, id=trans.security.encode_id( request.id ) )}" method="post">
 62        %if displayable_sample_widgets:
 63            <%
 64                grid_header = '<h3>Add samples to sequencing request "%s"</h3>' % request.name
 65            %>
 66            ${render_samples_grid( cntrller, request, displayable_sample_widgets, action='edit_samples', adding_new_samples=True, encoded_selected_sample_ids=[], render_buttons=False, grid_header=grid_header )}
 67            <div class="toolParamHelp" style="clear: both;">
 68                For each sample, select the data library and folder in which you would like the run datasets deposited.
 69                To automatically run a workflow on run datastets, select a history first and then the desired workflow. 
 70            </div>
 71            ## Render the other grids
 72            <% trans.sa_session.refresh( request.type.sample_form ) %>
 73            %for grid_index, grid_name in enumerate( request.type.sample_form.layout ):
 74                ${render_request_type_sample_form_grids( grid_index, grid_name, request.type.sample_form.grid_fields( grid_index ), displayable_sample_widgets=displayable_sample_widgets, show_saved_samples_read_only=True )}
 75            %endfor
 76        %else:
 77            <label>There are no samples.</label>
 78        %endif  
 79        %if can_add_samples:
 80            ## The user is adding a new sample
 81            %if displayable_sample_widgets:
 82                <p/>
 83                <div class="form-row">
 84                    <label> Copy <input type="text" name="num_sample_to_copy" value="1" size="3"/> samples from sample ${sample_copy_select_field.get_html()}</label>
 85                    <div class="toolParamHelp" style="clear: both;">
 86                        Select the sample from which the new sample should be copied or leave selection as <b>None</b> to add a new "generic" sample.
 87                    </div>
 88                </div>
 89            %endif
 90            <p/>
 91            <div class="form-row">
 92                <input type="hidden" name="twill" value=""/>
 93                %if ( request.samples or displayable_sample_widgets ) and len( displayable_sample_widgets ) > len( request.samples ):
 94                    <input type="submit" name="add_sample_button" value="Add sample" />
 95                    <input type="submit" name="save_samples_button" value="Save"/>
 96                    <input type="submit" name="cancel_changes_button" value="Cancel"/>
 97                    <div class="toolParamHelp" style="clear: both;">
 98                        Click the <b>Add sample</b> button for each new sample and click the <b>Save</b> button when you have finished adding samples.
 99                    </div>
100                %else:
101                    <input type="submit" name="add_sample_button" value="Add sample"/>
102                    <div class="toolParamHelp" style="clear: both;">
103                        Click the <b>Add sample</b> button for each new sample.
104                    </div>
105                %endif
106            </div>
107        %endif
108    </form>
109</div>
110%if is_unsubmitted:
111    <p/>
112    <h4><img src="/static/images/silk/resultset_next.png" alt="Hide" onclick="showContent(this);" style="cursor:pointer;"/>Import samples from csv file</h4>
113    <div style="display:none;">
114        <div class="toolFormBody">
115            <form id="import" name="import" action="${h.url_for( controller='requests_common', action='add_samples', cntrller=cntrller, id=trans.security.encode_id( request.id ) )}" enctype="multipart/form-data" method="post" >
116                <div class="form-row">
117                    <input type="file" name="file_data" />
118                    <input type="submit" name="import_samples_button" value="Import samples"/>
119                    <div class="toolParamHelp" style="clear: both;">
120                        The csv file must be in the following format.<br/>
121                        The [:FieldValue] is optional, the named form field will contain the value after the ':' if included.<br/>
122                        SampleName,DataLibraryName,FolderName,HistoryName,WorkflowName,Field1Name:Field1Value,Field2Name:Field2Value...
123                    </div>
124                </div>
125            </form>
126        </div>
127    </div>
128%endif