示例#1
0
def format_profile(self, request, obj, fieldname, *args, **kwargs):
    """IF user has a profile page return a link to it"""
    existing_profile = current_app.db.index.find_one(
        {'content_type': 'block', 'slug': slugify(obj.get('fullname'))}
    )
    if existing_profile:
        edit_url = url_for(
            'quokka.core.content.admin.blockview.edit_view',
            id=existing_profile['_id']
        )
        view_url = url_for(
            'quokka.core.content.author',
            author=existing_profile['slug']
        )
        edit_link = html.a(href=edit_url, target='_blank')(
            html.i(class_="icon fa fa-pencil glyphicon glyphicon-pencil",
                   style="margin-right: 5px;")(),
            'Edit Profile'
        )
        view_link = html.a(href=view_url, target='_blank')(
            html.i(class_="icon fa fa-globe glyphicon glyphicon-globe",
                   style="margin-right: 5px;")(),
            'View Profile'
        )
        return html.div()(
            html.span()(edit_link),
            Markup(' '),
            html.span()(view_link)
        )
示例#2
0
def format_link(self, request, obj, fieldname, *args, **kwars):
    """Format a link from the model"""
    model = make_model(obj)
    value = getattr(model, fieldname)
    return html.a(href=value, title=value,
                  target='_blank')(html.i(class_="icon  icon-resize-small",
                                          style="margin-right: 5px;")())
示例#3
0
def format_link(self, request, obj, fieldname, *args, **kwars):
    """Format a link from the model"""
    model = make_model(obj)
    value = getattr(model, fieldname)
    return html.a(href=value, title=value, target='_blank')(
        html.i(class_="icon  icon-resize-small",
               style="margin-right: 5px;")()
    )
示例#4
0
def format_view_on_site(self, request, obj, fieldname, *args, **kwargs):
    """Returns button to view or preview depending on content status"""
    model = make_model(obj)
    return html.a(
        href=model.external_url,
        target='_blank',
    )(html.i(class_="icon fa fa-globe glyphicon glyphicon-globe",
             style="margin-right: 5px;")(),
      'View' if model.published else 'Preview')
示例#5
0
def view_on_site(self, request, obj, fieldname, *args, **kwargs):
    available = obj.is_available
    endpoint = kwargs.pop(
        'endpoint',
        'flaskpress.core.detail' if available else 'flaskpress.core.preview')
    return html.a(
        href=obj.get_absolute_url(endpoint),
        target='_blank',
    )(html.i(class_="icon icon-eye-open", style="margin-right: 5px;")(),
      _l('View on site') if available else _l('Preview on site'))
示例#6
0
def view_on_site(self, request, obj, fieldname, *args, **kwargs):
    available = obj.is_available
    endpoint = kwargs.pop(
        'endpoint',
        'quokka.core.detail' if available else 'quokka.core.preview'
    )
    return html.a(
        href=obj.get_absolute_url(endpoint),
        target='_blank',
    )(html.i(class_="icon icon-eye-open", style="margin-right: 5px;")(),
      _l('View on site') if available else _l('Preview on site'))
示例#7
0
def format_link(self, request, obj, fieldname, *args, **kwars):
    value = getattr(obj, fieldname)
    return html.a(href=value, title=value, target='_blank')(
        html.i(class_="icon  icon-resize-small",
               style="margin-right: 5px;")()
    )
示例#8
0
def format_link(self, request, obj, fieldname, *args, **kwars):
    value = getattr(obj, fieldname)
    return html.a(href=value, title=value,
                  target='_blank')(html.i(class_="icon  icon-resize-small",
                                          style="margin-right: 5px;")())