Browse Source

implement basic kicking of users. todo: banning/moving. see #81

Natenom/support-murmur-13-1446181288462
Michael Ziegler 15 years ago
parent
commit
8e8fb6237e
  1. 12
      pyweb/mumble/MumbleCtlIce.py
  2. 6
      pyweb/mumble/forms.py
  3. 3
      pyweb/mumble/models.py
  4. 20
      pyweb/mumble/templates/mumble/mumble.html
  5. 8
      pyweb/mumble/views.py

12
pyweb/mumble/MumbleCtlIce.py

@ -501,6 +501,18 @@ class MumbleCtlIce_120(MumbleCtlIce_118):
@protectDjangoErrPage @protectDjangoErrPage
def setACL(self, srvid, channelid, acls, groups, inherit): def setACL(self, srvid, channelid, acls, groups, inherit):
return self._getIceServerObject(srvid).setACL( channelid, acls, groups, inherit ); return self._getIceServerObject(srvid).setACL( channelid, acls, groups, inherit );
@protectDjangoErrPage
def getBans(self, srvid):
return self._getIceServerObject(srvid).getBans();
@protectDjangoErrPage
def setBans(self, srvid, bans):
return self._getIceServerObject(srvid).setBans(bans);
@protectDjangoErrPage
def kickUser(self, srvid, userid, reason=""):
return self._getIceServerObject(srvid).kickUser( userid, reason.encode("UTF-8") );
class MumbleCtlIce_122(MumbleCtlIce_120): class MumbleCtlIce_122(MumbleCtlIce_120):

6
pyweb/mumble/forms.py

@ -297,6 +297,12 @@ class MumbleUserAdminForm( PropertyModelForm ):
model = Mumble; model = Mumble;
class MumbleKickForm( Form ):
session = forms.IntegerField();
ban = forms.BooleanField( required=False );
reason = forms.CharField( required=False );
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();

3
pyweb/mumble/models.py

@ -457,6 +457,9 @@ class Mumble( models.Model ):
raise AttributeError( _( "This field must not be updated once the record has been saved." ) ); raise AttributeError( _( "This field must not be updated once the record has been saved." ) );
models.Model.__setattr__( self, name, value ); models.Model.__setattr__( self, name, value );
def kickUser( self, sessionid, reason="" ):
return self.ctl.kickUser( self.srvid, sessionid, reason );

20
pyweb/mumble/templates/mumble/mumble.html

@ -137,6 +137,26 @@
<img src="{% url mumble.views.showTexture DBaseObject.id item.mumbleuser.id %}" alt="user texture" /> <img src="{% url mumble.views.showTexture DBaseObject.id item.mumbleuser.id %}" alt="user texture" />
</fieldset> </fieldset>
{% endif %} {% endif %}
{% if CurrentUserIsAdmin or user.is_staff %}
<fieldset>
<legend>{% trans "Kick user" %}</legend>
<form action="{% url mumble.views.show DBaseObject.id %}" method="POST">
<input type="hidden" name="mode" value="kick" />
<input type="hidden" name="session" value="{{ item.session }}" />
<ul>
<li>
<label for="inp_reason">{% trans "Reason" %}</label>
<input type="text" name="reason" value="" id="inp_reason" />
</li>
<li>
<input type="checkbox" name="ban" value="1" id="inp_ban" />
<label for="inp_ban">{% trans "Ban user" %}</label>
</li>
</ul>
<input type="submit" value="{% trans "Kick user" %}" />
</form>
</fieldset>
{% endif %}
</div> </div>
{% else %} {% else %}
<div id="mumble_{{ item.id }}" class="mumble-ext x-hide-display"> <div id="mumble_{{ item.id }}" class="mumble-ext x-hide-display">

8
pyweb/mumble/views.py

@ -29,7 +29,7 @@ from django.contrib.auth import views as auth_views
from models import Mumble, MumbleUser from models import Mumble, MumbleUser
from forms import MumbleForm, MumbleUserForm, MumbleUserPasswordForm from forms import MumbleForm, MumbleUserForm, MumbleUserPasswordForm
from forms import MumbleUserLinkForm, MumbleTextureForm
from forms import MumbleUserLinkForm, MumbleTextureForm, MumbleKickForm
def redir( request ): def redir( request ):
@ -165,6 +165,12 @@ def show( request, server ):
regform = None; regform = None;
textureform = None; textureform = None;
if isAdmin:
if request.method == 'POST' and 'mode' in request.POST and request.POST['mode'] == 'kick':
kickform = MumbleKickForm( request.POST );
if kickform.is_valid():
srv.kickUser( kickform.cleaned_data['session'], kickform.cleaned_data['reason'] );
# ChannelTable is a somewhat misleading name, as it actually contains channels and players. # ChannelTable is a somewhat misleading name, as it actually contains channels and players.
channelTable = []; channelTable = [];
for cid in srv.channels: for cid in srv.channels:

Loading…
Cancel
Save