Skip to content

Add new board to TOML & improve the board logic #439

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
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
120 changes: 94 additions & 26 deletions docs/operations/boards.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,40 +12,108 @@ Kanonickým zdrojem pravdy je ale `výpis na justice.cz <https://or.justice.cz/i



Nově zvolený výbor
------------------

.. list-table::
:header-rows: 1

* * Jméno
* GitHub
* Funkce
* * Jakub Vysoký
* `@kvbik <https://github.com/kvbik>`_
*
* * Jan Čermák
* `@sairon <https://github.com/sairon>`_
* |:moneybag:|
* * Karolina Surma
* `@befeleme <https://github.com/befeleme>`_
* |:crown:|
* * Petr Viktorin
* `@encukou <https://github.com/encukou>`_
*
* * Jakub Červinka
* `@JakubDotPy <https://github.com/JakubDotPy>`_
*

Výbor od 9.4.2022
-------------------------------------------------

.. csv-table::
:header: "Jméno", "GitHub", "Funkce"

Barbora Drbohlavová, `@baradrb <https://github.com/baradrb>`_, |:crown:|
Anežka Müller, `@anezkamll <https://github.com/anezkamll>`_,
Jan Javorek, `@honzajavorek <https://github.com/honzajavorek>`_,
Jakub Vysoký, `@kvbik <https://github.com/kvbik>`_,
Jan Čermák, `@sairon <https://github.com/sairon>`_, |:moneybag:|
.. list-table::
:header-rows: 1

* * Jméno
* GitHub
* Funkce
* * Barbora Drbohlavová
* `@baradrb <https://github.com/baradrb>`_
* |:crown:|
* * Anežka Müller
* `@anezkamll <https://github.com/anezkamll>`_
*
* * Jan Javorek
* `@honzajavorek <https://github.com/honzajavorek>`_
*
* * Jakub Vysoký
* `@kvbik <https://github.com/kvbik>`_
*
* * Jan Čermák
* `@sairon <https://github.com/sairon>`_
* |:moneybag:|

Výbor od 8.4.2019
-------------------------------------------------

.. csv-table::
:header: "Jméno", "GitHub", "Funkce"

Martin Bílek, `@martinbilek <https://github.com/martinbilek>`_, |:crown:| |:moneybag:|
Aleš Zoulek, `@aleszoulek <https://github.com/aleszoulek>`_,
Jan Javorek, `@honzajavorek <https://github.com/honzajavorek>`_,
Jakub Vysoký, `@kvbik <https://github.com/kvbik>`_,
Jiří Bartoň, `@whiskybar <https://github.com/whiskybar>`_,
.. list-table::
:header-rows: 1

* * Jméno
* GitHub
* Funkce
* * Martin Bílek
* `@martinbilek <https://github.com/martinbilek>`_
* |:crown:| |:moneybag:|
* * Aleš Zoulek
* `@aleszoulek <https://github.com/aleszoulek>`_
*
* * Jan Javorek
* `@honzajavorek <https://github.com/honzajavorek>`_
*
* * Jakub Vysoký
* `@kvbik <https://github.com/kvbik>`_
*
* * Jiří Bartoň
* `@whiskybar <https://github.com/whiskybar>`_
*

Výbor od 27.3.2012
-------------------------------------------------

.. csv-table::
:header: "Jméno", "GitHub", "Funkce"

Martin Bílek, `@martinbilek <https://github.com/martinbilek>`_, |:crown:| |:moneybag:|
Aleš Zoulek, `@aleszoulek <https://github.com/aleszoulek>`_,
Robin Gottfried, `@czervenka <https://github.com/czervenka>`_,
Jan Král, `@honzakral <https://github.com/honzakral>`_,
Jakub Vysoký, `@kvbik <https://github.com/kvbik>`_,
Jiří Bartoň, `@whiskybar <https://github.com/whiskybar>`_,
Vítězslav Pliska, `@whit <https://github.com/whit>`_,
.. list-table::
:header-rows: 1

