PageRenderTime 28ms CodeModel.GetById 18ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/templates/library/common/ldda_info.mako

https://bitbucket.org/cistrome/cistrome-harvard/
Mako | 288 lines | 281 code | 6 blank | 1 comment | 4 complexity | 574a4d8f0c0b33dc9b931497080ab623 MD5 | raw file
  1<%inherit file="/base.mako"/>
  2<%namespace file="/message.mako" import="render_msg" />
  3<%namespace file="/common/template_common.mako" import="render_template_fields" />
  4<%
  5    from galaxy import util
  6    from galaxy.web.controllers.library_common import branch_deleted, get_containing_library_from_library_dataset
  7    from galaxy.web.framework.helpers import time_ago
  8
  9    if ldda == ldda.library_dataset.library_dataset_dataset_association:
 10        current_version = True
 11    else:
 12        current_version = False
 13    if ldda.user:
 14        uploaded_by = ldda.user.email
 15    else:
 16        uploaded_by = 'anonymous'
 17    if trans.user_is_admin() and cntrller == 'library_admin':
 18        can_modify = can_manage = True
 19    elif cntrller in [ 'library', 'requests' ]:
 20        can_modify = trans.app.security_agent.can_modify_library_item( current_user_roles, ldda.library_dataset )
 21        can_manage = trans.app.security_agent.can_manage_library_item( current_user_roles, ldda.library_dataset )
 22    else:
 23        can_modify = can_manage = False
 24    form_type = trans.model.FormDefinition.types.LIBRARY_INFO_TEMPLATE
 25%>
 26
 27<%def name="javascripts()">
 28    ${parent.javascripts()}
 29</%def>
 30
 31%if current_version:
 32    <b><i>This is the latest version of this library dataset</i></b>
 33%else:
 34    <font color="red"><b><i>This is an expired version of this library dataset</i></b></font>
 35%endif
 36<p/>
 37
 38<ul class="manage-table-actions">
 39    <li>
 40        <a class="action-button" href="${h.url_for( controller='library_common', action='browse_library', cntrller=cntrller, id=trans.security.encode_id( library.id ), use_panels=use_panels, show_deleted=show_deleted )}"><span>Browse this data library</span></a>
 41    </li>
 42</ul>
 43
 44%if message:
 45    ${render_msg( message, status )}
 46%endif
 47
 48<div class="toolForm">
 49    <div class="toolFormTitle">
 50        Information about <div class="menubutton popup" id="dataset-${ldda.id}-popup">${ldda.name}</div>
 51        %if not library.deleted and not branch_deleted( ldda.library_dataset.folder ) and not ldda.library_dataset.deleted:
 52            <div popupmenu="dataset-${ldda.id}-popup">
 53                %if can_modify:
 54                    <a class="action-button" href="${h.url_for( controller='library_common', action='ldda_edit_info', cntrller=cntrller, library_id=trans.security.encode_id( library.id ), folder_id=trans.security.encode_id( ldda.library_dataset.folder.id ), id=trans.security.encode_id( ldda.id ), use_panels=use_panels, show_deleted=show_deleted )}">Edit information</a>
 55                    %if not info_association:
 56                        <a class="action-button" href="${h.url_for( controller='library_common', action='add_template', cntrller=cntrller, item_type='ldda', form_type=form_type, library_id=trans.security.encode_id( library.id ), folder_id=trans.security.encode_id( ldda.library_dataset.folder.id ), ldda_id=trans.security.encode_id( ldda.id ), use_panels=use_panels, show_deleted=show_deleted )}">Use template</a>
 57                    %else:
 58                        <a class="action-button" href="${h.url_for( controller='library_common', action='edit_template', cntrller=cntrller, item_type='ldda', form_type=form_type, library_id=trans.security.encode_id( library.id ), folder_id=trans.security.encode_id( ldda.library_dataset.folder.id ), ldda_id=trans.security.encode_id( ldda.id ), use_panels=use_panels, show_deleted=show_deleted )}">Edit template</a>
 59                        <a class="action-button" href="${h.url_for( controller='library_common', action='delete_template', cntrller=cntrller, item_type='ldda', form_type=form_type, library_id=trans.security.encode_id( library.id ), folder_id=trans.security.encode_id( ldda.library_dataset.folder.id ), ldda_id=trans.security.encode_id( ldda.id ), use_panels=use_panels, show_deleted=show_deleted )}">Unuse template</a>
 60                    %endif
 61                %endif
 62                %if can_manage:
 63                    <a class="action-button" href="${h.url_for( controller='library_common', action='ldda_permissions', cntrller=cntrller, library_id=trans.security.encode_id( library.id ), folder_id=trans.security.encode_id( ldda.library_dataset.folder.id ), id=trans.security.encode_id( ldda.id ), use_panels=use_panels, show_deleted=show_deleted )}">Edit permissions</a>
 64                %endif
 65                %if current_version and can_modify:
 66                    <a class="action-button" href="${h.url_for( controller='library_common', action='upload_library_dataset', cntrller=cntrller, library_id=trans.security.encode_id( library.id ), folder_id=trans.security.encode_id( ldda.library_dataset.folder.id ), replace_id=trans.security.encode_id( ldda.library_dataset.id ) )}">Upload a new version of this dataset</a>
 67                %endif
 68                %if ldda.has_data():
 69                    <a class="action-button" href="${h.url_for( controller='library_common', action='import_datasets_to_histories', cntrller=cntrller, library_id=trans.security.encode_id( library.id ), ldda_ids=trans.security.encode_id( ldda.id ), use_panels=use_panels, show_deleted=show_deleted )}">Import this dataset into selected histories</a>
 70                    <a class="action-button" href="${h.url_for( controller='library_common', action='download_dataset_from_folder', cntrller=cntrller, id=trans.security.encode_id( ldda.id ), library_id=trans.security.encode_id( library.id ), use_panels=use_panels, show_deleted=show_deleted )}">Download this dataset</a>
 71                %endif
 72                %if show_associated_hdas_and_lddas:
 73                    <a class="action-button" href="${h.url_for( controller='library_common', action='ldda_info', cntrller=cntrller, library_id=trans.security.encode_id( library.id ), folder_id=trans.security.encode_id( ldda.library_dataset.folder.id ), id=trans.security.encode_id( ldda.id ), show_associated_hdas_and_lddas=False, use_panels=use_panels, show_deleted=show_deleted )}">Hide items using this dataset's disk file</a>
 74                %else:
 75                    <a class="action-button" href="${h.url_for( controller='library_common', action='ldda_info', cntrller=cntrller, library_id=trans.security.encode_id( library.id ), folder_id=trans.security.encode_id( ldda.library_dataset.folder.id ), id=trans.security.encode_id( ldda.id ), show_associated_hdas_and_lddas=True, use_panels=use_panels, show_deleted=show_deleted )}">Show items using this dataset's disk file</a>
 76                %endif
 77            </div>
 78        %endif
 79    </div>
 80    <div class="toolFormBody">
 81        %if ldda.message:
 82            <div class="form-row">
 83                <label>Message:</label>
 84                <pre>${ldda.message}</pre>
 85                <div style="clear: both"></div>
 86            </div>
 87        %endif
 88        <div class="form-row">
 89            <label>Uploaded by:</label>
 90            ${uploaded_by}
 91            <div style="clear: both"></div>
 92        </div>
 93        <div class="form-row">
 94            <label>Date uploaded:</label>
 95            ${ldda.create_time.strftime( "%Y-%m-%d" )}
 96            <div style="clear: both"></div>
 97        </div>
 98        <div class="form-row">
 99            <label>File size:</label>
