Automatically finishing orders

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Automatically finishing orders

martin.gropp
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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Automatically finishing orders

wvengen
Administrator
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,
- Willem

(*) 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.

On 14-05-14 16:28, martin.gropp [via foodsoft] wrote:

> 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

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Automatically finishing orders

martin.gropp
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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Automatically finishing orders

wvengen
Administrator
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.

- Willem

On 14-05-14 17:07, martin.gropp [via foodsoft] wrote:
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


If you reply to this email, your message will be added to the discussion below:
http://foodsoft.51229.x6.nabble.com/Automatically-finishing-orders-tp639p641.html
To start a new topic under foodsoft-discuss, email [hidden email]
To unsubscribe from foodsoft-discuss, click here.
NAML

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Automatically finishing orders

martin.gropp
Okay, I'll try that. :)
Thanks a lot!

Martin
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Automatically finishing orders

martin.gropp
Yay, seems to work! :)

Here's my script in case anyone's interested:

#!/bin/bash
set -e
set -u

# user and password, urlencoded
user='...'
password='...'

base_url='https://...'

order_id=$1

# temporary file for cookies
cookies=$( mktemp )
trap "rm -f '$cookies'" EXIT

# get authenticity token
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' \
)

# log in
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"

# finish order
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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Automatically finishing orders

wvengen
Administrator
Thanks for sharing, Martin!
Loading...