def format_data(self, value, show_edit, show_delete, show_view, view_link_class, edit_link_class, delete_link_class): result = literal() if self.edit_endpoint and show_edit: result += link_to( literal(' '), flask.url_for(self.edit_endpoint, objid=value, session_key=self.grid.session_key), **{ 'aria-label': _('Edit'), 'class_': edit_link_class, 'title': _('Edit') } ) if self.delete_endpoint and show_delete: result += link_to( literal(' '), flask.url_for(self.delete_endpoint, objid=value, session_key=self.grid.session_key), **{ 'aria-label': _('Delete'), 'class_': delete_link_class, 'title': _('Delete') } ) if self.view_endpoint and show_view: result += link_to( literal(' '), flask.url_for(self.view_endpoint, objid=value, session_key=self.grid.session_key), **{ 'aria-label': _('View'), 'class_': view_link_class, 'title': _('View') } ) return result
def lnk(rev, repo_name): lazy_cs = False title_ = None url_ = '#' if isinstance(rev, BaseChangeset) or isinstance(rev, AttributeDict): if rev.op and rev.ref_name: if rev.op == 'delete_branch': lbl = _('Deleted branch: %s') % rev.ref_name elif rev.op == 'tag': lbl = _('Created tag: %s') % rev.ref_name else: lbl = 'Unknown operation %s' % rev.op else: lazy_cs = True lbl = rev.short_id[:8] url_ = url('changeset_home', repo_name=repo_name, revision=rev.raw_id) else: # changeset cannot be found - it might have been stripped or removed lbl = rev[:12] title_ = _('Changeset %s not found') % lbl if parse_cs: return link_to(lbl, url_, title=title_, **{'data-toggle': 'tooltip'}) return link_to(lbl, url_, class_='lazy-cs' if lazy_cs else '', **{'data-raw_id': rev.raw_id, 'data-repo_name': repo_name})
def link_to_ref(repo_name, ref_type, ref_name, rev=None): """ Return full markup for a href to changeset_home for a changeset. If ref_type is branch it will link to changelog. ref_name is shortened if ref_type is 'rev'. if rev is specified show it too, explicitly linking to that revision. """ txt = short_ref(ref_type, ref_name) if ref_type == 'branch': u = url('changelog_home', repo_name=repo_name, branch=ref_name) else: u = url('changeset_home', repo_name=repo_name, revision=ref_name) l = link_to(repo_name + '#' + txt, u) if rev and ref_type != 'rev': l = literal('%s (%s)' % (l, link_to(short_id(rev), url('changeset_home', repo_name=repo_name, revision=rev)))) return l
def render_html(self, record, hah): url = self.create_url(record) if self.link_label is not None: label = self.link_label else: label = self.extract_and_format_data(record) return link_to(label, url, **self.link_attrs)
def options_td(col_num, i, item): # XXX This module can't depend on 'app_globals' or 'url' or # external data. Define data within this method or class or # in a base class. # Could use HTML.a() instead of link_to(). u = url("/tickets/view", ticket_id=item["id"]) a = link_to(item["options"], u) return HTML.td(a)
def render_static(self): if self.displayval == '': todisplay = literal(' ') else: if self.displayval.startswith('http:') or self.displayval.startswith('https:'): todisplay = tags.link_to(self.displayval, self.displayval) else: todisplay = self.displayval return HTML.span(todisplay, **self._static_attributes())
def __call__(self, repo_name, rev, paths): url_l = [link_to(repo_name, url('files_home', repo_name=repo_name, revision=rev, f_path=''), class_='ypjax-link')] paths_l = paths.split('/') for cnt, p in enumerate(paths_l): if p != '': url_l.append(link_to(p, url('files_home', repo_name=repo_name, revision=rev, f_path='/'.join(paths_l[:cnt + 1]) ), class_='ypjax-link' ) ) return literal('/'.join(url_l))
def init(self): self.add_text('widget_type', 'Type', required=True) self.add_text('color', 'Color', required=True) self.add_text('quantity', 'Quantity', required=True) sg = self.add_elgroup('submit-group', class_='submit-only') sg.add_submit('submit') cancel_url = link_to('Cancel', url_for('WidgetCrud', action='manage'), title='Go back to the manage page') sg.add_static('cancel', None, cancel_url)
def add_submit(self, crud_view=None): sg = self.add_elgroup('submit-group', class_='submit-only') sg.add_submit('submit') crud_view = crud_view or self.__class__.__name__ + 'Crud' sg.add_static( 'cancel', None, link_to('Cancel', url_for(crud_view, action='manage'), title='Go back to the manage page')) return sg
def extract_data(self, rec): edit_link = link_to('(edit)', url_for( self.endpoint, action='edit', objid=rec.id, session_key=self.grid.session_key, ), class_='edit_link', title='edit record') return literal(edit_link)
def extract_data(self, rec): edit_link = link_to('(edit)', url_for( self.endpoint, action='edit', objid=rec.id, session_key=self.grid.session_key, ), class_='edit_link', title='edit record') delete_link = link_to('(delete)', url_for( self.endpoint, action='delete', objid=rec.id, session_key=self.grid.session_key, ), class_='delete_link', title='delete record') links = [delete_link, edit_link] return literal(''.join(links))
def get_pull_request(): from kallithea.model.db import PullRequest pull_request_id = action_params nice_id = PullRequest.make_nice_id(pull_request_id) deleted = user_log.repository is None if deleted: repo_name = user_log.repository_name else: repo_name = user_log.repository.repo_name return link_to(_('Pull request %s') % nice_id, url('pullrequest_show', repo_name=repo_name, pull_request_id=pull_request_id))
def extract_data(self, rec): edit_link = '' if self.has_edit: edit_link = link_to('(edit)', url_for(self.grid.endpoint, action='edit', objid=rec.id, session_key=self.grid.session_key), class_='edit_link', title='edit record') delete_link = '' if self.has_delete: delete_link = link_to('(delete)', url_for( self.grid.endpoint, action='delete', objid=rec.id, session_key=self.grid.session_key), class_='delete_link', title='delete record') return literal('{0}{1}'.format( delete_link, edit_link, ))
def url_func(changeset): author = escape(changeset.author) date = changeset.date message = escape(changeset.message) tooltip_html = ("<b>Author:</b> %s<br/>" "<b>Date:</b> %s</b><br/>" "<b>Message:</b> %s") % (author, date, message) lnk_format = show_id(changeset) uri = link_to( lnk_format, url('changeset_home', repo_name=repo_name, revision=changeset.raw_id), style=get_color_string(changeset.raw_id), **{'data-toggle': 'popover', 'data-content': tooltip_html} ) uri += '\n' return uri
def get_fork_name(): repo_name = action_params url_ = url('summary_home', repo_name=repo_name) return _('Fork name %s') % link_to(action_params, url_)
def html_link(obj): import flask return link_to(obj.name, flask.url_for(endpoint, objid=obj.id))
def options_td(self, col_num, i, item): u = url( "/tickets/view", ticket_id=item.id, y=self.additional_kw["context"]["y"] ) a = link_to(item.options, u) return HTML.td(a)
def html_link(obj): return link_to(obj.username, flask.url_for(endpoint, objid=obj.id))