wagtail-nest / wagtail-airtable

Airtable import and export support for Wagtail pages and Django models.
BSD 3-Clause "New" or "Revised" License
50 stars 15 forks source link

Initial development #1

Closed KalobTaulien closed 4 years ago

KalobTaulien commented 4 years ago

Initial development. Includes tests (but not 100% test coverage as that's a bit extreme).

The docs should have enough information in it to make installation and usage simple for developers.

There are also examples in the examples/ directory.

To install and test locally:

git clone git@github.com:wagtail/wagtail-airtable.git # Into your wagtail project
pip install -e wagtail-airtable/ 
# Follow install steps in docs (may require a free Airtable account)

To run the unit tests: cd wagtail-airtable/tests/ && python runtests.py

KalobTaulien commented 4 years ago
  1. Currently, saving and exporting a page will add an explanatory error message if it fails. However, a bulk import does not (again, unless I'm missing something). Would it be possible to add this?

Yep, Django Messages (Wagtail notifications) have been added for Wagtail Pages. And in Wagtail 2.10 Snippets will have 3 hooks which will automatically be picked up on in this package, but models (snippets) won't have notifications until 2.10. There's no real way around that unless we modify all the places a snippet can be edited in the views/forms/templates.

  1. I import a model from airtable. In my model's save() method, for instance, I override the value of a synchronised field. This model, because this is in the middle of an import, does not push this new value back to airtable. As a result, Wagtail and Airtable are now out of sync. Is this scenario possible?

I just tested this, and as long as super() is called after the values are changed, this continues to work as expected.

    def save(self, *args, **kwargs):
        self.over_write_this = 'Lorem Ipsum'
        return super().save(*args, **kwargs)

☝️ That successfully overwrites the saved value, and updates Airtable with "Lorem Ipsum".