Browse Source

implement removing bans. (Natenom: you owe me a cookie.)

Natenom/support-murmur-13-1446181288462
Michael Ziegler 14 years ago
parent
commit
e6cf9ca4f3
  1. 9
      pyweb/mumble/MumbleCtlIce.py
  2. 23
      pyweb/mumble/media/js/banviewer.js
  3. 3
      pyweb/mumble/models.py
  4. 12
      pyweb/mumble/views.py

9
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") )

23
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,

3
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 )

12
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) )

Loading…
Cancel
Save