Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various fixes and features #75

Merged
merged 37 commits into from
Jan 6, 2025
Merged
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
d67b9a2
Make the interface a bit more "brutalist"
tamuri Dec 6, 2024
0917e76
Add handler to drop into REPL
tamuri Dec 6, 2024
539ebac
Add condition to check sort isn't activated to allow 'ss' to sort asc…
tamuri Dec 6, 2024
f061c83
Add readline and some history to make filter easier to use
tamuri Dec 6, 2024
0dc5d5a
Tidy up comparison function, create and return result if we don't hav…
tamuri Dec 6, 2024
16838c8
Many tournament references a bit clearer
tamuri Dec 6, 2024
de9d59c
ruff format
tamuri Dec 6, 2024
f48889b
Minor improvements for clarity
tamuri Dec 7, 2024
5240896
Fix errors from static analysis
tamuri Dec 7, 2024
10eb74b
readkeys not used
tamuri Dec 7, 2024
6a63ff3
Fix some type errors
tamuri Dec 7, 2024
952993c
Print a message whether shortlist was restored or created
tamuri Dec 7, 2024
95453c1
Rationalise applicants table view and put collect context variables t…
tamuri Dec 7, 2024
90b2032
Tidy up context
tamuri Dec 7, 2024
499fe97
Loop with enumerate so user can filter by number
tamuri Dec 8, 2024
2897fb4
Add filtering help
tamuri Dec 8, 2024
b4151a4
Add `total_score` example
tamuri Dec 8, 2024
2545d45
Add an interactive sorter and add it as a sort option
tamuri Dec 8, 2024
a54a822
Add table legend and option to redisplay applicant (e.g. if scrolls o…
tamuri Dec 9, 2024
9946633
Improve display of applicants comparison sorting
tamuri Dec 9, 2024
a05be3e
Use pywebview to display applicant PDFs
tamuri Dec 9, 2024
9f09673
Serving httpd in thread (for serving pdf.js)
tamuri Dec 10, 2024
00126de
present pdfs in webview window using pdf.js
tamuri Dec 10, 2024
35f53bf
tidy-up webview usage
tamuri Dec 10, 2024
97e22fb
change to always open in external viewer
tamuri Dec 10, 2024
f56af3b
don't override built-in keyword `object`
tamuri Dec 10, 2024
8a2ad5b
Remove unused argument
tamuri Dec 10, 2024
cda256e
Fix imports
tamuri Dec 10, 2024
41de72d
Small linter fixes
tamuri Dec 10, 2024
ca92732
Catch more specific errors for eval
tamuri Dec 10, 2024
d9974da
Add docstring
tamuri Dec 10, 2024
263fe35
Slightly dim background of start page
tamuri Dec 10, 2024
2a138b3
Only listen on loopback
tamuri Dec 10, 2024
bf6c179
use keyword arguments clarity
tamuri Dec 10, 2024
b5d0df0
webview might not be available, so we can't load things from shortlis…
tamuri Dec 11, 2024
f83e490
use a better word (than the word I made up - unretrievable)
tamuri Dec 11, 2024
4b1c15f
Add pdfjs-4.9.155-dist
tamuri Dec 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions shortlister/controller.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import string
from dataclasses import dataclass
from enum import Enum
from pathlib import Path
import readline
Expand Down Expand Up @@ -32,13 +33,15 @@
class ViewWidth(Enum):
NARROW, WIDE = 1, 2

@dataclass
class Context:
applicants: list[Applicant]
applicant_index: int
criterion: Criterion
table_view: ViewWidth
applicants: list[Applicant] # selected applicants
applicant_index: int # selected applicant
criterion: Criterion | None # selected criterion to score
table_view: ViewWidth # selected applicants' table view
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Putting these variable into a separate class makes the code so much more cleaner!


class Controller:

def __init__(self, path):
self.path = path
self.shortlist, msg = load_shortlist(path)
Expand All @@ -50,11 +53,12 @@ def __init__(self, path):
self.available_keys = string.digits + string.ascii_letters

# application context
self.ctx = Context()
self.ctx.applicants = self.shortlist.applicants
self.ctx.applicant_index: int = 0
self.ctx.criterion = None
self.ctx.table_view = ViewWidth.WIDE
self.ctx = Context(
self.shortlist.applicants,
0,
None,
ViewWidth.WIDE
)

# add common filtering commands to readline history for easy access
readline.add_history('score(applicant, "criterion-name", "score")')
Expand Down