aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xgenerate4
-rw-r--r--sjdbmk/daily.py7
-rw-r--r--sjdbmk/sendmail.py13
-rw-r--r--templates/template.html2
4 files changed, 22 insertions, 4 deletions
diff --git a/generate b/generate
index 6c2b1ad..01daaca 100755
--- a/generate
+++ b/generate
@@ -1,5 +1,7 @@
#!/usr/bin/env bash
+. "$HOME/.local/share/venv/bin/activate"
+
src_home="${BASH_SOURCE[0]%/*}"
export PYTHONPATH="$src_home:$PYTHONPATH"
@@ -30,7 +32,7 @@ printf 'Running daily.py\n' >&2
python3 -m sjdbmk.daily --date="$TARGET" || exit 2
printf 'Running pack.py\n' >&2
python3 -m sjdbmk.pack --date="$TARGET" || exit 3
-xdg-open ../sjdb-build/sjdb-"$(printf '%s' "$TARGET" | tr -d '-')".html
+open ../sjdb-build/sjdb-"$(printf '%s' "$TARGET" | tr -d '-')".html
read -p "Is this bulletin OK to send? [y/N] " res
if [ "$res" = "y" ]
then
diff --git a/sjdbmk/daily.py b/sjdbmk/daily.py
index e708bae..4c7ad69 100644
--- a/sjdbmk/daily.py
+++ b/sjdbmk/daily.py
@@ -136,10 +136,13 @@ def generate(
breakfast_today = week_data["menu"]["Breakfast"][weekday_short]
lunch_today = week_data["menu"]["Lunch"][weekday_short]
- dinner_today = week_data["menu"]["Dinner"][weekday_short]
+ try:
+ dinner_today = week_data["menu"]["Dinner"][weekday_short]
+ except KeyError:
+ dinner_today = None
try:
breakfast_tomorrow = week_data["menu"]["Breakfast"][next_weekday_short]
- except IndexError:
+ except KeyError:
breakfast_tomorrow = None
try:
snack_morning = week_data["snacks"][0][days_since_beginning]
diff --git a/sjdbmk/sendmail.py b/sjdbmk/sendmail.py
index 35b1639..4b58674 100644
--- a/sjdbmk/sendmail.py
+++ b/sjdbmk/sendmail.py
@@ -54,6 +54,7 @@ def sendmail(
content_type: str = "HTML",
importance: str = "Normal",
reply_to: Optional[str] = None,
+ respect_when: bool = True,
) -> str:
data = {
"subject": subject,
@@ -64,7 +65,7 @@ def sendmail(
"bccRecipients": [{"emailAddress": {"address": a}} for a in bcc],
}
- if when is not None:
+ if when is not None and respect_when:
if when.tzinfo is None:
raise TypeError("Naive datetimes are no longer supported")
utcwhen = when.astimezone(datetime.timezone.utc)
@@ -129,6 +130,12 @@ def main() -> None:
action="store_true",
help="Reply to the previous bulletin when sending (BROKEN)",
)
+ parser.add_argument(
+ "-n",
+ "--now",
+ action="store_true",
+ help="Send the bulletin right now, instead of at the right time",
+ )
parser.add_argument("--config", default="config.ini", help="path to the configuration file")
args = parser.parse_args()
config = ConfigParser()
@@ -166,6 +173,7 @@ def main() -> None:
),
content_type="HTML",
importance="Normal",
+ respect_when=(not args.now),
)
assert a
with open("last-a.txt", "w") as fd:
@@ -185,6 +193,7 @@ def main() -> None:
),
content_type="HTML",
importance="Normal",
+ respect_when=(not args.now),
)
assert b
with open("last-b.txt", "w") as fd:
@@ -208,6 +217,7 @@ def main() -> None:
content_type="HTML",
importance="Normal",
reply_to=last_a,
+ respect_when=(not args.now),
)
assert a
with open("last-a.txt", "w") as fd:
@@ -230,6 +240,7 @@ def main() -> None:
content_type="HTML",
importance="Normal",
reply_to=last_b,
+ respect_when=(not args.now),
)
assert b
with open("last-b.txt", "w") as fd:
diff --git a/templates/template.html b/templates/template.html
index 30d4b5f..c3b0c1c 100644
--- a/templates/template.html
+++ b/templates/template.html
@@ -314,6 +314,7 @@
{% endif %}
</td>
</tr>
+ {% if today_dinner %}
<tr class="today">
<th scope="row">{{weekdays_abbrev[0]}}<br/>Dinner</th>
<td>
@@ -379,6 +380,7 @@
{% endif %}
</td>
</tr>
+ {% endif %}
</tbody>
</table>
{% if days_after_this == -1 %}