Browse Source

add server ID to displayed fields, and calculate the bind port if it isn't set in the Model.

Natenom/support-murmur-13-1446181288462
Michael Ziegler 15 years ago
parent
commit
d5f2548833
  1. 18
      pyweb/mumble/admin.py

18
pyweb/mumble/admin.py

@ -14,6 +14,7 @@
* GNU General Public License for more details. * GNU General Public License for more details.
""" """
from django.conf import settings
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 _
@ -26,14 +27,27 @@ class MumbleServerAdmin(admin.ModelAdmin):
class MumbleAdmin(admin.ModelAdmin): class MumbleAdmin(admin.ModelAdmin):
""" Specification for the "Server administration" admin section. """ """ Specification for the "Server administration" admin section. """
list_display = [ 'name', 'addr', 'port', 'get_booted', 'get_is_public',
list_display = [ 'name', 'srvid', 'get_addr', 'get_port', 'get_booted', 'get_is_public',
'get_users_regged', 'get_users_online', 'get_channel_count' ]; 'get_users_regged', 'get_users_online', 'get_channel_count' ];
list_filter = [ 'addr' ];
list_filter = [ 'addr', 'server' ];
search_fields = [ 'name', 'addr', 'port' ]; search_fields = [ 'name', 'addr', 'port' ];
ordering = [ 'name' ]; ordering = [ 'name' ];
form = MumbleAdminForm; form = MumbleAdminForm;
def get_addr( self, obj ):
if not obj.addr:
return "*"
get_addr.short_description = _('Server Address')
def get_port( self, obj ):
if not obj.port:
return "< %d >" % (settings.MUMBLE_DEFAULT_PORT + obj.srvid - 1)
return obj.port
get_port.short_description = _('Server Port')
def get_booted( self, obj ): def get_booted( self, obj ):
return obj.booted return obj.booted

Loading…
Cancel
Save