Hiho!
I noticed that orders are not finished automatically and it’s still possible to order after the order should have ended.
(Or is this a bug on my system…?)
So, is there a way to automatically finish orders?
Cheers,
Martin
Hiho!
I noticed that orders are not finished automatically and it’s still possible to order after the order should have ended.
(Or is this a bug on my system…?)
So, is there a way to automatically finish orders?
Cheers,
Martin
Hi Martin,
At this moment orders are not automatically closed. The end date is more
an indicator until when members can order. Since someone needs to send
an email with the order anyway, I think it makes sense that this is a
manual action. (*)
Cheers,
(*) In the foodcoop-adam fork, the order will be sent to the supplier
automatically upon closing the order (when a supplier’s order_howto is
an email address). We would like to have automatic order cycles at some
point.
Hi Willem!
Okay, thanks for this clarification!
So far we already had automated order emails, and of course it would be good to keep them when switching to Foodsoft (from a dreadful huge Google Docs spreadsheet…)
I adapted my order script to read the order information from the Foodsoft database, but it doesn’t make much sense to have an order cronjob if the order remains open in Foodsoft.
I take it that just setting status = ‘finished’ in the database is not such a good idea…?
Cheers,
Martin
Hi Martin,
You could do an HTTP POST to https://foodcoop.test/f/orders/123/finish
which closes the order. Updating the database would not update the group
orders or send out emails to members.
Okay, I’ll try that.
Thanks a lot!
Martin
Yay, seems to work!
Here’s my script in case anyone’s interested:
#!/bin/bash
set -e
set -u
user=’…’
password=’…’
base_url=‘https://…’
order_id=$1
cookies=$( mktemp )
trap “rm -f ‘$cookies’” EXIT
echo “Acquiring authenticity token…” >&2
authenticity_token=$(
wget -q -O -
–save-cookies “${cookies}” --keep-session-cookies
–no-check-certificate
“${base_url}/f/login”
| sed -n ‘s/.<input name=“authenticity_token” type=“hidden” value="([^"])".*/\1/p’
)
echo “Logging in…” >&2
wget -q -O /dev/null
–load-cookies “${cookies}” --save-cookies “${cookies}” --keep-session-cookies
–no-check-certificate
–header “X-CSRF-Token: ${authenticity_token}”
–post-data “nick=${user}&password=${password}&authenticity_token=${authenticity_token}&foodcoop=f&utf8=%E2%9C%93”
“${base_url}/f/sessions”
echo “Closing order…” >&2
wget -q -O /dev/null \
–load-cookies “${cookies}” --keep-session-cookies
–no-check-certificate
–header “X-CSRF-Token: ${authenticity_token}”
–post-data “”
“${base_url}/f/orders/${order_id}/finish”
echo “Done.” >&2
Thanks for sharing, Martin!