* * Jméno
* GitHub
* Funkce
* * Martin Bílek
* `@martinbilek <https://github.com/martinbilek>`_
* |:crown:| |:moneybag:|
* * Aleš Zoulek
* `@aleszoulek <https://github.com/aleszoulek>`_
*
* * Robin Gottfried
* `@czervenka <https://github.com/czervenka>`_
*
* * Jan Král
* `@honzakral <https://github.com/honzakral>`_
*
* * Jakub Vysoký
* `@kvbik <https://github.com/kvbik>`_
*
* * Jiří Bartoň
* `@whiskybar <https://github.com/whiskybar>`_
*
* * Vítězslav Pliska
* `@whit <https://github.com/whit>`_
*
29 changes: 23 additions & 6 deletions docs/operations/boards.rst.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,29 @@ Kanonickým zdrojem pravdy je ale `výpis na justice.cz <https://or.justice.cz/i


{% for board in boards %}
{%- if board.start_on == None %}
Nově zvolený výbor
------------------
{%- else %}
Výbor od {{ board.start_on.strftime("%-d.%-m.%Y") }}
-------------------------------------------------

.. csv-table::
:header: "Jméno", "GitHub", "Funkce"
{% for member in board.members %}
{{ member.name }}, `@{{ member.github }} <https://github.com/{{ member.github }}>`_, {% if member.is_chair %}|:crown:| {% endif %}{% if member.is_treasurer %}|:moneybag:| {% endif %}
{%- endfor %}
{%- endif %}

.. list-table::
:header-rows: 1

* * Jméno
* GitHub
* Funkce
{%- for member in board.members %}
* * {{ member.name }}
* `@{{ member.github }} <https://github.com/{{ member.github }}>`_
*
{%- if member.is_chair -%}
{{- " " -}} |:crown:|
{%- endif -%}
{%- if member.is_treasurer -%}
{{- " " -}} |:moneybag:|
{%- endif -%}
{% endfor %}
{% endfor %}
10 changes: 5 additions & 5 deletions docs/operations/elections.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ Volby do výboru probíhají asynchronně a zpravidla trvají týden, aby stihli
Kdy se volí
-----------

+------------------------------------+--------------------+
| |:ballot_box:| Předchozí volba | |board_start| |
+------------------------------------+--------------------+
| |:warning:| Příští volba | |board_end| |
+------------------------------------+--------------------+
+------------------------------------+------------------------+
| |:ballot_box:| Předchozí volba | |board_vote_date| |
+------------------------------------+------------------------+
| |:warning:| Příští volba | |next_board_vote_date| |
+------------------------------------+------------------------+

Příprava
--------
Expand Down
33 changes: 29 additions & 4 deletions src/pyvec_docs/boards.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,47 @@ def is_treasurer(self) -> bool:


class Board(BaseModel):
start_on: date
start_on: date | None = None
voted_on: date
members: list[BoardMember]

model_config = {"extra": "forbid", "frozen": True}

@classmethod
def make(cls, voted_on=None, start_on=None, **kwargs):
Copy link
Member

Choose a reason for hiding this comment

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

This is first time I see a method like this called make, so I got confused what it does. Eventually I understood it's something I usually call create. I'm not strongly opinionated about this, just sharing that this was an effort for me to grasp, which might or might not mean anything.

if voted_on is None:
voted_on = start_on
return cls(voted_on=voted_on, start_on=start_on, **kwargs)

@property
def years(self) -> tuple[int, int]:
def years(self) -> tuple[int, int] | tuple[None, None]:
if self.start_on is None:
return None, None
start_year = self.start_on.year
return (start_year, start_year + BOARDS_MANDATE_LENGTH)

@property
def sort_key(self):
# Boards without a start date sort as starting in the future
if self.start_on is None:
return (1, None)
return (0, self.start_on)


@cache
def load_boards(path: Path | str = BOARDS_CONFIG_PATH) -> list[Board]:
"""Load all boards, including inactive ones"""
data = tomllib.loads(Path(path).read_text())
return sorted(
(Board(**board) for board in data["board"]),
key=attrgetter("start_on"),
(Board.make(**board) for board in data["board"]),
key=attrgetter('sort_key'),
reverse=True,
)

