summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLauréline Guérin <zebuline@entrouvert.com>2019-10-14 12:05:26 (GMT)
committerLauréline Guérin <zebuline@entrouvert.com>2019-10-29 07:35:53 (GMT)
commita7417488eb63c32caf8a1a512ac3db879b656e93 (patch)
treee6704ce4063970be8d4a6a9211ee8ead7e21d2c5
parentccf99d908f3263e7d249738664318b6d8648bea0 (diff)
downloadcombo-a7417488eb63c32caf8a1a512ac3db879b656e93.zip
combo-a7417488eb63c32caf8a1a512ac3db879b656e93.tar.gz
combo-a7417488eb63c32caf8a1a512ac3db879b656e93.tar.bz2
dj2: use set and/or clear method for M2M (#36895)
remove RemovedInDjango20Warning: Direct assignment to the forward side of a many-to-many set is deprecated due to the implicit save() that happens. Use items.set() instead.
-rw-r--r--combo/apps/lingo/views.py2
-rw-r--r--combo/manager/forms.py10
-rw-r--r--tests/test_dataviz.py4
-rw-r--r--tests/test_import_export.py4
-rw-r--r--tests/test_lingo_manager.py4
-rw-r--r--tests/test_pages.py4
-rw-r--r--tests/test_public.py8
7 files changed, 18 insertions, 18 deletions
diff --git a/combo/apps/lingo/views.py b/combo/apps/lingo/views.py
index f3f9697..b68b906 100644
--- a/combo/apps/lingo/views.py
+++ b/combo/apps/lingo/views.py
@@ -346,7 +346,7 @@ class PayMixin(object):
transaction.save()
transaction.regie = regie
- transaction.items = items
+ transaction.items.set(items)
transaction.remote_items = ','.join([x.id for x in remote_items])
transaction.status = 0
transaction.amount = total_amount
diff --git a/combo/manager/forms.py b/combo/manager/forms.py
index 97f6d82..e32193a 100644
--- a/combo/manager/forms.py
+++ b/combo/manager/forms.py
@@ -148,23 +148,23 @@ class CellVisibilityForm(forms.Form):
if self.cleaned_data['visibility'] == 'all':
self.instance.public = True
self.instance.restricted_to_unlogged = False
- self.instance.groups = []
+ self.instance.groups.clear()
elif self.cleaned_data['visibility'] == 'logged':
self.instance.public = False
self.instance.restricted_to_unlogged = False
- self.instance.groups = []
+ self.instance.groups.clear()
elif self.cleaned_data['visibility'] == 'unlogged':
self.instance.public = True
self.instance.restricted_to_unlogged = True
- self.instance.groups = []
+ self.instance.groups.clear()
elif self.cleaned_data['visibility'] == 'groups-any':
self.instance.public = False
self.instance.restricted_to_unlogged = False
- self.instance.groups = self.cleaned_data['groups']
+ self.instance.groups.set(self.cleaned_data['groups'])
elif self.cleaned_data['visibility'] == 'groups-none':
self.instance.public = False
self.instance.restricted_to_unlogged = True
- self.instance.groups = self.cleaned_data['groups']
+ self.instance.groups.set(self.cleaned_data['groups'])
self.instance.save()
return self.instance
diff --git a/tests/test_dataviz.py b/tests/test_dataviz.py
index 79ce83b..363acdc 100644
--- a/tests/test_dataviz.py
+++ b/tests/test_dataviz.py
@@ -322,14 +322,14 @@ def test_chartng_cell_view(app, normal_user):
group = Group(name='plop')
group.save()
cell.public = False
- cell.groups = [group]
+ cell.groups.set([group])
cell.save()
resp = app.get('/api/dataviz/graph/1/?width=400', status=403)
app = login(app, username='normal-user', password='normal-user')
resp = app.get('/api/dataviz/graph/1/?width=400', status=403)
- normal_user.groups = [group]
+ normal_user.groups.set([group])
normal_user.save()
resp = app.get('/api/dataviz/graph/1/?width=400', status=200)
diff --git a/tests/test_import_export.py b/tests/test_import_export.py
index 9661c36..0d2c3fe 100644
--- a/tests/test_import_export.py
+++ b/tests/test_import_export.py
@@ -142,11 +142,11 @@ def test_group_restrictions_import_export(app, some_data):
group.save()
page = Page.objects.get(slug='one')
- page.groups = [group]
+ page.groups.set([group])
page.save()
cell = TextCell.objects.get(order=0)
- cell.groups = [group]
+ cell.groups.set([group])
cell.save()
output = get_output_of_command('export_site')
diff --git a/tests/test_lingo_manager.py b/tests/test_lingo_manager.py
index f1a93f7..4dccd3a 100644
--- a/tests/test_lingo_manager.py
+++ b/tests/test_lingo_manager.py
@@ -163,9 +163,9 @@ def test_download_transaction(app, admin_user, payment_backend):
bank_transaction_id='567', status=eopayment.PAID)
trans2 = Transaction.objects.create(regie=regie, remote_items='remote items omg', order_id='2', user=user,
bank_transaction_id='136', status=eopayment.PAID)
- trans1.items = [b_item,]
+ trans1.items.set([b_item])
trans1.save()
- trans2.items = [b_item,]
+ trans2.items.set([b_item])
trans2.save()
app = login(app)
resp = app.get('/manage/lingo/transactions/download-csv/', status=200)
diff --git a/tests/test_pages.py b/tests/test_pages.py
index 158aba3..b27db89 100644
--- a/tests/test_pages.py
+++ b/tests/test_pages.py
@@ -112,14 +112,14 @@ def test_page_visibility():
group.save()
user1 = User(username='foo')
user1.save()
- user1.groups = [group]
+ user1.groups.set([group])
user2 = User(username='bar')
user2.save()
assert page.is_visible(user1)
assert page.is_visible(user2)
- page.groups = [group]
+ page.groups.set([group])
assert not page.is_visible()
assert page.is_visible(user1)
assert not page.is_visible(user2)
diff --git a/tests/test_public.py b/tests/test_public.py
index 0ed730b..70a2b98 100644
--- a/tests/test_public.py
+++ b/tests/test_public.py
@@ -100,7 +100,7 @@ def test_page_contents_group_presence(app, normal_user):
cell = TextCell(page=page, placeholder='content', text='Foobar', order=0,
public=False)
cell.save()
- cell.groups = [group]
+ cell.groups.set([group])
resp = app.get('/', status=200)
assert 'Foobar' not in resp.text
@@ -108,7 +108,7 @@ def test_page_contents_group_presence(app, normal_user):
resp = app.get('/', status=200)
assert 'Foobar' not in resp.text
- normal_user.groups = [group]
+ normal_user.groups.set([group])
resp = app.get('/', status=200)
assert 'Foobar' in resp.text
@@ -121,7 +121,7 @@ def test_page_contents_group_absence(app, normal_user):
cell = TextCell(page=page, placeholder='content', text='Foobar', order=0,
public=False, restricted_to_unlogged=True)
cell.save()
- cell.groups = [group]
+ cell.groups.set([group])
resp = app.get('/', status=200)
assert 'Foobar' not in resp.text
@@ -129,7 +129,7 @@ def test_page_contents_group_absence(app, normal_user):
resp = app.get('/', status=200)
assert 'Foobar' in resp.text
- normal_user.groups = [group]
+ normal_user.groups.set([group])
resp = app.get('/', status=200)
assert 'Foobar' not in resp.text