remove default permission after syncdb
This commit is contained in:
parent
6f377453bc
commit
535795391d
@ -29,6 +29,7 @@ def get_version(version=None):
|
|||||||
|
|
||||||
return main + sub
|
return main + sub
|
||||||
|
|
||||||
|
|
||||||
def hg_version():
|
def hg_version():
|
||||||
import socket
|
import socket
|
||||||
import os
|
import os
|
||||||
@ -69,6 +70,7 @@ def hg_version():
|
|||||||
|
|
||||||
return version
|
return version
|
||||||
|
|
||||||
|
|
||||||
import os, site
|
import os, site
|
||||||
|
|
||||||
SITE_ROOT = os.path.realpath(os.path.dirname(__file__))
|
SITE_ROOT = os.path.realpath(os.path.dirname(__file__))
|
||||||
|
@ -25,7 +25,7 @@ from projector.projector import SlideMixin
|
|||||||
from projector.api import register_slidemodel
|
from projector.api import register_slidemodel
|
||||||
|
|
||||||
from agenda.api import is_summary
|
from agenda.api import is_summary
|
||||||
from utils.translation_ext import xugettext as _
|
from utils.translation_ext import ugettext as _
|
||||||
|
|
||||||
|
|
||||||
class Item(MPTTModel, SlideMixin):
|
class Item(MPTTModel, SlideMixin):
|
||||||
|
@ -23,7 +23,7 @@ from projector.models import SlideMixin
|
|||||||
from participant.models import Profile
|
from participant.models import Profile
|
||||||
from config.models import config
|
from config.models import config
|
||||||
from utils.utils import _propper_unicode
|
from utils.utils import _propper_unicode
|
||||||
from utils.translation_ext import xugettext as _
|
from utils.translation_ext import ugettext as _
|
||||||
from poll.models import BaseOption, BasePoll, CountVotesCast, CountInvalid, Vote
|
from poll.models import BaseOption, BasePoll, CountVotesCast, CountInvalid, Vote
|
||||||
|
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ from participant.models import Profile
|
|||||||
from projector.projector import SlideMixin
|
from projector.projector import SlideMixin
|
||||||
from projector.api import register_slidemodel
|
from projector.api import register_slidemodel
|
||||||
from poll.models import BasePoll, CountInvalid, CountVotesCast, BaseOption, PublishPollMixin
|
from poll.models import BasePoll, CountInvalid, CountVotesCast, BaseOption, PublishPollMixin
|
||||||
from utils.translation_ext import xugettext as _
|
from utils.translation_ext import ugettext as _
|
||||||
|
|
||||||
class Assignment(models.Model, SlideMixin):
|
class Assignment(models.Model, SlideMixin):
|
||||||
prefix = 'assignment'
|
prefix = 'assignment'
|
||||||
|
@ -15,7 +15,7 @@ import base64
|
|||||||
from django.db import models
|
from django.db import models
|
||||||
from django.dispatch import receiver
|
from django.dispatch import receiver
|
||||||
|
|
||||||
from utils.translation_ext import xugettext as _
|
from utils.translation_ext import ugettext as _
|
||||||
|
|
||||||
from openslides.config.signals import default_config_value
|
from openslides.config.signals import default_config_value
|
||||||
|
|
||||||
|
@ -19,19 +19,8 @@ from utils.forms import CssClassMixin
|
|||||||
from utils.translation_ext import LocalizedModelMultipleChoiceField
|
from utils.translation_ext import LocalizedModelMultipleChoiceField
|
||||||
|
|
||||||
# required for USER_VISIBLE_PERMISSIONS
|
# required for USER_VISIBLE_PERMISSIONS
|
||||||
from agenda.models import Item
|
|
||||||
from application.models import Application
|
|
||||||
from assignment.models import Assignment
|
|
||||||
from participant.models import Profile
|
from participant.models import Profile
|
||||||
from config.models import ConfigStore
|
|
||||||
|
|
||||||
USER_VISIBLE_PERMISSIONS = reduce(list.__add__, [
|
|
||||||
[p[0] for p in Item._meta.permissions],
|
|
||||||
[p[0] for p in Application._meta.permissions],
|
|
||||||
[p[0] for p in Assignment._meta.permissions],
|
|
||||||
[p[0] for p in Profile._meta.permissions],
|
|
||||||
[p[0] for p in ConfigStore._meta.permissions]
|
|
||||||
])
|
|
||||||
|
|
||||||
|
|
||||||
USER_APPLICATION_IMPORT_OPTIONS = [
|
USER_APPLICATION_IMPORT_OPTIONS = [
|
||||||
@ -63,27 +52,26 @@ class UsernameForm(ModelForm, CssClassMixin):
|
|||||||
model = User
|
model = User
|
||||||
exclude = ('first_name', 'last_name', 'email', 'is_active','is_superuser', 'groups', 'password', 'is_staff', 'last_login', 'date_joined', 'user_permissions')
|
exclude = ('first_name', 'last_name', 'email', 'is_active','is_superuser', 'groups', 'password', 'is_staff', 'last_login', 'date_joined', 'user_permissions')
|
||||||
|
|
||||||
|
|
||||||
class ProfileForm(ModelForm, CssClassMixin):
|
class ProfileForm(ModelForm, CssClassMixin):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Profile
|
model = Profile
|
||||||
|
|
||||||
class GroupForm(ModelForm, CssClassMixin):
|
|
||||||
permissions = LocalizedModelMultipleChoiceField(queryset=Permission.objects.filter(codename__in=USER_VISIBLE_PERMISSIONS))
|
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
class GroupForm(ModelForm, CssClassMixin):
|
||||||
super(GroupForm, self).__init__(*args, **kwargs)
|
permissions = LocalizedModelMultipleChoiceField(queryset=Permission.objects.all())
|
||||||
if kwargs.get('instance', None) is not None:
|
|
||||||
self.fields['permissions'].initial = [p.pk for p in kwargs['instance'].permissions.all()]
|
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Group
|
model = Group
|
||||||
exclude = ('permissions',)
|
exclude = ('permissions',)
|
||||||
|
|
||||||
|
|
||||||
class UsersettingsForm(UserEditForm, CssClassMixin):
|
class UsersettingsForm(UserEditForm, CssClassMixin):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = User
|
model = User
|
||||||
fields = ('username', 'first_name', 'last_name', 'email')
|
fields = ('username', 'first_name', 'last_name', 'email')
|
||||||
|
|
||||||
|
|
||||||
class UserImportForm(Form, CssClassMixin):
|
class UserImportForm(Form, CssClassMixin):
|
||||||
csvfile = FileField(widget=FileInput(attrs={'size':'50'}), label=_("CSV File"))
|
csvfile = FileField(widget=FileInput(attrs={'size':'50'}), label=_("CSV File"))
|
||||||
application_handling = ChoiceField(required=True, choices=USER_APPLICATION_IMPORT_OPTIONS, label=_("For existing applications"))
|
application_handling = ChoiceField(required=True, choices=USER_APPLICATION_IMPORT_OPTIONS, label=_("For existing applications"))
|
||||||
|
@ -14,7 +14,7 @@ from django.db import models
|
|||||||
from django.db.models import Q
|
from django.db.models import Q
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
|
|
||||||
from utils.translation_ext import xugettext as _
|
from utils.translation_ext import ugettext as _
|
||||||
from participant.api import gen_password
|
from participant.api import gen_password
|
||||||
|
|
||||||
class Profile(models.Model):
|
class Profile(models.Model):
|
||||||
|
@ -14,7 +14,7 @@ from django.db import models
|
|||||||
|
|
||||||
from projector.api import register_slidemodel
|
from projector.api import register_slidemodel
|
||||||
from projector.models import SlideMixin
|
from projector.models import SlideMixin
|
||||||
from utils.translation_ext import xugettext as _
|
from utils.translation_ext import ugettext as _
|
||||||
|
|
||||||
class BaseOption(models.Model):
|
class BaseOption(models.Model):
|
||||||
poll = models.ForeignKey('BasePoll')
|
poll = models.ForeignKey('BasePoll')
|
||||||
|
@ -4,7 +4,7 @@ from api import register_slidemodel
|
|||||||
from projector import SlideMixin
|
from projector import SlideMixin
|
||||||
|
|
||||||
from config.models import config
|
from config.models import config
|
||||||
from utils.translation_ext import xugettext as _
|
from utils.translation_ext import ugettext as _
|
||||||
|
|
||||||
|
|
||||||
class ProjectorSlide(models.Model, SlideMixin):
|
class ProjectorSlide(models.Model, SlideMixin):
|
||||||
|
@ -10,9 +10,10 @@
|
|||||||
:license: GNU GPL, see LICENSE for more details.
|
:license: GNU GPL, see LICENSE for more details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from django.utils.translation import ugettext
|
from django.utils.translation import ugettext as _ugettext
|
||||||
from django.forms import ChoiceField, ModelChoiceField, ModelMultipleChoiceField
|
from django.forms import ChoiceField, ModelChoiceField, ModelMultipleChoiceField
|
||||||
|
|
||||||
|
|
||||||
class LocalizedModelChoiceField(ModelChoiceField):
|
class LocalizedModelChoiceField(ModelChoiceField):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(LocalizedModelChoiceField, self).__init__(*args, **kwargs)
|
super(LocalizedModelChoiceField, self).__init__(*args, **kwargs)
|
||||||
@ -29,6 +30,7 @@ class LocalizedModelChoiceField(ModelChoiceField):
|
|||||||
|
|
||||||
choices = property(_localized_get_choices, ChoiceField._set_choices)
|
choices = property(_localized_get_choices, ChoiceField._set_choices)
|
||||||
|
|
||||||
|
|
||||||
class LocalizedModelMultipleChoiceField(ModelMultipleChoiceField):
|
class LocalizedModelMultipleChoiceField(ModelMultipleChoiceField):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
self.to_field_name = kwargs.get('to_field_name', None)
|
self.to_field_name = kwargs.get('to_field_name', None)
|
||||||
@ -46,8 +48,9 @@ class LocalizedModelMultipleChoiceField(ModelMultipleChoiceField):
|
|||||||
|
|
||||||
choices = property(_localized_get_choices, ChoiceField._set_choices)
|
choices = property(_localized_get_choices, ChoiceField._set_choices)
|
||||||
|
|
||||||
def xugettext(msg, fixstr=False):
|
|
||||||
|
def ugettext(msg, fixstr=False):
|
||||||
if fixstr:
|
if fixstr:
|
||||||
return msg
|
return msg
|
||||||
else:
|
else:
|
||||||
return ugettext(msg)
|
return _ugettext(msg)
|
||||||
|
@ -24,6 +24,7 @@ from django.core.context_processors import csrf
|
|||||||
from django.contrib import messages
|
from django.contrib import messages
|
||||||
from django.contrib.auth.models import Permission
|
from django.contrib.auth.models import Permission
|
||||||
from django.utils.translation import ugettext as _
|
from django.utils.translation import ugettext as _
|
||||||
|
from django.db.models import signals
|
||||||
|
|
||||||
from openslides.utils.signals import template_manipulation
|
from openslides.utils.signals import template_manipulation
|
||||||
|
|
||||||
@ -88,7 +89,7 @@ def render_to_forbitten(request, error=_("Sorry, you have no rights to see this
|
|||||||
return HttpResponseForbidden(render_to_string('403.html', {'error': error}, context_instance=RequestContext(request)))
|
return HttpResponseForbidden(render_to_string('403.html', {'error': error}, context_instance=RequestContext(request)))
|
||||||
|
|
||||||
|
|
||||||
def delete_default_permissions():
|
def delete_default_permissions(**kwargs):
|
||||||
for p in Permission.objects.all():
|
for p in Permission.objects.all():
|
||||||
if p.codename.startswith('add') or p.codename.startswith('delete') or p.codename.startswith('change'):
|
if p.codename.startswith('add') or p.codename.startswith('delete') or p.codename.startswith('change'):
|
||||||
p.delete()
|
p.delete()
|
||||||
@ -123,3 +124,7 @@ def encodedict(dict):
|
|||||||
for key in dict:
|
for key in dict:
|
||||||
newdict[key] = [unicode(dict[key][0].decode('utf-8'))]
|
newdict[key] = [unicode(dict[key][0].decode('utf-8'))]
|
||||||
return newdict
|
return newdict
|
||||||
|
|
||||||
|
|
||||||
|
signals.post_syncdb.connect(delete_default_permissions,
|
||||||
|
dispatch_uid = "openslides.utils.utils.delete_default_permissions")
|
||||||
|
Loading…
Reference in New Issue
Block a user