Browse Source

remove model's isAdmin field, and add a PropertyModelForm for the admin to set the aclAdmin property

Natenom/support-murmur-13-1446181288462
Michael Ziegler 15 years ago
parent
commit
6305a82c5b
  1. 4
      pyweb/mumble/admin.py
  2. 7
      pyweb/mumble/forms.py
  3. 4
      pyweb/mumble/models.py

4
pyweb/mumble/admin.py

@ -17,7 +17,7 @@
from django.contrib import admin from django.contrib import admin
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from mumble.forms import MumbleAdminForm
from mumble.forms import MumbleAdminForm, MumbleUserAdminForm
from mumble.models import Mumble, MumbleUser from mumble.models import Mumble, MumbleUser
class MumbleAdmin(admin.ModelAdmin): class MumbleAdmin(admin.ModelAdmin):
@ -82,6 +82,8 @@ class MumbleUserAdmin(admin.ModelAdmin):
search_fields = [ 'owner__username', 'name' ]; search_fields = [ 'owner__username', 'name' ];
ordering = [ 'owner__username' ]; ordering = [ 'owner__username' ];
form = MumbleUserAdminForm
def get_acl_admin( self, obj ): def get_acl_admin( self, obj ):
return obj.aclAdmin return obj.aclAdmin

7
pyweb/mumble/forms.py

@ -268,6 +268,13 @@ class MumbleUserLinkForm( MumbleUserForm ):
return self.cleaned_data; return self.cleaned_data;
class MumbleUserAdminForm( PropertyModelForm ):
aclAdmin = forms.BooleanField( label=_('Admin on root channel'), required=False );
class Meta:
model = Mumble;
class MumbleTextureForm( Form ): class MumbleTextureForm( Form ):
""" The form used to upload a new image to be set as texture. """ """ The form used to upload a new image to be set as texture. """
texturefile = forms.ImageField(); texturefile = forms.ImageField();

4
pyweb/mumble/models.py

@ -266,7 +266,6 @@ class Mumble( models.Model ):
playerinstance.name = playerdata.name; playerinstance.name = playerdata.name;
playerinstance.isAdmin = playerinstance.getAdmin();
playerinstance.save( dontConfigureMurmur=True ); playerinstance.save( dontConfigureMurmur=True );
@ -394,7 +393,6 @@ class MumbleUser( models.Model ):
password = models.CharField( _('Login password'), max_length = 200, blank=True ); password = models.CharField( _('Login password'), max_length = 200, blank=True );
server = models.ForeignKey( Mumble, verbose_name=_('Server instance'), related_name="mumbleuser_set" ); server = models.ForeignKey( Mumble, verbose_name=_('Server instance'), related_name="mumbleuser_set" );
owner = models.ForeignKey( User, verbose_name=_('Account owner'), related_name="mumbleuser_set", null=True, blank=True ); owner = models.ForeignKey( User, verbose_name=_('Account owner'), related_name="mumbleuser_set", null=True, blank=True );
isAdmin = models.BooleanField( _('Admin on root channel'), default = False );
class Meta: class Meta:
unique_together = ( ( 'server', 'owner' ), ( 'server', 'mumbleid' ) ); unique_together = ( ( 'server', 'owner' ), ( 'server', 'mumbleid' ) );
@ -448,8 +446,6 @@ class MumbleUser( models.Model ):
# Don't save the users' passwords, we don't need them anyway # Don't save the users' passwords, we don't need them anyway
self.password = ''; self.password = '';
self.aclAdmin = self.isAdmin;
# Now allow django to save the record set # Now allow django to save the record set
return models.Model.save( self ); return models.Model.save( self );

Loading…
Cancel
Save