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
|
||||
|
||||
|
||||
def hg_version():
|
||||
import socket
|
||||
import os
|
||||
@ -69,6 +70,7 @@ def hg_version():
|
||||
|
||||
return version
|
||||
|
||||
|
||||
import os, site
|
||||
|
||||
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 agenda.api import is_summary
|
||||
from utils.translation_ext import xugettext as _
|
||||
from utils.translation_ext import ugettext as _
|
||||
|
||||
|
||||
class Item(MPTTModel, SlideMixin):
|
||||
|
@ -23,7 +23,7 @@ from projector.models import SlideMixin
|
||||
from participant.models import Profile
|
||||
from config.models import config
|
||||
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
|
||||
|
||||
|
||||
|
@ -17,7 +17,7 @@ from participant.models import Profile
|
||||
from projector.projector import SlideMixin
|
||||
from projector.api import register_slidemodel
|
||||
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):
|
||||
prefix = 'assignment'
|
||||
|
@ -15,7 +15,7 @@ import base64
|
||||
from django.db import models
|
||||
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
|
||||
|
||||
|
@ -19,19 +19,8 @@ from utils.forms import CssClassMixin
|
||||
from utils.translation_ext import LocalizedModelMultipleChoiceField
|
||||
|
||||
# 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 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 = [
|
||||
@ -63,27 +52,26 @@ class UsernameForm(ModelForm, CssClassMixin):
|
||||
model = User
|
||||
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 Meta:
|
||||
model = Profile
|
||||
|
||||
class GroupForm(ModelForm, CssClassMixin):
|
||||
permissions = LocalizedModelMultipleChoiceField(queryset=Permission.objects.filter(codename__in=USER_VISIBLE_PERMISSIONS))
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(GroupForm, self).__init__(*args, **kwargs)
|
||||
if kwargs.get('instance', None) is not None:
|
||||
self.fields['permissions'].initial = [p.pk for p in kwargs['instance'].permissions.all()]
|
||||
class GroupForm(ModelForm, CssClassMixin):
|
||||
permissions = LocalizedModelMultipleChoiceField(queryset=Permission.objects.all())
|
||||
|
||||
class Meta:
|
||||
model = Group
|
||||
exclude = ('permissions',)
|
||||
|
||||
|
||||
class UsersettingsForm(UserEditForm, CssClassMixin):
|
||||
class Meta:
|
||||
model = User
|
||||
fields = ('username', 'first_name', 'last_name', 'email')
|
||||
|
||||
|
||||
class UserImportForm(Form, CssClassMixin):
|
||||
csvfile = FileField(widget=FileInput(attrs={'size':'50'}), label=_("CSV File"))
|
||||
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.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
|
||||
|
||||
class Profile(models.Model):
|
||||
|
@ -14,7 +14,7 @@ from django.db import models
|
||||
|
||||
from projector.api import register_slidemodel
|
||||
from projector.models import SlideMixin
|
||||
from utils.translation_ext import xugettext as _
|
||||
from utils.translation_ext import ugettext as _
|
||||
|
||||
class BaseOption(models.Model):
|
||||
poll = models.ForeignKey('BasePoll')
|
||||
|
@ -4,7 +4,7 @@ from api import register_slidemodel
|
||||
from projector import SlideMixin
|
||||
|
||||
from config.models import config
|
||||
from utils.translation_ext import xugettext as _
|
||||
from utils.translation_ext import ugettext as _
|
||||
|
||||
|
||||
class ProjectorSlide(models.Model, SlideMixin):
|
||||
|
@ -10,44 +10,47 @@
|
||||
: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
|
||||
|
||||
|
||||
class LocalizedModelChoiceField(ModelChoiceField):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(LocalizedModelChoiceField, self).__init__(*args, **kwargs)
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(LocalizedModelChoiceField, self).__init__(*args, **kwargs)
|
||||
|
||||
def _localized_get_choices(self):
|
||||
if hasattr(self, '_choices'):
|
||||
return self._choices
|
||||
def _localized_get_choices(self):
|
||||
if hasattr(self, '_choices'):
|
||||
return self._choices
|
||||
|
||||
c = []
|
||||
for (id, text) in super(LocalizedModelMultipleChoiceField, self)._get_choices():
|
||||
text = text.split(' | ')[-1]
|
||||
c.append((id, ugettext(text)))
|
||||
return c
|
||||
c = []
|
||||
for (id, text) in super(LocalizedModelMultipleChoiceField, self)._get_choices():
|
||||
text = text.split(' | ')[-1]
|
||||
c.append((id, ugettext(text)))
|
||||
return c
|
||||
|
||||
choices = property(_localized_get_choices, ChoiceField._set_choices)
|
||||
|
||||
choices = property(_localized_get_choices, ChoiceField._set_choices)
|
||||
|
||||
class LocalizedModelMultipleChoiceField(ModelMultipleChoiceField):
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.to_field_name = kwargs.get('to_field_name', None)
|
||||
super(LocalizedModelMultipleChoiceField, self).__init__(*args, **kwargs)
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.to_field_name = kwargs.get('to_field_name', None)
|
||||
super(LocalizedModelMultipleChoiceField, self).__init__(*args, **kwargs)
|
||||
|
||||
def _localized_get_choices(self):
|
||||
if hasattr(self, '_choices'):
|
||||
return self._choices
|
||||
def _localized_get_choices(self):
|
||||
if hasattr(self, '_choices'):
|
||||
return self._choices
|
||||
|
||||
c = []
|
||||
for (id, text) in super(LocalizedModelMultipleChoiceField, self)._get_choices():
|
||||
text = text.split(' | ')[-1]
|
||||
c.append((id, ugettext(text)))
|
||||
return c
|
||||
c = []
|
||||
for (id, text) in super(LocalizedModelMultipleChoiceField, self)._get_choices():
|
||||
text = text.split(' | ')[-1]
|
||||
c.append((id, ugettext(text)))
|
||||
return c
|
||||
|
||||
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:
|
||||
return msg
|
||||
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.auth.models import Permission
|
||||
from django.utils.translation import ugettext as _
|
||||
from django.db.models import signals
|
||||
|
||||
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)))
|
||||
|
||||
|
||||
def delete_default_permissions():
|
||||
def delete_default_permissions(**kwargs):
|
||||
for p in Permission.objects.all():
|
||||
if p.codename.startswith('add') or p.codename.startswith('delete') or p.codename.startswith('change'):
|
||||
p.delete()
|
||||
@ -123,3 +124,7 @@ def encodedict(dict):
|
||||
for key in dict:
|
||||
newdict[key] = [unicode(dict[key][0].decode('utf-8'))]
|
||||
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