100            ${ldda.get_size( nice_size=True )}
101            <div style="clear: both"></div>
102        </div>
103        %if ldda.tool_version:
104            <div class="form-row">
105                <label>Tool version:</label>
106                ${ldda.tool_version}
107                <div style="clear: both"></div>
108            </div>
109        %endif
110        <div class="form-row">
111            <label>Data type:</label>
112            ${ldda.ext}
113            <div style="clear: both"></div>
114        </div>
115        <div class="form-row">
116            <label>Build:</label>
117            ${ldda.dbkey}
118            <div style="clear: both"></div>
119        </div>
120        <div class="form-row">
121            <label>Miscellaneous information:</label>
122            ${ldda.info}
123            <div style="clear: both"></div>
124        </div>
125        %if ldda.creating_job_associations:
126            <% job = ldda.creating_job_associations[0].job %>
127            %if job.stdout and job.stdout.strip() != '':
128                <div class="form-row">
129                    <label>Job Standard Output</label>
130                    <pre>${job.stdout}</pre>
131                    <div style="clear: both"></div>
132                </div>
133            %endif
134            %if job.stderr and job.stderr.strip() != '':
135                <div class="form-row">
136                    <label>Job Standard Error</label>
137                    <pre>${job.stderr}</pre>
138                    <div style="clear: both"></div>
139                </div>
140            %endif
141        %endif
142        <div class="form-row">
143            <div>${ldda.blurb}</div>
144        </div>
145        ## We want to display all metadata item here, whether marked visible or not since they are all pretty useful
146        %for name, spec in ldda.metadata.spec.items():
147            <div class="form-row">
148                <label>${spec.desc.replace( ' (click box & select)', '' )}:</label>
149                <%
150                    metadata_val = ldda.metadata.get( name )
151                    if isinstance( metadata_val, trans.model.MetadataFile ):
152                        metadata_val = metadata_val.file_name
153                    elif isinstance( metadata_val, list ):
154                        # Make sure list items are strings
155                        metadata_val = [ str( item ) for item in metadata_val ]
156                        metadata_val = ', '.join( metadata_val )
157                %>
158                ${metadata_val}
159                <div style="clear: both"></div>
160            </div>
161        %endfor
162        %if ldda.peek != "no peek":
163            <div class="form-row">
164                <div id="info${ldda.id}" class="historyItemBody">
165                    <label>Peek:</label>
166                    <div><pre id="peek${ldda.id}" class="peek">${ldda.display_peek()}</pre></div>
167                </div>
168            </div>
169        %endif
170        %if trans.user_is_admin() and cntrller == 'library_admin':
171            <div class="form-row">
172                <label>Disk file:</label>
173                ${ldda.file_name}
174                <div style="clear: both"></div>
175            </div>
176        %endif
177    </div>
178</div>
179%if widgets:
180    ${render_template_fields( cntrller=cntrller, item_type='ldda', widgets=widgets, widget_fields_have_contents=widget_fields_have_contents, library_id=library_id, folder_id=trans.security.encode_id( ldda.library_dataset.folder.id ), ldda_id=trans.security.encode_id( ldda.id ), info_association=info_association, inherited=inherited, editable=False )}
181%endif
182%if show_associated_hdas_and_lddas:
183    %if associated_hdas:
184        <p/>
185        <b>Active (undeleted) history items that use this library dataset's disk file</b>
186        <div class="toolForm">
187            <table class="grid">
188                <thead>
189                    <tr>
190                        <th>History</th>
191                        <th>History Item</th>
192                        <th>Last Updated</th>
193                        <th>User</th>
194                    </tr>
195                </thead>
196                %for hda in associated_hdas:
197                    <tr>
198                        <td>
199                            %if hda.history:
200                                <a target="_blank" href="${h.url_for( controller='history', action='view', id=trans.security.encode_id( hda.history_id ) )}">${hda.history.get_display_name()}</a>
201                            %else:
202                                no history
203                            %endif
204                        </td>
205                        <td>${hda.get_display_name()}</td>
206                        <td>${time_ago( hda.update_time )}</td>
207                        <td>
208                            %if hda.history and hda.history.user:
209                                ${hda.history.user.email}
210                            %else:
211                                anonymous
212                            %endif
213                        </td>
214                    </tr>
215                %endfor
216            </table>
217        </div>
218        <p/>
219    %endif
220    %if associated_lddas:
221        <p/>
222        <b>Other active (undeleted) library datasets that use this library dataset's disk file</b>
223        <div class="toolForm">
224            <table class="grid">
225                <thead>
226                    <tr>
227                        <th>Library</th>
228                        <th>Library Folder</th>
229                        <th>Library Dataset</th>
230                        <th>Last Updated</th>
231                        <th>User</th>
232                    </tr>
233                </thead>
234                %for copied_ldda in associated_lddas:
235                    <% containing_library = get_containing_library_from_library_dataset( trans, copied_ldda.library_dataset ) %>
236                    <tr>
237                        <td>
238                            <%
239                                if containing_library:
240                                    library_display_name = containing_library.get_display_name()
241                                else:
242                                    library_display_name = 'no library'
243                            %>
244                            %if containing_library:
245                                <a href="${h.url_for( controller='library_common', action='browse_library', id=trans.security.encode_id( containing_library.id ), cntrller=cntrller, use_panels=use_panels )}">${library_display_name}</a>
246                            %else:
247                                ${library_display_name}
248                            %endif
249                        </td>
250                        <td>
251                            <%
252                                library_dataset = copied_ldda.library_dataset
253                                folder = library_dataset.folder
254                                folder_display_name = folder.get_display_name()
255                                if folder_display_name == library_display_name:
256                                    folder_display_name = 'library root'
257                            %>
258                            ${folder_display_name}
259                            ${copied_ldda.library_dataset.folder.get_display_name()}
260                        </td>
261                        <td>${copied_ldda.get_display_name()}</td>
262                        <td>${time_ago( copied_ldda.update_time )}</td>
263                        <td>
264                            %if copied_ldda.user:
265                                ${copied_ldda.user.email}
266                            %else:
267                                anonymous
268                            %endif
269                        </td>
270                    </tr>
271                %endfor
272            </table>
273        </div>
274        <p/>
275    %endif
276%endif
277%if current_version:
278    <% expired_lddas = [ e_ldda for e_ldda in ldda.library_dataset.expired_datasets ] %>
279    %if expired_lddas:
280        <br/>
281        <div class="toolFormTitle">Expired versions of ${ldda.name}</div>
282        %for expired_ldda in expired_lddas:
283            <div class="form-row">
284                <a href="${h.url_for( controller='library_common', action='ldda_info', cntrller=cntrller, library_id=trans.security.encode_id( library.id ), folder_id=trans.security.encode_id( expired_ldda.library_dataset.folder.id ), id=trans.security.encode_id( expired_ldda.id ), use_panels=use_panels, show_deleted=show_deleted )}">${expired_ldda.name}</a>
285            </div>
286        %endfor
287    %endif
288%endif