Skip to content

Commit

Permalink
adds option to select entities via query parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
tholzheim committed Dec 17, 2024
1 parent 9bafee7 commit ff36b5c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ authors = [
maintainers = [
{name = "Tim Holzheim", email = "[email protected]"},
]
version = "0.0.16"
version = "0.0.17"
readme = "README.md"
license= "Apache-2.0"
dependencies = [
Expand Down
7 changes: 5 additions & 2 deletions src/wikibasemigrator/web/webserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,14 @@ async def login_via_wiki(request: Request):
return response

@ui.page("/")
async def main_page(client: Client) -> None:
async def main_page(client: Client, entities: str | None = None) -> None:
await client.connected()
profile = self.get_profile()
user = await self.get_user()
WikibaseControllerPage(profile, self.get_icon_path(), user=user).setup_ui()
controller_page = WikibaseControllerPage(profile, self.get_icon_path(), user=user)
controller_page.setup_ui()
if entities is not None:
controller_page.select_entities(entities)

@ui.page("/config")
async def config_page(client: Client) -> None:
Expand Down
13 changes: 13 additions & 0 deletions src/wikibasemigrator/web/wikibase_controller_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from wikibasemigrator.model.migration_mark import MigrationMark
from wikibasemigrator.model.profile import WikibaseMigrationProfile
from wikibasemigrator.model.translations import EntitySetTranslationResult
from wikibasemigrator.web.item_selectors import ItemSelectorElement
from wikibasemigrator.web.migration_view import MigrationView
from wikibasemigrator.web.oauth import MediaWikiUserIdentity
from wikibasemigrator.web.selection_view import SelectionView
Expand Down Expand Up @@ -85,6 +86,18 @@ def setup_view_container(self) -> None:
else:
self.selection_view.setup_ui()

def select_entities(self, entities: str):
"""
Add given entities to the list of entities selected.
:param entities:
:return:
"""
selector_id = 1
self.selection_view.switch_to_selector(selector_id)
selector = self.selection_view.selectors.get(selector_id)
if isinstance(selector, ItemSelectorElement):
selector.value = entities

def requires_login(self) -> bool:
"""
Check if user login is required
Expand Down

0 comments on commit ff36b5c

Please sign in to comment.