mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-25 02:24:26 +00:00
Fix page permissions and fix migration when on sqlite backend
This commit is contained in:
parent
aa49b2d4ce
commit
12c49b285a
@ -2,7 +2,9 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
from club.models import Club
|
||||
from core.operations import PsqlRunOnly
|
||||
|
||||
|
||||
def generate_club_pages(apps, schema_editor):
|
||||
@ -32,7 +34,7 @@ class Migration(migrations.Migration):
|
||||
name='page',
|
||||
field=models.OneToOneField(related_name='club', blank=True, null=True, to='core.Page'),
|
||||
),
|
||||
migrations.RunSQL('SET CONSTRAINTS ALL IMMEDIATE', reverse_sql=migrations.RunSQL.noop),
|
||||
PsqlRunOnly('SET CONSTRAINTS ALL IMMEDIATE', reverse_sql=migrations.RunSQL.noop),
|
||||
migrations.RunPython(generate_club_pages),
|
||||
migrations.RunSQL(migrations.RunSQL.noop, reverse_sql='SET CONSTRAINTS ALL IMMEDIATE'),
|
||||
PsqlRunOnly(migrations.RunSQL.noop, reverse_sql='SET CONSTRAINTS ALL IMMEDIATE'),
|
||||
]
|
||||
|
@ -893,7 +893,7 @@ class Page(models.Model):
|
||||
)
|
||||
|
||||
def can_be_edited_by(self, user):
|
||||
if self.is_club_page and self.club.can_be_edited_by(user):
|
||||
if hasattr(self, 'club') and self.club.can_be_edited_by(user):
|
||||
# Override normal behavior for clubs
|
||||
return True
|
||||
return False
|
||||
|
32
core/operations.py
Normal file
32
core/operations.py
Normal file
@ -0,0 +1,32 @@
|
||||
# -*- coding:utf-8 -*
|
||||
#
|
||||
# Copyright 2016,2017
|
||||
# - Sli <antoine@bartuccio.fr>
|
||||
#
|
||||
# Ce fichier fait partie du site de l'Association des Étudiants de l'UTBM,
|
||||
# http://ae.utbm.fr.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify it under
|
||||
# the terms of the GNU General Public License a published by the Free Software
|
||||
# Foundation; either version 3 of the License, or (at your option) any later
|
||||
# version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
# details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along with
|
||||
# this program; if not, write to the Free Sofware Foundation, Inc., 59 Temple
|
||||
# Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
#
|
||||
|
||||
from django.db import connection, migrations
|
||||
|
||||
|
||||
class PsqlRunOnly(migrations.RunSQL):
|
||||
|
||||
def _run_sql(self, schema_editor, sqls):
|
||||
if connection.vendor == 'postgresql':
|
||||
super(PsqlRunOnly, self)._run_sql(schema_editor, sqls)
|
10
core/urls.py
10
core/urls.py
@ -87,9 +87,9 @@ urlpatterns = [
|
||||
url(r'^page/$', PageListView.as_view(), name='page_list'),
|
||||
url(r'^page/create$', PageCreateView.as_view(), name='page_new'),
|
||||
url(r'^page/(?P<page_id>[0-9]*)/delete$', PageDeleteView.as_view(), name='page_delete'),
|
||||
url(r'^page/(?P<page_name>[a-zA-Z0-9][a-zA-Z0-9._-]*[a-zA-Z0-9])/edit$', PageEditView.as_view(), name='page_edit'),
|
||||
url(r'^page/(?P<page_name>[a-zA-Z0-9][a-zA-Z0-9._-]*[a-zA-Z0-9])/prop$', PagePropView.as_view(), name='page_prop'),
|
||||
url(r'^page/(?P<page_name>[a-zA-Z0-9][a-zA-Z0-9._-]*[a-zA-Z0-9])/hist$', PageHistView.as_view(), name='page_hist'),
|
||||
url(r'^page/(?P<page_name>[a-zA-Z0-9][a-zA-Z0-9._-]*[a-zA-Z0-9])/rev/(?P<rev>[0-9]+)/', PageRevView.as_view(), name='page_rev'),
|
||||
url(r'^page/(?P<page_name>[a-zA-Z0-9][a-zA-Z0-9._-]*[a-zA-Z0-9])/$', PageView.as_view(), name='page'),
|
||||
url(r'^page/(?P<page_name>([/a-zA-Z0-9][a-zA-Z0-9._-]*[a-zA-Z0-9])+)/edit$', PageEditView.as_view(), name='page_edit'),
|
||||
url(r'^page/(?P<page_name>([/a-zA-Z0-9][a-zA-Z0-9._-]*[a-zA-Z0-9])+)/prop$', PagePropView.as_view(), name='page_prop'),
|
||||
url(r'^page/(?P<page_name>([/a-zA-Z0-9][a-zA-Z0-9._-]*[a-zA-Z0-9])+)/hist$', PageHistView.as_view(), name='page_hist'),
|
||||
url(r'^page/(?P<page_name>([/a-zA-Z0-9][a-zA-Z0-9._-]*[a-zA-Z0-9])+)/rev/(?P<rev>[0-9]+)/', PageRevView.as_view(), name='page_rev'),
|
||||
url(r'^page/(?P<page_name>([/a-zA-Z0-9][a-zA-Z0-9._-]*[a-zA-Z0-9])+)/$', PageView.as_view(), name='page'),
|
||||
]
|
||||
|
Loading…
Reference in New Issue
Block a user