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.

45 lines
1.3 KiB

  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.db import connection
  16. from django.db.models import signals
  17. from mumble import models
  18. from update_schema import update_schema
  19. from server_detect import find_existing_instances
  20. cursor = connection.cursor()
  21. tablename = models.Mumble._meta.db_table
  22. uptodate = False
  23. if tablename in connection.introspection.get_table_list(cursor):
  24. fields = connection.introspection.get_table_description(cursor, tablename)
  25. for entry in fields:
  26. if entry[0] == "server_id":
  27. uptodate = True
  28. break
  29. else:
  30. # Table doesn't yet exist, so syncdb will create it properly
  31. uptodate = True
  32. if not uptodate:
  33. signals.post_syncdb.connect( update_schema, sender=models );
  34. else:
  35. signals.post_syncdb.connect( find_existing_instances, sender=models );