Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get the project working with Wagtail 4.1+ #489

Open
wants to merge 49 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
7e9c62d
Only python 38 + 39
nickmoreton Aug 27, 2024
4210a56
No python 3.7 support
nickmoreton Aug 27, 2024
6b293b2
Add support for Django 3.0
nickmoreton Aug 27, 2024
cb22d20
Use built-in StringIO instead of django.utils.six.StringIO
nickmoreton Aug 27, 2024
3dbf15d
Limit of python versions to 3.8 for Wagtail 2.11
nickmoreton Aug 27, 2024
ba401d9
Allow testing with Django 3.2
nickmoreton Aug 27, 2024
70e30a6
Test wagtail 2.14 and Django 3.2
nickmoreton Aug 27, 2024
58bcd4c
Add DEFAULT_AUTO_FIELD to test settings
nickmoreton Aug 27, 2024
672f1e9
Allow py310-dj32-wt215 and py310-dj32-wt216
nickmoreton Aug 27, 2024
950d417
Test django 4.0
nickmoreton Aug 27, 2024
ef92497
Actions for python 3.10
nickmoreton Aug 27, 2024
19f17a5
Update force_text to force_str
nickmoreton Aug 27, 2024
781bb21
This may just work if not stop here
nickmoreton Aug 27, 2024
a9fbcef
Change ugettext to gettext
nickmoreton Aug 27, 2024
c53f63a
Change the import of `url` from `django.conf.urls` to `django.urls` i…
nickmoreton Aug 27, 2024
b92611b
Allow wagtail 3.0 in testing
nickmoreton Aug 28, 2024
ad56496
Allow testing against Wagtail 4.0
nickmoreton Aug 28, 2024
86f344b
Allow testing with Django 4.1 and Wagtail 4.1
nickmoreton Aug 28, 2024
2146531
Allow testing django 41 with wagtail 40,41,42
nickmoreton Aug 28, 2024
c95d4fc
No longer test against Wagtail < 3.0, Django < 3.2, or Python < 3.8
nickmoreton Aug 28, 2024
36b6531
Update wagtail.core imports thats changed at Wagtail 3.0
nickmoreton Aug 28, 2024
d7b8e88
Add python version to matrix for complete testing coverage
nickmoreton Aug 28, 2024
94e9c54
Min pythonn version is now 3.8
nickmoreton Aug 28, 2024
b86ba45
Limit install to Django 3.2+ and Wagtail 3.0+
nickmoreton Aug 28, 2024
88348d3
Min python 3.9
nickmoreton Aug 29, 2024
ae4f3f4
Min python 3.9 and introduce Django 4.2 and Wagtail 5.0
nickmoreton Aug 29, 2024
bc838ab
Drop python 3.8
nickmoreton Aug 29, 2024
9a37707
wagtail.core is now wagtail
nickmoreton Aug 29, 2024
326bb15
Update contrib settings to use BaseSiteSetting
nickmoreton Aug 29, 2024
a31894a
Test up to wagtail 5.1
nickmoreton Aug 29, 2024
379ffc0
Test wagtail 5.2 compatibility
nickmoreton Aug 29, 2024
51fa2bd
Remove commented old versions no longer supported by the project.
nickmoreton Aug 29, 2024
9b81379
Update to use re_path instead of url
nickmoreton Aug 29, 2024
48453fe
Ignore my_project directory for testing longclaw start my_project
nickmoreton Aug 30, 2024
10fdac4
Add new migration for polymorphic_ctype field
nickmoreton Aug 30, 2024
c153787
ImageChooserPanel is no longer required.
nickmoreton Aug 30, 2024
26caafd
Update settings in project_template
nickmoreton Aug 30, 2024
07a44fa
Update urls import in project template
nickmoreton Aug 30, 2024
5d513a7
Add missing migrations in the project_template
nickmoreton Aug 30, 2024
983b712
Use template_name instead of template in wagtail_hooks
nickmoreton Aug 30, 2024
f79bfab
Remove conditional imports
nickmoreton Aug 30, 2024
b51892d
Documentation updates
nickmoreton Aug 30, 2024
04b1b99
Update CHANGELOG.rst
nickmoreton Aug 30, 2024
e8ea2cb
A temporary fix for a failing test, fix later
nickmoreton Aug 27, 2024
3ce1443
Fixes site summary and stats panel
nickmoreton Sep 1, 2024
c15b737
Update CHANGELOG.rst to reflect fixing the dashboard panels
nickmoreton Sep 1, 2024
44fae54
Lock node dependencies for now
nickmoreton Sep 3, 2024
f79d7a7
Fixes the api url to be at the root of the domain
nickmoreton Sep 3, 2024
118bce8
Add extra info to CHANGELOG
nickmoreton Sep 3, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python: ["3.7", "3.8", "3.9"]
python: ["3.9", "3.10", "3.11"]

steps:
- uses: actions/checkout@v2
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,4 @@ webpack-stats.json

# local virtual environment
/venv
/my_project
2 changes: 1 addition & 1 deletion .python-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.7
3.9
16 changes: 16 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,22 @@
History
-------

