Skip to content

Commit

Permalink
fix(apis_relations): reuse GenericTable.Meta.sequence for tables
Browse files Browse the repository at this point in the history
This way we use the same order of fields as in the other tables
inheriting from GenericTable.

Closes: #716
  • Loading branch information
b1rger committed Mar 22, 2024
1 parent 6b2fb49 commit b15e587
Showing 1 changed file with 4 additions and 14 deletions.
18 changes: 4 additions & 14 deletions apis_core/apis_relations/tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ class TripleTable(GenericTable):
subj = tables.Column(linkify=True)
obj = tables.Column(linkify=True)

class Meta:
class Meta(GenericTable.Meta):
fields = ["id", "subj", "prop", "obj"]
exclude = ["desc"]
sequence = ("id", "subj", "prop", "obj", "...")
sequence = tuple(fields) + GenericTable.Meta.sequence


class SubjObjColumn(tables.ManyToManyColumn):
Expand Down Expand Up @@ -63,21 +63,11 @@ class PropertyTable(GenericTable):
subject = SubjObjColumn(accessor="subj_class", verbose_name="Subject")
object = SubjObjColumn(accessor="obj_class", verbose_name="Object")

class Meta:
class Meta(GenericTable.Meta):
fields = ["subject", "predicate", "object", "predicate_reverse"]
order_by = "predicate"
exclude = ["desc"]

def __init__(self, *args, **kwargs):
if "sequence" not in kwargs:
kwargs["sequence"] = [
"subject",
"predicate",
"object",
"predicate_reverse",
"...",
]
super().__init__(*args, **kwargs)
sequence = tuple(fields) + GenericTable.Meta.sequence

# Use order_ methods to define how individual columns should be sorted.
# Method names are column names prefixed with "order_".
Expand Down

0 comments on commit b15e587

Please sign in to comment.