Skip to content

Commit

Permalink
Add reset/activate/deactivate tag function
Browse files Browse the repository at this point in the history
  • Loading branch information
foolcage committed Jul 11, 2024
1 parent 743cba6 commit 6358693
Show file tree
Hide file tree
Showing 6 changed files with 167 additions and 189 deletions.
3 changes: 2 additions & 1 deletion src/zvt/fill_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ def gen_kdata_schemas():
# gen_exports('trader')
# gen_exports('autocode')
# gen_exports("zhdate")
gen_exports("recorders", export_from_package=True)
# gen_exports("recorders", export_from_package=True)
gen_exports("tag", export_from_package=False)
# gen_kdata_schemas()
# zip_dir(ZVT_TEST_DATA_PATH, zip_file_name=DATA_SAMPLE_ZIP_PATH)
2 changes: 1 addition & 1 deletion src/zvt/rest/work.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ def activate_sub_tags(activate_sub_tags_model: ActivateSubTagsModel):
Activate sub tags
"""

return tag_service.activate_main_tag_by_sub_tags(activate_sub_tags_model=activate_sub_tags_model)
return tag_service.activate_sub_tags(activate_sub_tags_model=activate_sub_tags_model)


@work_router.post("/batch_set_stock_tags", response_model=List[StockTagsModel])
Expand Down
1 change: 1 addition & 0 deletions src/zvt/tag/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-#


# the __all__ is generated
__all__ = []
1 change: 1 addition & 0 deletions src/zvt/tag/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class StockPoolType(Enum):


class TagType(Enum):
#: A tag is a main tag due to its extensive capacity.
main_tag = "main_tag"
sub_tag = "sub_tag"
hidden_tag = "hidden_tag"
Expand Down
6 changes: 3 additions & 3 deletions src/zvt/tag/tag_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ class SetStockTagsModel(CustomModel):
entity_id: str
main_tag: str
main_tag_reason: Optional[str] = None
sub_tag: Union[str, None]
sub_tag: Optional[str] = None
sub_tag_reason: Optional[str] = None
active_hidden_tags: Union[Dict[str, str], None]
active_hidden_tags: Optional[Dict[str, str]] = None

@field_validator("main_tag")
@classmethod
Expand All @@ -85,7 +85,7 @@ def main_tag_must_be_in(cls, v: str) -> str:
@field_validator("sub_tag")
@classmethod
def sub_tag_must_be_in(cls, v: str) -> str:
if v not in get_sub_tags():
if v and (v not in get_sub_tags()):
raise ValueError(f"sub_tag: {v} must be created at sub_tag_info at first")
return v

Expand Down
Loading

0 comments on commit 6358693

Please sign in to comment.