diff --git a/.github/workflows/build-docker.yml b/.github/workflows/build-docker.yml
index cee4bed..838afc2 100644
--- a/.github/workflows/build-docker.yml
+++ b/.github/workflows/build-docker.yml
@@ -1,7 +1,7 @@
---
name: Docker Build and maybe Push
-on:
+on:
workflow_call:
inputs:
org:
@@ -37,7 +37,7 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: "3.10"
-
+
- name: Fix metadata
run: |
if [ -x bin/freeze.sh ]; then
@@ -76,4 +76,3 @@ jobs:
context: .
push: true
tags: ${{ inputs.org }}/${{ inputs.repo }}:${{ inputs.tag }}
-
diff --git a/.github/workflows/build-latest.yml b/.github/workflows/build-latest.yml
index 019dcdb..86fcf1d 100644
--- a/.github/workflows/build-latest.yml
+++ b/.github/workflows/build-latest.yml
@@ -21,27 +21,24 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
-
- - name: install
- uses: appleboy/ssh-action@v1.1.0
- with:
- host: ${{ secrets.HOST }}
- username: ${{ secrets.USERNAME }}
- key: ${{ secrets.KEY }}
- port: ${{ secrets.PORT }}
- passphrase: ${{ secrets.PASSPHRASE }}
- script: |
- set -euo pipefail
- cd /opt/compose
- docker compose pull freezing-web
- docker compose up -d freezing-web
-
- - name: wait
- uses: iFaxity/wait-on-action@v1.2.1
- with:
- resource: https-get://freezingsaddles.org
- timeout: 5000
-
+ - name: install
+ uses: appleboy/ssh-action@v1.1.0
+ with:
+ host: ${{ secrets.HOST }}
+ username: ${{ secrets.USERNAME }}
+ key: ${{ secrets.KEY }}
+ port: ${{ secrets.PORT }}
+ passphrase: ${{ secrets.PASSPHRASE }}
+ script: |
+ set -euo pipefail
+ cd /opt/compose
+ docker compose pull freezing-web
+ docker compose up -d freezing-web
+ - name: wait
+ uses: iFaxity/wait-on-action@v1.2.1
+ with:
+ resource: https-get://freezingsaddles.org
+ timeout: 5000
test:
concurrency: build-deploy-and-test
@@ -49,10 +46,7 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
-
- - name: checkout
- uses: actions/checkout@v4
-
- - name: test-wget-spider
- run: "URL=https://freezingsaddles.org test/wget-spider.sh"
-
+ - name: checkout
+ uses: actions/checkout@v4
+ - name: test-wget-spider
+ run: "URL=https://freezingsaddles.org test/wget-spider.sh"
diff --git a/.github/workflows/build-tag.yml b/.github/workflows/build-tag.yml
index dd7488d..26a9885 100644
--- a/.github/workflows/build-tag.yml
+++ b/.github/workflows/build-tag.yml
@@ -4,7 +4,7 @@ name: Build Tag
on:
push:
tags:
- - '*'
+ - '*'
jobs:
build:
diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml
index 7e1fda0..6b03b10 100644
--- a/.github/workflows/lint.yml
+++ b/.github/workflows/lint.yml
@@ -4,9 +4,9 @@ name: Lint
on: pull_request
jobs:
-
- # Thanks https://black.readthedocs.io/en/stable/integrations/github_actions.html
- lint:
+ # Thanks for the inspiration:
+ # https://black.readthedocs.io/en/stable/integrations/github_actions.html
+ python:
name: Python Lint
runs-on: ubuntu-latest
steps:
@@ -21,6 +21,24 @@ jobs:
- name: isort Lint
uses: isort/isort-action@v1
with:
- requirements-files: "requirements.txt requirements-test.txt"
+ requirements-files: "requirements.txt requirements-test.txt"
- name: flake8 Lint
uses: py-actions/flake8@v2
+
+ templates:
+ name: Templates Lint
+ runs-on: ubuntu-latest
+ steps:
+ - name: Check out source repository
+ uses: actions/checkout@v4
+ - name: Set up Python environment
+ uses: actions/setup-python@v5
+ with:
+ python-version: "3.10"
+ - name: Install dependencies
+ run: |
+ python -m pip install --upgrade pip
+ pip install -r requirements.txt -r requirements-test.txt
+ - name: djlint Lint
+ run: |
+ djlint --check freezing/web/templates
diff --git a/.github/workflows/security.yml b/.github/workflows/security.yml
index fce3dad..c0e1555 100644
--- a/.github/workflows/security.yml
+++ b/.github/workflows/security.yml
@@ -4,8 +4,9 @@ name: Security
on: pull_request
jobs:
-
- # Thanks https://black.readthedocs.io/en/stable/integrations/github_actions.html
+
+ # Thanks for inspiration:
+ # https://black.readthedocs.io/en/stable/integrations/github_actions.html
bandit:
name: Bandit
runs-on: ubuntu-latest
diff --git a/README.md b/README.md
index 24b00ff..0bff7bc 100644
--- a/README.md
+++ b/README.md
@@ -114,7 +114,13 @@ To get `freezing-web` to permanently use the `freezing-model` changes you will h
### Coding standards
-The `freezing-web` code is intended to be [PEP-8](https://www.python.org/dev/peps/pep-0008/) compliant. Code formatting is done with [black](https://black.readthedocs.io/en/stable/) and can be linted with [flake8](http://flake8.pycqa.org/en/latest/). See the [.flake8](.flake8) file and install the test dependencies to get these tools (`pip install -r test-requirements.txt`).
+The `freezing-web` code is intended to be [PEP-8](https://www.python.org/dev/peps/pep-0008/) compliant. Code formatting is done with [black](https://black.readthedocs.io/en/stable/), [isort](https://pycqa.github.io/isort/) and [djlint}(https://www.djlint.com/) and can be linted with [flake8](http://flake8.pycqa.org/en/latest/). See the [.flake8](.flake8) file and install the test dependencies to get these tools (`pip install -r test-requirements.txt`).
+
+To run _all_ the linters and formatters, use the following commands:
+```
+bin/lint.sh
+bin/fmt.sh
+```
## Docker Deployment
diff --git a/bin/fmt.sh b/bin/fmt.sh
new file mode 100755
index 0000000..ddf8b3f
--- /dev/null
+++ b/bin/fmt.sh
@@ -0,0 +1,9 @@
+#!/usr/bin/env bash
+echo "Running formatters"
+echo "*** black ***"
+black freezing
+echo "*** isort ***"
+isort freezing
+echo "*** djlint ***"
+djlint --reformat freezing/web/templates
+
diff --git a/bin/lint.sh b/bin/lint.sh
new file mode 100755
index 0000000..0fa0fb7
--- /dev/null
+++ b/bin/lint.sh
@@ -0,0 +1,12 @@
+#!/usr/bin/env bash
+echo "Running linting checks"
+echo "*** black ***"
+black --check freezing
+echo "*** isort ***"
+isort --check freezing
+echo "*** flake8 ***"
+flake8 freezing
+echo "*** mypy ***"
+echo "*** djlint ***"
+djlint --check freezing/web/templates
+
diff --git a/freezing/web/templates/alt_scoring/indiv_freeze.html b/freezing/web/templates/alt_scoring/indiv_freeze.html
index d0767d2..26b2023 100644
--- a/freezing/web/templates/alt_scoring/indiv_freeze.html
+++ b/freezing/web/templates/alt_scoring/indiv_freeze.html
@@ -1,19 +1,39 @@
{% extends "base.html" %}
{% block content %}
-
-
Freeze Points
-
-
Thanks to VVill for coming up with this, (explained here). Basically you get more points for riding in the cold, but distance doesn't matter so much.
-
-
Rank
Team
Points
-{% for a, b in indiv_freeze %}
-
-
{{loop.index}}
-
{{a}}
-
{{ '%0.1f' % b }}
-
-{% endfor %}
-
-
-
+
+
+ Freeze Points
+
+
+
+ Thanks to VVill for coming up with this, (explained here). Basically you get more points for riding in the cold, but distance doesn't matter so much.
+
We're looking for the hamsterest hamster who ever hamstered.
-
Segment Miles is based on the 2.5 mile Gate
- to Gate segment, so it undercounts your mileage if you did a full lap.
- However, since this segment is the official measure of "A Hains Point Lap" as far as
- this contest is concerned, it was thought best to use 2.5 miles.
-
If you feel the wrong decision has been made here, please be reminded that you are a hamster, and hamsters don't get the admin password to the web server.
-
-
-
-
Rank
Hamster
Times Hamstered
Segment Miles
Total Miles
Hamster %
-
-{% for a, b, c in indiv_hains %}
-
-
{{loop.index}}
-
{{a}}
-
{{b}}
-
{{b * 2.5}}
-
{{c|round(1)}}
-
{{((b*250)/c)|round(1)}}
-
-{% endfor %}
-
-
-
-
+
+
+ Hains Point Laps
+
+
+
+ We're looking for the hamsterest hamster who ever hamstered.
+
+
+ Segment Miles is based on the 2.5 mile Gate
+ to Gate segment, so it undercounts your mileage if you did a full lap.
+ However, since this segment is the official measure of "A Hains Point Lap" as far as
+ this contest is concerned, it was thought best to use 2.5 miles.
+
+
+ If you feel the wrong decision has been made here, please be reminded that you are a hamster, and hamsters don't get the admin password to the web server.
+
If we really want to be pedantic, and of course we want to be pedantic, it's actually Sleaze Days. Two one mile rides in a day gets you no sleaze ride credit. Since no one wants sleaze ride credit, this is a good thing.
-
-
Rank
Name
Sleaze Rides
-{% for a, b in indiv_sleaze %}
-
-
{{loop.index}}
-
{{a}}
-
{{b}}
-
-{% endfor %}
-
-
-
+
+
+ Sleaze Rides
+
+
+
+ If we really want to be pedantic, and of course we want to be pedantic, it's actually Sleaze Days. Two one mile rides in a day gets you no sleaze ride credit. Since no one wants sleaze ride credit, this is a good thing.
+
Take the median number of riders per day and then, for each day, your Adjusted Points are
- your points in the old system (1 point per mile, 10 points per day for riding at least 1 mile) multiplied
- by 1.025^(median-[total number of riders today]).
- At this moment in time, the median number of riders is {{median}}.
-
-
NOTE: This is calculated at the time you view the chart. This means that today's points will
- change as more people ride. If you are the first rider of the day, you will get literally a
- bajillion points (A sleaze ride of exactly one mile is worth almost 1500 points if you're
- the only rider of the day). As more people ride, your points go down.
-
-
-
-
-
Rank
Rider
Team
Miles
Old Points
Adjusted Points
Bump %
Days Ridden
-
-{% for a, b, c, d, e, f in data %}
-
-
{{loop.index}}
-
{{a}}
-
{{b}}
-
{{c|round(1)}}
-
{{d|round(1)}}
-
{{e|round(1)}}
-
{{(100*(e-d)/d)|round(1) if d > 0 else 0}}%
-
{{f}}
-
-{% endfor %}
-
-
-
-
+
+
+ Steve O's Worst Day Points Proposal
+
+
+
+ Take the median number of riders per day and then, for each day, your Adjusted Points are
+ your points in the old system (1 point per mile, 10 points per day for riding at least 1 mile) multiplied
+ by 1.025^(median-[total number of riders today]).
+ At this moment in time, the median number of riders is {{ median }}.
+
+
+ NOTE: This is calculated at the time you view the chart. This means that today's points will
+ change as more people ride. If you are the first rider of the day, you will get literally a
+ bajillion points (A sleaze ride of exactly one mile is worth almost 1500 points if you're
+ the only rider of the day). As more people ride, your points go down.
+
For each day, the team with the highest daily total gets {{team_total|length}} points. Second gets {{team_total|length - 1}}, down to 1 for the last place team.
-
- {% for a,b in team_total %}
-
{{b}} {{a}}
- {% endfor %}
-
-
-
+
+
+ Team Points by Day
+
+
+
+ For each day, the team with the highest daily total gets {{ team_total|length }} points. Second gets {{ team_total|length - 1 }}, down to 1 for the last place team.
+
Now, you know it's up to you whether or not you want to just do the bare minimum. People can go for a bike ride anywhere, okay? They do Freezing Saddles for the camaraderie and the soul-crushing cold.
-
Look, we want you to ride your bike, okay? Now if you feel that the bare minimum is enough, then okay. But some people choose to ride more and we encourage that, okay? You do want to ride your bike, don't you?
-
-
Rank
Team
Sleaze Rides
-{% for a, b in team_sleaze %}
-
-
{{loop.index}}
-
{{a}}
-
{{b}}
-
-{% endfor %}
-
-
-
+
+
+ Team Sleaze
+
+
+
+ Now, you know it's up to you whether or not you want to just do the bare minimum. People can go for a bike ride anywhere, okay? They do Freezing Saddles for the camaraderie and the soul-crushing cold.
+
+
+ Look, we want you to ride your bike, okay? Now if you feel that the bare minimum is enough, then okay. But some people choose to ride more and we encourage that, okay? You do want to ride your bike, don't you?
+
- You have successfully logged in to Strava and authorized the Freezing Saddles application to read your rides.
-
-
-
Make sure you have registered on the signup sheet.
- Note: for the purposes of the registration form, your Strava user ID is {{ athlete.id }}.
-
-{% if no_teams %}
-
Uh-oh, something went wrong.
- So you are a Strava athlete, we get that. Unfortunately, one of these two things is true:
-
-
you did not give Strava permission for us to "View your complete Strava profile".
- Without that, we can't see what clubs you belong to.
-{% if after_competition_start and competiton_teams_assigned %}
-
you are not registered with any of the configured Freezing Saddles team clubs;
- if that is the case, You need to join a competition team Strava club.
- Or maybe the app just needs to be updated to know about the Strava teams.
-
Don't worry, your rides will count but they won't be on any leaderboards until you have joined one of the
- competition team clubs.
-
-{% elif multiple_teams %}
-
Houston we have a problem.
- It looks like you joined _multiple_ Strava clubs that are registered as competition teams.
- Here are the problematic teams (please ensure you are only a member of one of them):
-
- You are registered with a team!
- You are a member of the
- {{ team.name }} Strava club.
-
-{% if not competition_teams_assigned %}
-
Later, you will need to join a competition team Strava club as well; please attend the season opener Happy Hour (watch the forum for an announcement) and check your email for updates. That will make you show up on the teamleaderboards.
-
+ You have successfully logged in to Strava and authorized the Freezing Saddles application to read your rides.
+
+
+
+ Make sure you have registered on the signup sheet.
+ Note: for the purposes of the registration form, your Strava user ID is {{ athlete.id }}.
+
+ {% if no_teams %}
+
+ Uh-oh, something went wrong.
+ So you are a Strava athlete, we get that. Unfortunately, one of these two things is true:
+
+
+ you did not give Strava permission for us to "View your complete Strava profile".
+ Without that, we can't see what clubs you belong to.
+
+ {% if after_competition_start and competiton_teams_assigned %}
+
+ you are not registered with any of the configured Freezing Saddles team clubs;
+ if that is the case, You need to join a competition team Strava club.
+ Or maybe the app just needs to be updated to know about the Strava teams.
+
+ Don't worry, your rides will count but they won't be on any leaderboards until you have joined one of the
+ competition team clubs.
+
+ {% elif multiple_teams %}
+
+ Houston we have a problem.
+ It looks like you joined _multiple_ Strava clubs that are registered as competition teams.
+ Here are the problematic teams (please ensure you are only a member of one of them):
+
+ You are registered with a team!
+ You are a member of the
+ {{ team.name }} Strava club.
+
+ {% if not competition_teams_assigned %}
+
+ Later, you will need to join a competition team Strava club as well; please attend the season opener Happy Hour (watch the forum for an announcement) and check your email for updates. That will make you show up on the teamleaderboards.
+