Configuring sharedlists for Terra

Hi Willem and others,

we set up foodsoft locally and sharedlist (both in docker). I couldn’t find any information about this: I don’t have a clue how to configure sharedlist to pull Terra’s BNN files and how to make Terra as supplier available in foodsoft. Any help or hint would be very much appreciated.

Best
Phil

Hi Phil,

You’re one of the few who’s actually going to use this (I guess). It’s been mostly deployed by the larger instances serving multiple foodcoops. Good you’re asking.

The README briefly explains that BNN settings are available for a supplier from within sharedlists (click on supplier name from index, choose Bearbeiten). You should have received the host, user and password from Terra Naturkost (I guess). The cronjob (which would generally be running as a separate docker container) then synchronizes three times an hour, but you can also run the rake task yourself. Note that at the moment, sharedlists may suffer from the password being lost when editing without entering it (#9).

Hope this helps you get going a bit. Good luck!

Regards,

  • Willem

Hi Willem,

thank you for your reply. I can’t get access to any interface of sharedlists to configure anything. Also there are no suppliers listed within foodsoft - the page is empty. So so we miss anything?

We are quite a few people and will try to cooperate superregionally in future.

Best
Phil

Hi Phil,

I presume you added suppliers in sharedlists.
You do need to configure Foodsoft so that in can find the sharedlists database.

     Â

Also make sure that you give the Foodsoft database user SELECT access on sharedlists’s suppliers and articles.

I’m curious how this will develop for you :slight_smile:

Regards,

  • Willem

p.s. You’re welcome to add yourself (and other coops) to

Heyho,

this is also interesting for us & we’d be curious how you will solve this, Phil.

Greetings

Thomas

Hi Willem,

me, I’m the actual admin for Phil’s planned foodcoop setup.
We set up foodsoft as well as sharedlists with docker (thanks to your(?) great work in dockerizing the whole stuff!!). Each software has its own database (maria 10) but they share the same login, so they can access each others data without problems. The sharedlists db is also referenced in foodsofts config. In foodsoft we can see the button for importing suppliers, but of course no supllier, as we didn’t manage to setup one. So far everything works fine, I guess.
But we don’t have a clue how to manage sharedlist itself. Is there some kind of a webinterface? Do we have to put some data straigth into the database? Or should there be some kind of management button in foodsoft that we just didn’t discover yet? Could you please explain in short how to add a supplier to sharedlists? What do we have to do to see a supplier in foodsofts import interface?
We’d be very happy if we could get that working and start foodcoop-ing. :wink:

Greets
Ben

Hi Ben,

Thanks for your message!

Sharedlists is a really old web app for keeping the shared database up-to-date (I’m sure you’ve read the shared database wiki page). When propely setup, you might hardly ever use it, because updates would go automatically. Creating the first user for sharedlists is explained in its README. You can then log into sharedlists, and start creating suppliers. In the supplier details, you can specify the update mechanism: BNN (which requires a cron instance) or email (which requires an smtp instance). See the README for running the instances. If you don’t want automatic updates, you can also upload through sharedlists’ web interface. Each supplier in sharedlists should be visible in the Foodsoft shared suppliers screen.

Does that help a bit?

Regards,

  • Willem

Hi Willem,

thanks that helped me a little bit in that I know now there must be a webinterface for sharedlists. Could you please point me to how to use it? In docker I see there is port 3000 opened but connecting to it with a browser gives a “500 internal server error”. Maybe there is some misconfiguration but I don’t see at which point I could have failed. An amdin account is setup and I can see that account in database. But til now I didn’t know where to “use” that account at all.

Hi Ben,

The server error doesn’t sound good. I haven’t seen that with sharedlists for a long time. Is the database setup correctly configured using DATABASE_URL (e.g. try the rails console in the sharedlists container to see if it is setup well)? What do the docker logs of the sharedlists container say?

  • Willem

Yay, I’m one step farther. There were so many error messages that I first didn’ see the top of the stack. I didn’t copy it, but it was saying like:
SECRET_TOKEN too short. Minimum 30 chars.
Indeed the token only had 26 chars… I enlarged it by some more chars, restarted the container … et voila: on local console (on the server running docker) I get a loginpage. Sadly I don’t seem to be able to tunnel that port to my workstation. Neither tunneling via ssh works nor publishing via haproxy, which is used for all other webites on that server too. But I guess, as long as you didn’t hardcode some “under-any-cicumstancens-deliver-only-to-localhost” into sharedlists, I have to figure out for myself, which system config currently prevents tunneling this special port.
Thanks a lot for your effort und keep up that great work!!

Everything works fine now! There were a couple of oddities with port forwarding and a browser which didn’t allow me to call a website without TLS. Security rulez! :~/
The interface is some kinda clean, others would say “stuck in the nineties”, but it fits for what it’s intended to. And as you pointed out, we’ll only use it once for adding the supplier and defining the import mechanism, afterwards we’ll probably never touch it again.

Again, thanks for all!

Hi Willem,

sorry to open up this thread again but we’re still having problems syncing articles between sharedlists and foodsoft.
When importing or updating the articles list in foodsoft I get an error 500. The logfile says:

ActiveRecord::StatementInvalid (Mysql2::Error: Unknown column 'articles.available' in 'where clause': SELECT `articles`.* FROM `articles` WHERE `articles`.`supplier_id` = 1 AND `articles`.`available` = 1 AND (`articles`.`id` != NULL)):
  app/models/supplier.rb:60:in `sync_all'
  app/controllers/articles_controller.rb:161:in `sync'
  app/controllers/application_controller.rb:93:in `set_currency'
  app/controllers/application_controller.rb:81:in `set_time_zone'

Seems like there is a column missing. It’s not quite clear to me in which one of the two databases this column is missing, as it is neither in sharedlist’s database nor in foodsoft’s. Looking at the current database schemas in github neither of them has a column “articles.available” defined, But there is a column “articles.availability” defined for foodsoft. Is this the column the sync is looking for?

Just tested with a manually updated app/models/supplier.rb having changed “available: true” to “availability: true” but it now complains about not finding column “availability”. Therefore the column must be missing in sharedlists. I can try to add this column and update a ‘1’ in every column, but this would only be a temporary workaraound as there is no interface in sharedlists nor in foodsoft for managing this value.

Importing articles manually from sharedlists works fine. But having some hundred articles makes this way quite a pita.

I just tested this with Foodsoft 4.6.0 and the latest sharedlists, but couldn’t reproduce what you’re seeing.
Foodsoft articles should have an availability column, indicating whether they will take part in a new order.
How did you initialize the Foodsoft database? It’s weird that it’s missing. –

Right, there is a column “availability” in foodsofts article table.

BUT: the software wants to read from “articles.available” not from “articles.availability”. When I changed that part in “app/models/supplier.rb” so that it reads

    # Find any new articles, unless the import is manual
    unless shared_sync_method == 'import'
      shared_supplier
        .shared_articles
        .where(availability: true)
        .where.not(id: existing_articles)
        .each { |shared_article| new_articles << shared_article.build_new_article(self) }
    end

then it complains about not finding the column “articles.availability”. Therefore the logic must be reading this value form the sharedlists database. In the sharedlists database there is neither a column “availability” nor a column “available” in table “articles”.

I just tested further and manually added a column “available” (tinyint(1)) in sharedlists “articles”-table. I set the value for all rows to 1. But I still cannot import articles into foodsoft. Now there is no error when doing import but it just says “database is up to date” without doing anything.
I added new articles to sharedlists, I changed articles and also deleted articles. But nothing reflects to foodsoft.
Currently, the only way to get articles from sharedlists into foodsoft is setting the supplier to manual import and importing each article one by one. After having some articles in foodsoft it also recognizes changes to the sharedlists database. Now I can update my articles. But we’d really like to import articles automatically.

Edit:
My foodsoft version is 4.6.99 (from docker hub) and sharedlists is also latest docker version but I don’t see the exact version.

You’ve come across a bug! Looking at the code, I bet you’re not running Foodsoft 4.6 but master, right?
This has been changed in PR#610, which introduced the bug you’re mentioning.

Removing the line “where(availability: true)” should fix the issue. I’ll do that on master (but will wait for the PR author to confirm).

Thanks for your answer!
The version shown in Webinterface is “Foodsoft v4.6.99”. I just did a pull from dockerhub and that’s what I got.

I changed the file supplier.rb and deleted the mentioned line but to no effect. I still cannot sync articles from sharedlists. I still can only import them manually. Having set the sync option to manual I can update already imported articles. That’s quite half the way we want to go. :wink:

Maybe another idea?

That’s really odd. I’ve just corrected it on master and tested it, and it seemed to work.
(Note that you can’t just edit the file in the container and assume it’s changed when you bring up the container - because it always runs the image built.)

If you still have an issue, please share the error you’re seeing now (with the updated image, which should be building now).

Hi Willem,

when testing your hotfix I placed the file “supplier.rb” in a folder outside of docker and bound it to the image using the “–volume” parameter:

--volume $BDIR/supplier.rb:/usr/src/app/app/models/supplier.rb

I know that this worked as I got different error messages after binding the changed file to the image.
I also tried to bind the complete filestructure of a downloaded stable 4.6.0 to the image but I guess ruby needs some compilation before running those files. Sorry, but in terms of ruby I’m a complete noob.

So I just downloaded the updated docker image and am about to get it up and running. Will give feedback when I’m done. Thanks for updating so fast!

Allright, after pulling the updated image and restarting the container I still see the same Version number displayed in foodsoft (4.6.99) and still have the same issues regarding articles sync.

Here is what currently works:

  • Adding a supplier which is defined in sharedlists

Using the “choose articles to import” sync

  • Importing articles from this supplier
  • updating imported articles which have changed in sharedlists
  • deleting articles which have been deleted (or have number changed) in sharedlists

Using the “All Articles” sync (either “new are available” or “new are unavailable”)

  • deleting articles which have been deleted (or have number changed) in sharedlists (those articles were previously imported via the “choose articles to import” sync option)

What doesn’t work using the “All Articles” sync (either “new are available” or “new are unavailable”):

  • updating changed articles from sharedlists
  • adding new articles from sharedlists