PageRenderTime 26ms CodeModel.GetById 14ms app.highlight 4ms RepoModel.GetById 2ms app.codeStats 0ms

/templates/requests/common/view_request.mako

https://bitbucket.org/cistrome/cistrome-harvard/
Mako | 174 lines | 163 code | 8 blank | 3 comment | 8 complexity | 2e43ec69e0ed570ea99ab43394cb7737 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    can_edit_request = ( is_admin and not request.is_complete ) or request.is_unsubmitted
 26    can_delete_samples = request.samples and not is_complete
 27    can_edit_samples = request.samples and ( is_admin or not is_complete )
 28    can_reject = is_admin and is_submitted
 29    can_submit = request.samples and is_unsubmitted
 30    can_undelete = request.deleted
 31    if is_admin:
 32        can_add_samples = not is_complete
 33    else:
 34        can_add_samples = is_unsubmitted
 35%>
 36
 37<br/><br/>
 38
 39<ul class="manage-table-actions">
 40    %if can_submit:
 41        <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>
 42    %endif
 43    <li><a class="action-button" id="request-${request.id}-popup" class="menubutton">Request Actions</a></li>
 44    <div popupmenu="request-${request.id}-popup">
 45        %if can_undelete:
 46            <a class="action-button" href="${h.url_for( controller='requests_common', action='undelete_request', cntrller=cntrller, id=trans.security.encode_id( request.id ) )}">Undelete this request</a>
 47        %endif
 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="toolForm">
 61    <div class="toolFormTitle">Sequencing request "${request.name}"</div>
 62    <div class="toolFormBody">
 63        <div class="form-row">
 64            <label>Current state:</label>
 65            <a href="${h.url_for( controller='requests_common', action='view_request_history', cntrller=cntrller, id=trans.security.encode_id( request.id ) )}">${request.state}</a>
 66            <div style="clear: both"></div>
 67        </div>
 68        <div class="form-row">
 69            <label>Description:</label>
 70            ${request.desc}
 71            <div style="clear: both"></div>
 72        </div>
 73        <div class="form-row">
 74            <label>User:</label>
 75            ${request.user.email}
 76            <div style="clear: both"></div>
 77        </div>
 78        <div class="form-row">
 79            <label>Request type:</label>
 80            %if is_admin:
 81                <a href="${h.url_for( controller='request_type', action='view_request_type', cntrller=cntrller, id=trans.security.encode_id( request.type.id ) )}">${request.type.name}</a>
 82            %else:
 83                ${request.type.name}
 84            %endif
 85            <div style="clear: both"></div>
 86        </div>
 87        <div class="form-row">
 88            <h4><img src="/static/images/silk/resultset_next.png" alt="Show" onclick="showContent(this);" style="cursor:pointer;"/> More</h4>
 89            <div style="display:none;">
 90                %for index, rd in enumerate( request_widgets ):
 91                    <%
 92                        field_label = rd[ 'label' ]
 93                        field_value = rd[ 'value' ]
 94                    %>
 95                    <div class="form-row">
 96                        <label>${field_label}:</label>                   
 97                        ${field_value}     
 98                    </div>
 99                    <div style="clear: both"></div>
100                %endfor
101                <div class="form-row">
102                    <label>Date created:</label>
103                    ${request.create_time}
104                    <div style="clear: both"></div>
105                </div>
106                <div class="form-row">
107                    <label>Last updated:</label>
108                    ${time_ago( request.update_time )}
109                    <div style="clear: both"></div>
110                </div>
111                <div class="form-row">
112                    <label>Email recipients:</label>
113                    <%
114                        if request.notification:
115                            emails = ', '.join( request.notification[ 'email' ] )
116                        else:
117                            emails = ''
118                    %>
119                    ${emails}
120                    <div style="clear: both"></div>
121                </div>
122                <div class="form-row">
123                    <label>Send email when state changes to:</label>
124                    <%
125                        if request.notification:
126                            states = []
127                            for ss in request.type.states:
128                                if ss.id in request.notification[ 'sample_states' ]:
129                                    states.append( ss.name )
130                            states = ', '.join( states )
131                        else:
132                            states = ''
133                    %>
134                    ${states}
135                    <div style="clear: both"></div>
136                </div>
137                ## Sample state updater
138                %if request.samples and request.is_submitted and request.samples_with_bar_code:
139                    <script type="text/javascript">
140                        // Updater
141                        sample_state_updater( {${ ",".join( [ '"%s" : "%s"' % ( s.id, s.state.name ) for s in request.samples ] ) }});
142                    </script>
143                %endif
144                ## Number of sample datasets updater
145                %if request.samples and request.is_submitted:
146                    <script type="text/javascript">
147                        // Updater
148                        sample_datasets_updater( {${ ",".join( [ '"%s" : "%s"' % ( s.id, len(s.datasets) ) for s in request.samples ] ) }});
149                    </script>
150                %endif
151            </div>
152        </div>
153    </div>
154</div>
155<p/>
156%if displayable_sample_widgets:
157    <%
158        grid_header = '<h3>Samples</h3>'
159        render_buttons = can_edit_samples
160    %>
161    ${render_samples_grid( cntrller, request, displayable_sample_widgets=displayable_sample_widgets, action='view_request', adding_new_samples=True, encoded_selected_sample_ids=[], render_buttons=render_buttons, grid_header=grid_header )}
162    ## Render the other grids
163    <% trans.sa_session.refresh( request.type.sample_form ) %>
164    %for grid_index, grid_name in enumerate( request.type.sample_form.layout ):
165        ${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 )}
166    %endfor
167%else:
168    There are no samples.
169    %if can_add_samples:
170        <ul class="manage-table-actions">
171            <li><a class="action-button" href="${h.url_for( controller='requests_common', action='add_sample', cntrller=cntrller, request_id=trans.security.encode_id( request.id ), add_sample_button='Add sample' )}">Add sample</a></li>
172        </ul>
173    %endif
174%endif