@cache
def load_current_board(path: Path | str = BOARDS_CONFIG_PATH) -> Board:
"""Load the board that is currently in power"""
return [
board for board in load_boards(path)
if board.start_on is not None
][0]
35 changes: 34 additions & 1 deletion src/pyvec_docs/boards.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,39 @@
# The Pyvec board members in time
# The current board is first, previous boards are listed in descending order
# The most recent board is first, previous boards are listed in descending order
# Each member has a `name`, `github`, and optionally a `roles` array
#
# "start_on" should ideally be the date from justice.cz. If missing, the board
# doesn't officially have power yet.
#
# "voted_on" is the day when we voted for the board. If missing, defaults to
# "start_on" as an approximation.


[[board]]
voted_on = "2025-05-07"

[[board.members]]
name = "Jakub Vysoký"
github = "kvbik"

[[board.members]]
name = "Jan Čermák"
github = "sairon"
roles = ["treasurer"]

[[board.members]]
name = "Karolina Surma"
github = "befeleme"
roles = ["chair"]

[[board.members]]
name = "Petr Viktorin"
github = "encukou"

[[board.members]]
name = "Jakub Červinka"
github = "JakubDotPy"


[[board]]
start_on = "2022-04-09"
Expand Down
8 changes: 4 additions & 4 deletions src/pyvec_docs/ext/board_dates.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
def board_dates(app: Sphinx, config: Config):
board = load_boards()[0]

board_start = board.start_on
board_end = board_start + timedelta(days=BOARDS_MANDATE_LENGTH * 365)
last_vote = board.voted_on
next_vote = last_vote + timedelta(days=BOARDS_MANDATE_LENGTH * 365)

existing_epilog = app.config.rst_epilog or ""
app.config.rst_epilog = (
f"{existing_epilog}\n\n"
f".. |board_start| replace:: {board_start:%-d.%-m.%Y}\n"
f".. |board_end| replace:: {board_end:%Y}\n"
f".. |board_vote_date| replace:: {last_vote:%-d.%-m.%Y}\n"
f".. |next_board_vote_date| replace:: {next_vote:%Y}\n"
)


Expand Down
4 changes: 2 additions & 2 deletions src/pyvec_docs/ext/slack.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from docutils import nodes

from pyvec_docs.boards import load_boards
from pyvec_docs.boards import load_current_board


# https://docutils.readthedocs.io/en/sphinx-docs/howto/rst-roles.html
Expand All @@ -34,6 +34,6 @@ def slack(


def setup(app):
pyvec_board_years = load_boards()[0].years
pyvec_board_years = load_current_board().years
app.add_role("slack", functools.partial(slack, pyvec_board_years=pyvec_board_years))
return {"version": "1.0", "parallel_read_safe": True}
2 changes: 2 additions & 0 deletions src/pyvec_docs/grants.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ def remove_comments(html):

def get_board_member_name(username, voted_at, boards: list[Board]):
for board in boards: # sorted from the most recent
if board.start_on is None:
continue
if voted_at > board.start_on:
for member in board.members:
if member.github == username:
Expand Down
26 changes: 24 additions & 2 deletions tests/test_scripts_generate_grants.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,16 @@
@pytest.fixture
def boards():
return [ # sorted!
Board(
Board.make(
**{
# No start_on; votes don't count
"voted_on": date(2023, 1, 1),
"members": [
{"name": "Bob", "github": "bobby"},
],
}
),
Board.make(
**{
"start_on": date(2020, 1, 1),
"members": [
Expand All @@ -23,9 +32,10 @@ def boards():
],
}
),
Board(
Board.make(
**{
"start_on": date(2019, 1, 1),
"voted_on": date(2018, 12, 1),
"members": [
{"name": "Bob", "github": "bobby"},
],
Expand All @@ -34,6 +44,18 @@ def boards():
]


def assert_boards_sorted(boards):
assert boards == sorted(boards)


def assert_voted_on_defaults(boards):
assert [b.voted_on for b in boards] == [
date(2023, 1, 1), # explicit
date(2020, 1, 1), # from start_on
date(2018, 12, 1), # explicit
]


def test_to_date():
assert to_date("2020-02-12T13:22:01Z") == date(2020, 2, 12)

Expand Down