Unreleased
+++++++++++

Modernise the project for later versions of python, Django and Wagtail.
The aim is to support modern versions of Django and Wagtail and continue to use the existing tests to ensure compatibility.

* Django >= 4.1, <= 4.2
* Wagtail >= 4.1, <= 5.2
* Python >= 3.9, <= 3.11
* Fixes the api url to be at the root of the domain


TODO: These are parts of the project that need further work.

* Currently it may not be possible to use the longclaw.contrib apps

1.0.0
+++++++++++

Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ We are working to upgrade the package for the latest versions of Django and Wagt

We are currently running the tests against the following versions of Python, Django and Wagtail.

- Django >= 2.2, < 3.1
- Wagtail >= 2.11, < 2.14
- Python >= 3.7, < 3.10
- Django >= 4.1, <= 4.2
- Wagtail >= 4.1, <= 5.2
- Python >= 3.9, <= 3.11

### Developers

Expand Down
8 changes: 4 additions & 4 deletions docs/tutorial/integrate.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ urlpatterns = [

6. In this new app, add the following models

```
```python
from django.db import models
from django_extensions.db.fields import AutoSlugField
from modelcluster.fields import ParentalKey
from wagtail.core.models import Page, Orderable
from wagtail.core.fields import RichTextField
from wagtail.models import Page, Orderable
from wagtail.fields import RichTextField
from wagtail.admin.edit_handlers import FieldPanel, InlinePanel
from wagtail.images.edit_handlers import ImageChooserPanel
from longclaw.products.models import ProductVariantBase, ProductBase
Expand Down Expand Up @@ -138,4 +138,4 @@ We'll be building on top these basic templates in the next section.
PRODUCT_VARIANT_MODEL = 'webshop.ProductVariant'
PAYMENT_GATEWAY = 'longclaw.checkout.gateways.BasePayment'
```
We'll be covering their function in the [setup](/docs/guide/install).
We'll be covering their function in the [setup](/docs/guide/install).
8 changes: 4 additions & 4 deletions docs/tutorial/products.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,11 @@ You will need to sign in with the super user you created at the start of the tut

Under 'Pages', select the root page:

![Root page](assets/longclaw-select-root-page.png)
![Root page](../assets/longclaw-select-root-page.png)

On the 'Root' screen select 'Add Child Page' at the top. Here I selected my 'Home' page, but if you are running a small shop, you may wish your home page to be your product listing, in which case you might select 'Product Index'.

![Adding a home page](assets/longclaw-bakery-create-product-index.png)
![Adding a home page](../assets/longclaw-bakery-create-product-index.png)


We can now add `Product` models as children of `ProductIndex`. Only pages of type `Product` can be created under `ProductIndex`.
Expand All @@ -127,10 +127,10 @@ Add a title, description then start adding variants.
You will see that in the product variants are the custom fields we added for
applying discounts.

![Image of the product](assets/longclaw-bakery-add-product.png)
![Image of the product](../assets/longclaw-bakery-add-product.png)


If we navigate back to the product index page, we see the new product listed:

![Image of the product index](assets/longclaw-bakery-product-index.png)
![Image of the product index](../assets/longclaw-bakery-product-index.png)

4 changes: 2 additions & 2 deletions docs/tutorial/shipping.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ using the `loadcountries` command:
In the image below, we set a standard rate for the UK. It is possible to select multiple countries
for a rate to apply to. We can also create more than one shipping rate for the same country.

![Shipping](assets/shipping.png)
![Shipping](../assets/shipping.png)

## Default Shipping Rate

Expand All @@ -37,7 +37,7 @@ To enable default shipping:
- Fill in `Default Shipping Rate` and `Default Shipping Carrier`
- Ensure `Enable Default Shipping` is checked.

![Default shipping](assets/default_shipping.png)
![Default shipping](../assets/default_shipping.png)

### Currency

Expand Down
2 changes: 1 addition & 1 deletion longclaw/basket/signals.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import django.dispatch

basket_modified = django.dispatch.Signal(providing_args=['basket_id'])
basket_modified = django.dispatch.Signal('basket_id')
4 changes: 2 additions & 2 deletions longclaw/basket/templates/basket/add_to_basket.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
var btn = document.getElementById('btn-add-to-basket');
btn.addEventListener("click", function (e) {
longclawclient.basketList.post({
prefix: "{% longclaw_api_url_prefix %}",
prefix: "/{% longclaw_api_url_prefix %}",
data: {
variant_id: e.target.dataset.variantId
}
});
});

</script>
</script>
8 changes: 3 additions & 5 deletions longclaw/basket/tests.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import mock
from io import StringIO

from django.test.client import RequestFactory
from django.test import TestCase
try:
from django.urls import reverse_lazy
except ImportError:
from django.core.urlresolvers import reverse_lazy
from django.urls import reverse_lazy
from django.core.management import call_command
from django.utils.six import StringIO

from longclaw.tests.utils import LongclawTestCase, BasketItemFactory, ProductVariantFactory, catch_signal
from longclaw.basket.utils import basket_id
Expand Down
13 changes: 7 additions & 6 deletions longclaw/basket/urls.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from django.conf.urls import url
from django.urls import re_path

from longclaw.basket import api
from longclaw.basket import views
from longclaw.settings import API_URL_PREFIX
Expand All @@ -23,20 +24,20 @@

urlpatterns = [

url(API_URL_PREFIX + r'basket/$',
re_path(API_URL_PREFIX + r'basket/$',
basket_list,
name='longclaw_basket_list'),
url(API_URL_PREFIX + r'basket/count/$',
re_path(API_URL_PREFIX + r'basket/count/$',
total_items,
name="longclaw_basket_total_items"),
url(API_URL_PREFIX + r'basket/(?P<variant_id>[0-9]+)/$',
re_path(API_URL_PREFIX + r'basket/(?P<variant_id>[0-9]+)/$',
basket_detail,
name='longclaw_basket_detail'),
url(API_URL_PREFIX + r'basket/(?P<variant_id>[0-9]+)/count/$',
re_path(API_URL_PREFIX + r'basket/(?P<variant_id>[0-9]+)/count/$',
item_count,
name='longclaw_basket_item_count'),

url(r'basket/$',
re_path(r'basket/$',
views.BasketView.as_view(),
name="longclaw_basket")
]
28 changes: 13 additions & 15 deletions longclaw/checkout/tests.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import uuid
from django.utils.encoding import force_text
from django.utils.encoding import force_str
from django.urls import reverse_lazy
from django.test import TestCase
from django.test.client import RequestFactory
from wagtail.core.models import Site
try:
from django.urls import reverse_lazy
except ImportError:
from django.core.urlresolvers import reverse_lazy

from wagtail.models import Site

from longclaw.tests.utils import (
LongclawTestCase,
Expand Down Expand Up @@ -98,10 +96,10 @@ def setUp(self):
def test_create_order_with_basket_shipping_option(self):
amount = 11
rate = ShippingRate.objects.create(
name=force_text(uuid.uuid4()),
name=force_str(uuid.uuid4()),
rate=amount,
carrier=force_text(uuid.uuid4()),
description=force_text(uuid.uuid4()),
carrier=force_str(uuid.uuid4()),
description=force_str(uuid.uuid4()),
basket_id=self.basket_id,
)
order = create_order(
Expand All @@ -116,10 +114,10 @@ def test_create_order_with_basket_shipping_option(self):
def test_create_order_with_address_shipping_option(self):
amount = 12
rate = ShippingRate.objects.create(
name=force_text(uuid.uuid4()),
name=force_str(uuid.uuid4()),
rate=amount,
carrier=force_text(uuid.uuid4()),
description=force_text(uuid.uuid4()),
carrier=force_str(uuid.uuid4()),
description=force_str(uuid.uuid4()),
destination=self.shipping_address,
)
order = create_order(
Expand All @@ -134,10 +132,10 @@ def test_create_order_with_address_shipping_option(self):
def test_create_order_with_address_and_basket_shipping_option(self):
amount = 13
rate = ShippingRate.objects.create(
name=force_text(uuid.uuid4()),
name=force_str(uuid.uuid4()),
rate=amount,
carrier=force_text(uuid.uuid4()),
description=force_text(uuid.uuid4()),
carrier=force_str(uuid.uuid4()),
description=force_str(uuid.uuid4()),
destination=self.shipping_address,
basket_id=self.basket_id,
)
Expand Down
13 changes: 7 additions & 6 deletions longclaw/checkout/urls.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
from django.conf.urls import url
from django.urls import re_path

from longclaw.checkout import api, views
from longclaw.settings import API_URL_PREFIX

urlpatterns = [
url(API_URL_PREFIX + r'checkout/$',
re_path(API_URL_PREFIX + r'checkout/$',
api.capture_payment,
name='longclaw_checkout'),
url(API_URL_PREFIX + r'checkout/prepaid/$',
re_path(API_URL_PREFIX + r'checkout/prepaid/$',
api.create_order_with_token,
name='longclaw_checkout_prepaid'),
url(API_URL_PREFIX + r'checkout/token/$',
re_path(API_URL_PREFIX + r'checkout/token/$',
api.create_token,
name='longclaw_checkout_token'),
url(r'checkout/$',
re_path(r'checkout/$',
views.CheckoutView.as_view(),
name='longclaw_checkout_view'),
url(r'checkout/success/(?P<pk>[0-9]+)/$',
re_path(r'checkout/success/(?P<pk>[0-9]+)/$',
views.checkout_success,
name='longclaw_checkout_success')
]
6 changes: 1 addition & 5 deletions longclaw/checkout/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@
from django.views.generic import TemplateView
from django.views.decorators.http import require_GET
from django.http import HttpResponseRedirect

try:
from django.urls import reverse
except ImportError:
from django.core.urlresolvers import reverse
from django.urls import reverse

from longclaw.shipping.forms import AddressForm
from longclaw.checkout.forms import CheckoutForm
Expand Down
2 changes: 1 addition & 1 deletion longclaw/client/.nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
12
16
Loading
Loading