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