示例#1
0
class HelpersReferenceDatatableView(DemoMixin, XEditableDatatableView):
    """
    ``datatableview.helpers`` is a module decidated to functions that can be supplied directly as
    column callback functions.  Some of them are easy to use at runtime in your own callbacks,
    making some work easier for you, but the majority aim to solve common problems with as little
    fuss as possible.
    """
    model = Entry
    datatable_options = {
        'columns': [
            ("ID", 'id', helpers.link_to_model),
            ("Blog", 'blog__name',
             helpers.link_to_model(key=lambda instance: instance.blog)),
            ("Headline", 'headline', helpers.make_xeditable),
            ("Body Text", 'body_text', helpers.itemgetter(slice(0, 30))),
            ("Publication Date", 'pub_date',
             helpers.format_date('%A, %b %d, %Y')),
            ("Modified Date", 'mod_date'),
            ("Age", 'pub_date', helpers.through_filter(timesince)),
            ("Interaction", 'get_interaction_total',
             helpers.make_boolean_checkmark),
            ("Comments", 'n_comments', helpers.format("{0:,}")),
            ("Pingbacks", 'n_pingbacks', helpers.format("{0:,}")),
        ],
    }

    implementation = u"""
示例#2
0
 def get_author_names_as_links(self, instance, *args, **kwargs):
     return ", ".join([helpers.link_to_model(author) for author in instance.authors.all()])
示例#3
0
 def get_tenant_as_link(self, instance, *args, **kwargs):
     return helpers.link_to_model(instance.tenant, text=instance.tenant.name)
示例#4
0
 def get_author_names_as_links(self, instance, *args, **kwargs):
     return ", ".join([
         helpers.link_to_model(author) for author in instance.authors.all()
     ])
    def get_column_Edit_data(self, instance, *args, **kwargs):
    # Simplest use, "text" will be the unicode of instance.blog
        #return helpers.link_to_model(instance)

    # Specify a custom text
        return helpers.link_to_model(instance, text="Edit")