@@ -62,15 +62,15 @@ def column_for_field(self, field, **kwargs):
62
62
63
63
64
64
class LinkTransform :
65
- """Object used to generate attributes for the `<a>`-tag to wrap the cell content in."""
66
-
67
65
viewname = None
68
66
accessor = None
69
67
attrs = None
70
68
71
69
def __init__ (self , url = None , accessor = None , attrs = None , reverse_args = None ):
72
70
"""
73
- arguments:
71
+ Object used to generate attributes for the `<a>`-tag to wrap the cell content in.
72
+
73
+ Arguments:
74
74
url (callable): If supplied, the result of this callable will be used as ``href`` attribute.
75
75
accessor (Accessor): if supplied, the accessor will be used to decide on which object
76
76
``get_absolute_url()`` is called.
@@ -120,9 +120,7 @@ def compose_url(self, **kwargs):
120
120
return context .get_absolute_url ()
121
121
122
122
def call_reverse (self , record ):
123
- """
124
- Prepares the arguments to reverse() for this record and calls reverse()
125
- """
123
+ """Prepare the arguments to reverse() for this record and calls reverse()."""
126
124
127
125
def resolve_if_accessor (val ):
128
126
return val .resolve (record ) if isinstance (val , Accessor ) else val
@@ -393,7 +391,7 @@ def order(self, queryset, is_descending):
393
391
table or by subclassing `.Column`; but only overrides if second element
394
392
in return tuple is True.
395
393
396
- returns :
394
+ Returns :
397
395
Tuple (QuerySet, boolean)
398
396
"""
399
397
return (queryset , False )
@@ -404,7 +402,9 @@ def from_field(cls, field, **kwargs):
404
402
Return a specialized column for the model field or `None`.
405
403
406
404
Arguments:
407
- field (Model Field instance): the field that needs a suitable column
405
+ field (Model Field instance): the field that needs a suitable column.
406
+ **kwargs: passed on to the column.
407
+
408
408
Returns:
409
409
`.Column` object or `None`
410
410
@@ -429,7 +429,7 @@ class BoundColumn:
429
429
In practice, this means that a `.BoundColumn` knows the *"variable name"* given to the `.Column`
430
430
when it was declared on the `.Table`.
431
431
432
- arguments :
432
+ Arguments :
433
433
table (`~.Table`): The table in which this column exists
434
434
column (`~.Column`): The type of column
435
435
name (str): The variable name of the column used when defining the
@@ -465,7 +465,6 @@ def attrs(self):
465
465
templates easier. ``tf`` is not actually a HTML tag, but this key name
466
466
will be used for attributes for column's footer, if the column has one.
467
467
"""
468
-
469
468
# prepare kwargs for computed_values()
470
469
kwargs = {"table" : self ._table , "bound_column" : self }
471
470
# BoundRow.items() sets current_record and current_value when iterating over
@@ -503,25 +502,19 @@ def attrs(self):
503
502
return attrs
504
503
505
504
def _get_cell_class (self , attrs ):
506
- """
507
- Return a set of the classes from the class key in ``attrs``.
508
- """
505
+ """Return a set of the classes from the class key in ``attrs``."""
509
506
classes = attrs .get ("class" , None )
510
507
classes = set () if classes is None else set (classes .split (" " ))
511
508
512
509
return self ._table .get_column_class_names (classes , self )
513
510
514
511
def get_td_class (self , td_attrs ):
515
- """
516
- Returns the HTML class attribute for a data cell in this column
517
- """
512
+ """Return the HTML class attribute for a data cell in this column."""
518
513
classes = sorted (self ._get_cell_class (td_attrs ))
519
514
return None if len (classes ) == 0 else " " .join (classes )
520
515
521
516
def get_th_class (self , th_attrs ):
522
- """
523
- Returns the HTML class attribute for a header cell in this column
524
- """
517
+ """Return the HTML class attribute for a header cell in this column."""
525
518
classes = self ._get_cell_class (th_attrs )
526
519
527
520
# add classes for ordering
@@ -539,7 +532,7 @@ def get_th_class(self, th_attrs):
539
532
540
533
@property
541
534
def default (self ):
542
- """Returns the default value for this column."""
535
+ """Return the default value for this column."""
543
536
value = self .column .default
544
537
if value is None :
545
538
value = self ._table .default
@@ -698,7 +691,7 @@ def visible(self):
698
691
699
692
@property
700
693
def localize (self ):
701
- """Return `True`, `False` or `None` as described in ``Column.localize``"""
694
+ """Return `True`, `False` or `None` as described in ``Column.localize``. """
702
695
return self .column .localize
703
696
704
697
@@ -742,10 +735,7 @@ def names(self):
742
735
return list (self .iternames ())
743
736
744
737
def iterall (self ):
745
- """
746
- Return an iterator that exposes all `.BoundColumn` objects,
747
- regardless of visibility or sortability.
748
- """
738
+ """Return an iterator that exposes all `.BoundColumn` objects, regardless of visibility or sortability."""
749
739
return (column for name , column in self .iteritems ())
750
740
751
741
def all (self ):
@@ -759,7 +749,6 @@ def iteritems(self):
759
749
consideration all of the ordering and filtering modifiers that a table
760
750
supports (e.g. `~Table.Meta.exclude` and `~Table.Meta.sequence`).
761
751
"""
762
-
763
752
for name in self ._table .sequence :
764
753
if name not in self ._table .exclude :
765
754
yield (name , self .columns [name ])
@@ -769,7 +758,7 @@ def items(self):
769
758
770
759
def iterorderable (self ):
771
760
"""
772
- Same as `BoundColumns.all` but only returns orderable columns .
761
+ `BoundColumns.all` filtered for whether they can be ordered .
773
762
774
763
This is useful in templates, where iterating over the full
775
764
set and checking ``{% if column.ordarable %}`` can be problematic in
@@ -780,7 +769,7 @@ def iterorderable(self):
780
769
781
770
def itervisible (self ):
782
771
"""
783
- Same as `.iterorderable` but only returns visible `.BoundColumn` objects .
772
+ Return `.iterorderable` filtered by visibility .
784
773
785
774
This is geared towards table rendering.
786
775
"""
@@ -805,7 +794,7 @@ def show(self, name):
805
794
self .columns [name ].column .visible = True
806
795
807
796
def __iter__ (self ):
808
- """Convenience API, alias of `.itervisible`."""
797
+ """Alias of `.itervisible` (for convenience) ."""
809
798
return self .itervisible ()
810
799
811
800
def __contains__ (self , item ):
0 commit comments