Skip to content

Commit

Permalink
Convert custom section order to int [fix #212]
Browse files Browse the repository at this point in the history
  • Loading branch information
psss committed Dec 2, 2019
1 parent 0009a65 commit 485cabd
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion did/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,14 @@ def configured_plugins(self, config):
user = self.user.clone(section) if self.user else None
statsgroup = StatsGroupPlugin.registry[type_]
obj = statsgroup(option=section, parent=self, user=user)
obj.order = data.get("order", statsgroup.order)
# Override default order if requested
if 'order' in data:
try:
obj.order = int(data['order'])
except ValueError:
raise did.base.GeneralError(
f"Invalid order '{data['order']}' "
f"in the '{section}' section.")
results.append(obj)
return sorted(results, key=lambda x: x.order)

Expand Down

0 comments on commit 485cabd

Please sign in to comment.