This repository has been archived by the owner on Oct 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Groundwork for list submissions command (#483)
* ⬆️ update dependencies * 🚧 add first stages of submission list command
- Loading branch information
1 parent
092fc2b
commit a97f1e0
Showing
7 changed files
with
117 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import zoneinfo | ||
from datetime import datetime | ||
from uuid import uuid4 | ||
|
||
from slack.web.classes.blocks import * | ||
from slack.web.classes.elements import * | ||
from slack.web.classes.views import View | ||
|
||
from blossom.api.slack import client | ||
from blossom.strings import translation | ||
|
||
i18n = translation() | ||
|
||
|
||
def _build_message() -> View: | ||
"""Create the modal view that will display in Slack. | ||
Action IDs: | ||
* submission_list_username_input | ||
* submission_list_select_start_date | ||
* submission_list_select_end_date | ||
""" | ||
return View( | ||
type="modal", | ||
title="Get Submissions", | ||
submit=PlainTextObject(text="Submit"), | ||
close=PlainTextObject(text="Close"), | ||
blocks=[ | ||
SectionBlock( | ||
fields=[ | ||
TextObject( | ||
type="mrkdwn", | ||
text=( | ||
"Select the date range to search for transcriptions in. Keep in mind" | ||
" that if your date range is too big, there might be a lot of returned" | ||
" transcriptions." | ||
), | ||
) | ||
] | ||
), | ||
InputBlock( | ||
label="Username", | ||
element=PlainTextInputElement( | ||
placeholder="itsthejoker", action_id="submission_list_username_input" | ||
), | ||
), | ||
SectionBlock( | ||
accessory=DatePickerElement( | ||
initial_date="2017-04-01", | ||
placeholder=PlainTextObject(text="Start Date:"), | ||
action_id="submission_list_select_start_date", | ||
) | ||
), | ||
SectionBlock( | ||
accessory=DatePickerElement( | ||
initial_date=datetime.now(tz=zoneinfo.ZoneInfo("UTC")).strftime("%Y-%m-%d"), | ||
placeholder=PlainTextObject(text="End Date:"), | ||
action_id="submission_list_select_end_date", | ||
) | ||
), | ||
], | ||
) | ||
|
||
|
||
def _process_submission_list(data: dict) -> None: | ||
from pprint import pprint | ||
|
||
pprint(data) | ||
|
||
|
||
def submissions_cmd(channel: str, _message: str) -> None: | ||
"""Get information from a date range about submissions of a user.""" | ||
client.views_open(trigger_id=uuid4(), view=_build_message()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/usr/bin/env python3 | ||
# https://shiv.readthedocs.io/en/latest/#preamble | ||
import os | ||
import shutil | ||
from pathlib import Path | ||
|
||
# These variables are injected by shiv.bootstrap | ||
site_packages: Path | ||
env: "shiv.bootstrap.environment.Environment" | ||
|
||
# Get a handle of the current PYZ's site_packages directory | ||
current = site_packages.parent | ||
|
||
# The parent directory of the site_packages directory is our shiv cache | ||
cache_path = current.parent | ||
|
||
|
||
name, build_id = current.name.split("_") | ||
|
||
if __name__ == "__main__": | ||
for path in cache_path.iterdir(): | ||
if path.name.startswith(f"{name}_") and not path.name.endswith(build_id): | ||
shutil.rmtree(path) | ||
if path.name.startswith(f".{name}") and not path.name.endswith(f"{build_id}_lock"): | ||
os.remove(path) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.