mirror of
https://github.com/ae-utbm/sith.git
synced 2024-12-22 15:51:19 +00:00
django2.2: remove direct assignments to many-to-many fields
This commit is contained in:
parent
97c316b62e
commit
99c8d95443
@ -190,8 +190,8 @@ class Club(models.Model):
|
|||||||
name=settings.SITH_MAIN_MEMBERS_GROUP
|
name=settings.SITH_MAIN_MEMBERS_GROUP
|
||||||
).first()
|
).first()
|
||||||
self.make_home()
|
self.make_home()
|
||||||
self.home.edit_groups = [board]
|
self.home.edit_groups.set([board])
|
||||||
self.home.view_groups = [member, subscribers]
|
self.home.view_groups.set([member, subscribers])
|
||||||
self.home.save()
|
self.home.save()
|
||||||
self.make_page()
|
self.make_page()
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ class ComTest(TestCase):
|
|||||||
self.com_group = RealGroup.objects.filter(
|
self.com_group = RealGroup.objects.filter(
|
||||||
id=settings.SITH_GROUP_COM_ADMIN_ID
|
id=settings.SITH_GROUP_COM_ADMIN_ID
|
||||||
).first()
|
).first()
|
||||||
self.skia.groups = [self.com_group]
|
self.skia.groups.set([self.com_group])
|
||||||
self.skia.save()
|
self.skia.save()
|
||||||
self.client.login(username=self.skia.username, password="plop")
|
self.client.login(username=self.skia.username, password="plop")
|
||||||
|
|
||||||
|
@ -142,18 +142,18 @@ class Command(BaseCommand):
|
|||||||
g.save()
|
g.save()
|
||||||
c = Counter(id=b[0], name=b[1], club=bar_club, type="BAR")
|
c = Counter(id=b[0], name=b[1], club=bar_club, type="BAR")
|
||||||
c.save()
|
c.save()
|
||||||
c.edit_groups = [g]
|
g.editable_counters.add(c)
|
||||||
c.save()
|
g.save()
|
||||||
self.reset_index("counter")
|
self.reset_index("counter")
|
||||||
Counter(name="Eboutic", club=main_club, type="EBOUTIC").save()
|
Counter(name="Eboutic", club=main_club, type="EBOUTIC").save()
|
||||||
Counter(name="AE", club=main_club, type="OFFICE").save()
|
Counter(name="AE", club=main_club, type="OFFICE").save()
|
||||||
|
|
||||||
home_root.view_groups = [
|
home_root.view_groups.set(
|
||||||
Group.objects.filter(name=settings.SITH_MAIN_MEMBERS_GROUP).first()
|
[Group.objects.filter(name=settings.SITH_MAIN_MEMBERS_GROUP).first()]
|
||||||
]
|
)
|
||||||
club_root.view_groups = [
|
club_root.view_groups.set(
|
||||||
Group.objects.filter(name=settings.SITH_MAIN_MEMBERS_GROUP).first()
|
[Group.objects.filter(name=settings.SITH_MAIN_MEMBERS_GROUP).first()]
|
||||||
]
|
)
|
||||||
home_root.save()
|
home_root.save()
|
||||||
club_root.save()
|
club_root.save()
|
||||||
|
|
||||||
@ -163,7 +163,7 @@ class Command(BaseCommand):
|
|||||||
p = Page(name="Index")
|
p = Page(name="Index")
|
||||||
p.set_lock(root)
|
p.set_lock(root)
|
||||||
p.save()
|
p.save()
|
||||||
p.view_groups = [settings.SITH_GROUP_PUBLIC_ID]
|
p.view_groups.set([settings.SITH_GROUP_PUBLIC_ID])
|
||||||
p.set_lock(root)
|
p.set_lock(root)
|
||||||
p.save()
|
p.save()
|
||||||
PageRev(
|
PageRev(
|
||||||
@ -178,7 +178,7 @@ Welcome to the wiki page!
|
|||||||
p = Page(name="services")
|
p = Page(name="services")
|
||||||
p.set_lock(root)
|
p.set_lock(root)
|
||||||
p.save()
|
p.save()
|
||||||
p.view_groups = [settings.SITH_GROUP_PUBLIC_ID]
|
p.view_groups.set([settings.SITH_GROUP_PUBLIC_ID])
|
||||||
p.set_lock(root)
|
p.set_lock(root)
|
||||||
PageRev(
|
PageRev(
|
||||||
page=p,
|
page=p,
|
||||||
@ -297,9 +297,13 @@ Welcome to the wiki page!
|
|||||||
counter.view_groups = [
|
counter.view_groups = [
|
||||||
Group.objects.filter(name=settings.SITH_MAIN_MEMBERS_GROUP).first().id
|
Group.objects.filter(name=settings.SITH_MAIN_MEMBERS_GROUP).first().id
|
||||||
]
|
]
|
||||||
counter.groups = [
|
counter.groups.set(
|
||||||
Group.objects.filter(id=settings.SITH_GROUP_COUNTER_ADMIN_ID).first().id
|
[
|
||||||
]
|
Group.objects.filter(id=settings.SITH_GROUP_COUNTER_ADMIN_ID)
|
||||||
|
.first()
|
||||||
|
.id
|
||||||
|
]
|
||||||
|
)
|
||||||
counter.save()
|
counter.save()
|
||||||
# Adding user Comptable
|
# Adding user Comptable
|
||||||
comptable = User(
|
comptable = User(
|
||||||
@ -316,11 +320,13 @@ Welcome to the wiki page!
|
|||||||
comptable.view_groups = [
|
comptable.view_groups = [
|
||||||
Group.objects.filter(name=settings.SITH_MAIN_MEMBERS_GROUP).first().id
|
Group.objects.filter(name=settings.SITH_MAIN_MEMBERS_GROUP).first().id
|
||||||
]
|
]
|
||||||
comptable.groups = [
|
comptable.groups.set(
|
||||||
Group.objects.filter(id=settings.SITH_GROUP_ACCOUNTING_ADMIN_ID)
|
[
|
||||||
.first()
|
Group.objects.filter(id=settings.SITH_GROUP_ACCOUNTING_ADMIN_ID)
|
||||||
.id
|
.first()
|
||||||
]
|
.id
|
||||||
|
]
|
||||||
|
)
|
||||||
comptable.save()
|
comptable.save()
|
||||||
# Adding user Guy
|
# Adding user Guy
|
||||||
u = User(
|
u = User(
|
||||||
@ -359,11 +365,11 @@ Welcome to the wiki page!
|
|||||||
PageRev(
|
PageRev(
|
||||||
page=p, title="Aide sur la syntaxe", author=skia, content=rm.read()
|
page=p, title="Aide sur la syntaxe", author=skia, content=rm.read()
|
||||||
).save()
|
).save()
|
||||||
p.view_groups = [settings.SITH_GROUP_PUBLIC_ID]
|
p.view_groups.set([settings.SITH_GROUP_PUBLIC_ID])
|
||||||
p.save(force_lock=True)
|
p.save(force_lock=True)
|
||||||
p = Page(name="Services")
|
p = Page(name="Services")
|
||||||
p.save(force_lock=True)
|
p.save(force_lock=True)
|
||||||
p.view_groups = [settings.SITH_GROUP_PUBLIC_ID]
|
p.view_groups.set([settings.SITH_GROUP_PUBLIC_ID])
|
||||||
p.save(force_lock=True)
|
p.save(force_lock=True)
|
||||||
PageRev(
|
PageRev(
|
||||||
page=p,
|
page=p,
|
||||||
@ -842,9 +848,9 @@ Welcome to the wiki page!
|
|||||||
)
|
)
|
||||||
comunity.set_password("plop")
|
comunity.set_password("plop")
|
||||||
comunity.save()
|
comunity.save()
|
||||||
comunity.groups = [
|
comunity.groups.set(
|
||||||
Group.objects.filter(name="Communication admin").first().id
|
[Group.objects.filter(name="Communication admin").first().id]
|
||||||
]
|
)
|
||||||
comunity.save()
|
comunity.save()
|
||||||
Membership(
|
Membership(
|
||||||
user=comunity,
|
user=comunity,
|
||||||
@ -862,7 +868,7 @@ Welcome to the wiki page!
|
|||||||
)
|
)
|
||||||
tutu.set_password("plop")
|
tutu.set_password("plop")
|
||||||
tutu.save()
|
tutu.save()
|
||||||
tutu.groups = [settings.SITH_GROUP_PEDAGOGY_ADMIN_ID]
|
tutu.groups.set([settings.SITH_GROUP_PEDAGOGY_ADMIN_ID])
|
||||||
tutu.save()
|
tutu.save()
|
||||||
|
|
||||||
# Adding subscription for sli
|
# Adding subscription for sli
|
||||||
|
@ -948,8 +948,8 @@ class SithFile(models.Model):
|
|||||||
def copy_rights(self):
|
def copy_rights(self):
|
||||||
"""Copy, if possible, the rights of the parent folder"""
|
"""Copy, if possible, the rights of the parent folder"""
|
||||||
if self.parent is not None:
|
if self.parent is not None:
|
||||||
self.edit_groups = self.parent.edit_groups.all()
|
self.edit_groups.set(self.parent.edit_groups.all())
|
||||||
self.view_groups = self.parent.view_groups.all()
|
self.view_groups.set(self.parent.view_groups.all())
|
||||||
self.save()
|
self.save()
|
||||||
|
|
||||||
def move_to(self, parent):
|
def move_to(self, parent):
|
||||||
|
@ -152,8 +152,8 @@ class Forum(models.Model):
|
|||||||
"""Copy, if possible, the rights of the parent folder"""
|
"""Copy, if possible, the rights of the parent folder"""
|
||||||
if self.parent is not None:
|
if self.parent is not None:
|
||||||
self.owner_club = self.parent.owner_club
|
self.owner_club = self.parent.owner_club
|
||||||
self.edit_groups = self.parent.edit_groups.all()
|
self.edit_groups.set(self.parent.edit_groups.all())
|
||||||
self.view_groups = self.parent.view_groups.all()
|
self.view_groups.set(self.parent.view_groups.all())
|
||||||
self.save()
|
self.save()
|
||||||
|
|
||||||
_club_memberships = {} # This cache is particularly efficient:
|
_club_memberships = {} # This cache is particularly efficient:
|
||||||
|
Loading…
Reference in New Issue
Block a user