Skip to content

Commit

Permalink
Merge pull request #14 from BA-OST-Index/dev
Browse files Browse the repository at this point in the history
StoryInfo interpage (through ReferenceData) support
  • Loading branch information
sctop authored Jan 6, 2024
2 parents 1075e55 + 77aa0b4 commit 31c7e5b
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
5 changes: 5 additions & 0 deletions data_model/actual_data/reference_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ def check_data_loaded(self):
if not self.is_data_loaded():
raise RuntimeError

@property
def ref_instance(self):
self.check_data_loaded()
return self._ref_instance


class ReferenceFile(FileLoader, InterpageMixin, IParentData):
_instance = {}
Expand Down
21 changes: 21 additions & 0 deletions data_model/actual_data/story.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from ._story.story_source_all import StoryInfoSource
from ..tool.parent_data import IParentData
from ..tool.interpage import InterpageMixin
from .reference_data import ReferenceData
from collections import OrderedDict


Expand Down Expand Up @@ -213,6 +214,26 @@ def _get_instance_offset(self, offset: int):

return instance

@property
def interpage_prev(self):
try:
self.data["interpage"]["prev"]
except KeyError:
return super().interpage_prev
else:
ref_data = self.data["interpage"]["prev"]
return ReferenceData(ref_data["module_name"], ref_data["model_name"], ref_data["instance_id"]).ref_instance

@property
def interpage_next(self):
try:
self.data["interpage"]["next"]
except KeyError:
return super().interpage_next
else:
ref_data = self.data["interpage"]["next"]
return ReferenceData(ref_data["module_name"], ref_data["model_name"], ref_data["instance_id"]).ref_instance


class StoryInfoBond(FileLoader, IParentData, InterpageMixin):
"""Basically a modified class from StoryInfo"""
Expand Down

0 comments on commit 31c7e5b

Please sign in to comment.