mirror of
https://github.com/ae-utbm/sith.git
synced 2024-12-22 15:51:19 +00:00
Sync pages with club unix_name
This commit is contained in:
parent
fe69cbcee1
commit
939146bddd
@ -105,22 +105,24 @@ class Club(models.Model):
|
||||
self.save()
|
||||
|
||||
def make_page(self):
|
||||
root = User.objects.filter(username="root").first()
|
||||
if not self.page:
|
||||
root = User.objects.filter(username="root").first()
|
||||
club_root = Page.objects.filter(name=settings.SITH_CLUB_ROOT_PAGE).first()
|
||||
if root and club_root:
|
||||
public = Group.objects.filter(id=settings.SITH_GROUP_PUBLIC_ID).first()
|
||||
office = Group.objects.filter(name=self.unix_name + settings.SITH_BOARD_SUFFIX).first()
|
||||
p = Page(name=self.unix_name)
|
||||
p.parent = club_root
|
||||
p.set_lock(root)
|
||||
if public:
|
||||
p.view_groups.add(public)
|
||||
if office:
|
||||
p.edit_groups.add(office)
|
||||
p.save()
|
||||
self.page = p
|
||||
self.save()
|
||||
elif self.page and self.page.name != self.unix_name:
|
||||
self.page.unset_lock()
|
||||
self.page.set_lock(root)
|
||||
self.page.name = self.unix_name
|
||||
self.page.save()
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
with transaction.atomic():
|
||||
@ -142,7 +144,7 @@ class Club(models.Model):
|
||||
self.home.edit_groups = [board]
|
||||
self.home.view_groups = [member, subscribers]
|
||||
self.home.save()
|
||||
self.make_page()
|
||||
self.make_page()
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
@ -85,6 +85,12 @@ class Command(BaseCommand):
|
||||
profiles_root.save()
|
||||
home_root = SithFile(parent=None, name="users", is_folder=True, owner=root)
|
||||
home_root.save()
|
||||
|
||||
# Page needed for club creation
|
||||
p = Page(name=settings.SITH_CLUB_ROOT_PAGE)
|
||||
p.set_lock(root)
|
||||
p.save()
|
||||
|
||||
club_root = SithFile(parent=None, name="clubs", is_folder=True, owner=root)
|
||||
club_root.save()
|
||||
SithFile(parent=None, name="SAS", is_folder=True, owner=root).save()
|
||||
@ -147,10 +153,6 @@ Welcome to the wiki page!
|
||||
p.set_lock(root)
|
||||
PageRev(page=p, title="Laverie", author=root, content="Fonctionnement de la laverie").save()
|
||||
|
||||
p = Page(name=settings.SITH_CLUB_ROOT_PAGE)
|
||||
p.set_lock(root)
|
||||
p.save()
|
||||
|
||||
# Here we add a lot of test datas, that are not necessary for the Sith, but that provide a basic development environment
|
||||
if not options['prod']:
|
||||
# Adding user Skia
|
||||
|
@ -892,6 +892,12 @@ class Page(models.Model):
|
||||
code='loop',
|
||||
)
|
||||
|
||||
def can_be_edited_by(self, user):
|
||||
if self.is_club_page and self.club.can_be_edited_by(user):
|
||||
# Override normal behavior for clubs
|
||||
return True
|
||||
return False
|
||||
|
||||
def get_parent_list(self):
|
||||
l = []
|
||||
p = self.parent
|
||||
|
Loading…
Reference in New Issue
Block a user