Forked mumble-django project from https://bitbucket.org/Svedrin/mumble-django
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

102 lines
2.8 KiB

16 years ago
16 years ago
16 years ago
16 years ago
16 years ago
16 years ago
  1. # -*- coding: utf-8 -*-
  2. """
  3. * Copyright © 2009-2010, Michael "Svedrin" Ziegler <diese-addy@funzt-halt.net>
  4. *
  5. * Mumble-Django is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This package is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. """
  15. from django.contrib import admin
  16. from django.utils.translation import ugettext_lazy as _
  17. from mumble.forms import MumbleAdminForm, MumbleUserAdminForm
  18. from mumble.models import MumbleServer, Mumble, MumbleUser
  19. class MumbleAdmin(admin.ModelAdmin):
  20. """ Specification for the "Server administration" admin section. """
  21. list_display = [ 'name', 'addr', 'port', 'get_booted', 'get_is_public',
  22. 'get_users_regged', 'get_users_online', 'get_channel_count' ];
  23. list_filter = [ 'addr' ];
  24. search_fields = [ 'name', 'addr', 'port' ];
  25. ordering = [ 'name' ];
  26. form = MumbleAdminForm;
  27. def get_booted( self, obj ):
  28. return obj.booted
  29. get_booted.short_description = _('Boot Server')
  30. get_booted.boolean = True
  31. def get_users_regged( self, obj ):
  32. """ Populates the "Registered users" column. """
  33. if obj.booted:
  34. return obj.users_regged;
  35. else:
  36. return '-';
  37. get_users_regged.short_description = _( 'Registered users' );
  38. def get_users_online( self, obj ):
  39. """ Populates the "Online users" column. """
  40. if obj.booted:
  41. return obj.users_online;
  42. else:
  43. return '-';
  44. get_users_online.short_description = _( 'Online users' );
  45. def get_channel_count( self, obj ):
  46. """ Populates the "Channel Count" column. """
  47. if obj.booted:
  48. return obj.channel_cnt;
  49. else:
  50. return '-';
  51. get_channel_count.short_description = _( 'Channel count' );
  52. def get_is_public( self, obj ):
  53. """ Populates the "Public" column. """
  54. if obj.booted:
  55. if obj.is_public:
  56. return _( 'Yes' );
  57. else:
  58. return _( 'No' );
  59. else:
  60. return '-';
  61. get_is_public.short_description = _( 'Public' );
  62. class MumbleUserAdmin(admin.ModelAdmin):
  63. """ Specification for the "Registered users" admin section. """
  64. list_display = [ 'owner', 'server', 'name', 'get_acl_admin' ];
  65. list_filter = [ 'server' ];
  66. search_fields = [ 'owner__username', 'name' ];
  67. ordering = [ 'owner__username' ];
  68. form = MumbleUserAdminForm
  69. def get_acl_admin( self, obj ):
  70. return obj.aclAdmin
  71. get_acl_admin.short_description = _('Admin on root channel')
  72. get_acl_admin.boolean = True
  73. admin.site.register( MumbleServer );
  74. admin.site.register( Mumble, MumbleAdmin );
  75. admin.site.register( MumbleUser, MumbleUserAdmin );