Skip to content

Commit fc38b7c

Browse files
committed
Merge branch 'main' into tobias/add-logging-to-payment-logic
2 parents ab0ffaf + 204e17d commit fc38b7c

File tree

5 files changed

+84
-84
lines changed

5 files changed

+84
-84
lines changed

.github/workflows/deploy.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
---
2+
name: Deploy
3+
4+
on:
5+
push:
6+
branches:
7+
- main
8+
- tobias/create-github-actions-for-deployment
9+
workflow_dispatch:
10+
inputs:
11+
branch:
12+
description: 'Branch to deploy'
13+
required: true
14+
default: 'main'
15+
type: string
16+
17+
permissions:
18+
contents: read
19+
20+
jobs:
21+
deploy-test:
22+
name: Deploy to test environment
23+
runs-on: ubuntu-latest
24+
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
25+
steps:
26+
- name: Deploy to test server
27+
uses: appleboy/[email protected]
28+
with:
29+
key: ${{ secrets.SSH_KEY }}
30+
username: voko_acc
31+
host: leden.vokoutrecht.nl
32+
script: |
33+
# Run the deploy script with the specified branch
34+
if [ "${{ github.event_name }}" = "push" ]; then
35+
# Auto-deploy to test environment on push to main
36+
$HOME/scripts/deploy.sh -b 'tobias/create-github-actions-for-deployment'
37+
else
38+
# Manual deploy with specified branch
39+
$HOME/scripts/deploy.sh -b ${{ github.event.inputs.branch }}
40+
fi
41+
42+
# deploy-production:
43+
# name: Deploy to production environment
44+
# runs-on: ubuntu-latest
45+
# environment: production
46+
# if: github.event_name == 'push'
47+
48+
# steps:
49+
# - name: Deploy to production server
50+
# uses: appleboy/[email protected]
51+
# with:
52+
# key: ${{ secrets.SSH_KEY }}
53+
# script: |
54+
# # Run the deploy script with the specified branch
55+
# $HOME/scripts/deploy.sh -b ${{ github.event.inputs.branch }}

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@ Django based custom web application for food collective www.vokoutrecht.nl.
33

44
![example workflow](https://github.com/VOKO-Utrecht/voko/actions/workflows/ci.yml/badge.svg)
55

6+
## Deployment
7+
8+
This project includes automated deployment workflows:
9+
- **Test environment**: Automatically deploys when pushing to `main` branch
10+
- **Production environment**: Manual deployment via GitHub Actions workflow dispatch
11+
12+
For complete deployment setup instructions, see [docs/DEPLOYMENT.md](docs/DEPLOYMENT.md).
13+
614
## Some notes
715
1. The code base needs cleaning up and adding of tests.
816
2. License: GNU GPLv3

uv.lock

Lines changed: 3 additions & 48 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

webapp/ordering/core.py

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -275,23 +275,21 @@ def create_orderround_batch():
275275
last_round = get_last_order_round()
276276
current_date = datetime.now(pytz.UTC).date()
277277

278-
# If there's no last round, we start from next week and end at the last day of the current quarter
278+
# Determine start date based on whether there's a last round
279279
if last_round is None:
280280
start_date = current_date + timedelta(days=7)
281-
end_date = last_day_current_quarter
282-
# If the last round is not just before the next quarter, create a batch to fill the current quarter
283-
elif (
284-
last_round.open_for_orders.date() + timedelta(weeks=config.ORDERROUND_INTERVAL_WEEKS)
285-
<= last_day_current_quarter
286-
):
287-
start_date = last_round.open_for_orders.date() + timedelta(weeks=config.ORDERROUND_INTERVAL_WEEKS)
288-
end_date = last_day_current_quarter
289-
# If the next quarter is less than ORDERROUND_CREATE_DAYS_AHEAD away, create a new batch for the next quarter
290-
elif last_day_current_quarter < current_date + timedelta(days=config.ORDERROUND_CREATE_DAYS_AHEAD):
281+
else:
291282
start_date = last_round.open_for_orders.date() + timedelta(weeks=config.ORDERROUND_INTERVAL_WEEKS)
283+
284+
# Determine end date based on proximity to next quarter
285+
if last_day_current_quarter < current_date + timedelta(days=config.ORDERROUND_CREATE_DAYS_AHEAD):
286+
# Next quarter is close, create batch for next quarter
292287
end_date = last_day_next_quarter
293-
# If none of these match, we don't need a new order round batch.
288+
elif last_round is None or start_date <= last_day_current_quarter:
289+
# Fill current quarter
290+
end_date = last_day_current_quarter
294291
else:
292+
# No new order round batch needed
295293
return []
296294

297295
# Adjust start date to the configured open day of the week

webapp/ordering/tests/test_core.py

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
get_latest_order_round,
88
update_totals_for_products_with_max_order_amounts,
99
create_orderround_batch,
10-
get_quarter_end_dates,
11-
get_last_order_round,
1210
)
1311
from ordering.models import OrderProduct
1412
from ordering.tests.factories import (
@@ -268,35 +266,21 @@ def test_latest_order_round_is_returned(self):
268266

269267

270268
class TestAutomaticOrderRoundCreation(VokoTestCase):
271-
@freeze_time("2025-09-18")
269+
@freeze_time("2025-08-25")
272270
def test_create_orderround_batch_no_order_rounds_yet(self):
273271
"""Test creating order rounds when no order rounds exist yet"""
274-
# When there are no order rounds, should create from next week to end of current quarter
272+
# When there are no order rounds, should create from next week to end of next quarter
275273
result = create_orderround_batch()
276274

277-
self.assertEqual(len(result), 1) # Only one order round should fit in this period
278-
279-
def test_create_orderround_batch_one_order_round_no_more_in_quarter(self):
280-
"""Test when there's one order round but no more planned for rest of current quarter"""
281-
# Create an existing order round early in the quarter
282-
_ = OrderRoundFactory(
283-
open_for_orders=datetime(2024, 1, 8, 8, 0, tzinfo=UTC), # Early January
284-
closed_for_orders=datetime(2024, 1, 12, 8, 0, tzinfo=UTC),
285-
collect_datetime=datetime(2024, 1, 17, 18, 0, tzinfo=UTC),
286-
)
275+
self.assertEqual(len(result), 2) # Two order rounds should be created
287276

277+
@freeze_time("2025-09-18")
278+
def test_create_orderround_batch_no_order_rounds_yet_next_quarter_close(self):
279+
"""Test creating order rounds when no order rounds exist yet but next quarter is close"""
280+
# When there are no order rounds and next quarter is close, should create from next week to end of next quarter
288281
result = create_orderround_batch()
289282

290-
# Should create order rounds from January 22 (2 weeks after Jan 8) to end of Q1
291-
# This should create multiple order rounds to fill the gap
292-
self.assertGreater(len(result), 0)
293-
294-
# Get last ourder round
295-
last_round = get_last_order_round()
296-
297-
# Last order round should be before next quarter
298-
last_day_current_quarter, _ = get_quarter_end_dates()
299-
self.assertGreater(last_day_current_quarter, last_round.closed_for_orders.date())
283+
self.assertEqual(len(result), 7) # Seven order rounds should be created
300284

301285
@freeze_time("2024-02-01")
302286
def test_create_orderround_batch_next_quarter_far_away(self):

0 commit comments

Comments
 (0)