diff --git a/pyweb/mumble/MumbleCtlIce.py b/pyweb/mumble/MumbleCtlIce.py index 30f3bf1..9b7f18f 100644 --- a/pyweb/mumble/MumbleCtlIce.py +++ b/pyweb/mumble/MumbleCtlIce.py @@ -632,6 +632,15 @@ class MumbleCtlIce_120(MumbleCtlIce_118): srvbans.append( Ban( **kwargs ) ) return self.setBans(srvid, srvbans) + @protectDjangoErrPage + def removeBan(self, srvid, **kwargs): + return self.setBans(srvid, [ + # keep all bans which don't match exactly the one we're looking for + ban for ban in self.getBans(srvid) + # if one of those attr checks fails (-> False), min() is False -> keep the thing + if not min([ getattr(ban, kw) == kwargs[kw] for kw in kwargs ]) + ]) + @protectDjangoErrPage def kickUser(self, srvid, userid, reason=""): return self._getIceServerObject(srvid).kickUser( userid, reason.encode("UTF-8") ) diff --git a/pyweb/mumble/media/js/banviewer.js b/pyweb/mumble/media/js/banviewer.js index d5598fe..c694e35 100644 --- a/pyweb/mumble/media/js/banviewer.js +++ b/pyweb/mumble/media/js/banviewer.js @@ -36,12 +36,23 @@ Ext.ux.BanViewerPanel = function( config ){ dataIndex: 'reason' }]), bbar: [{ - iconCls: 'x-tbar-loading', - tooltip: gettext('Refresh'), - handler: function(){ - this.ownerCt.ownerCt.store.reload(); - } - }], + iconCls: 'x-tbar-loading', + tooltip: gettext('Refresh'), + handler: function(){ + this.ownerCt.ownerCt.store.reload(); + } + }, { + text: gettext('Delete'), + handler: function(){ + var grid = this.ownerCt.ownerCt; + var mdl = grid.getSelectionModel(); + if( mdl.hasSelection() ){ + Mumble.removeBan(this.ownerCt.ownerCt.server, mdl.selection.record.data, function(){ + grid.store.reload(); + }); + } + } + }], store: new Ext.data.DirectStore({ baseParams: {'server': this.server}, directFn: Mumble.bans, diff --git a/pyweb/mumble/models.py b/pyweb/mumble/models.py index 27e593e..c3a9ea5 100644 --- a/pyweb/mumble/models.py +++ b/pyweb/mumble/models.py @@ -317,6 +317,9 @@ class Mumble( models.Model ): def getBans( self ): return self.ctl.getBans( self.srvid ) + def removeBan( self, **kwargs ): + return self.ctl.removeBan( self.srvid, **kwargs ) + def getConf( self, field ): return self.ctl.getConf( self.srvid, field ) diff --git a/pyweb/mumble/views.py b/pyweb/mumble/views.py index 5042cd9..96fb9e4 100644 --- a/pyweb/mumble/views.py +++ b/pyweb/mumble/views.py @@ -292,6 +292,18 @@ def bans( request, server ): for ent in srv.getBans() ], 'success': True } +@EXT_DIRECT_PROVIDER.register_method( "Mumble" ) +def removeBan( request, server, bandata ): + """ Retrieve bans. """ + srv = get_object_or_404( Mumble, id=int(server) ) + if not srv.isUserAdmin( request.user ): + raise Exception( "Access denied" ) + if "addrstr" in bandata: + del bandata["addrstr"] + bandata["address"] = tuple(bandata["address"]) + return srv.removeBan( **bandata ) + + @EXT_DIRECT_PROVIDER.register_method( "Mumble" ) def moveUser( request, server, sessionid, channelid ): srv = get_object_or_404( Mumble, id=int(server) )