diff --git a/src/character/models/capabilities.py b/src/character/models/capabilities.py index 6743997..3de2b79 100644 --- a/src/character/models/capabilities.py +++ b/src/character/models/capabilities.py @@ -65,7 +65,7 @@ class Path(DocumentedModel, UniquelyNamedModel, TimeStampedModel, models.Model): return None def get_next_capability(self, character) -> Capability: - next_rank = character.capabilities.filter(path=self).count() + 1 + next_rank = self.max_rank(character) + 1 return self.capabilities.get(rank=next_rank) def has_next_capability(self, character) -> bool: @@ -75,6 +75,9 @@ class Path(DocumentedModel, UniquelyNamedModel, TimeStampedModel, models.Model): except Capability.DoesNotExist: return False + def max_rank(self, character) -> int: + return character.capabilities.filter(path=self).count() + class CapabilityManager(models.Manager): def get_by_natural_key(self, path, rank): diff --git a/src/character/templates/character/path.html b/src/character/templates/character/path.html index 1d6bc30..99cf0d2 100644 --- a/src/character/templates/character/path.html +++ b/src/character/templates/character/path.html @@ -1,22 +1,24 @@ {% load character_extras %} -
+
- {{ path.display_name }} - - {% if path|has_next_capability:character %} - - {% endif %} + {% if path|has_next_capability:character %} + + {% endif %} +
{% if path.notes %}
{{ path.notes }}
diff --git a/src/character/templatetags/character_extras.py b/src/character/templatetags/character_extras.py index 44b5dfb..d3915d6 100644 --- a/src/character/templatetags/character_extras.py +++ b/src/character/templatetags/character_extras.py @@ -32,3 +32,8 @@ def weapon_modifier(character: Character, weapon: Weapon): @register.filter def has_next_capability(path: Path, character: Character) -> bool: return path.has_next_capability(character) + + +@register.filter +def max_rank(path: Path, character: Character) -> int: + return path.max_rank(character)