Fixes to table creation
authorStas Shtin <antisvin@gmail.com>
Sun, 11 Apr 2010 12:38:09 +0000 (16:38 +0400)
committerStas Shtin <antisvin@gmail.com>
Sun, 11 Apr 2010 12:38:09 +0000 (16:38 +0400)
src/ipypbx/controllers.py
src/ipypbx/create.sql
src/ipypbx/main.py
src/ipypbxweb/models.py

index 1cb00a4..a196a27 100644 (file)
@@ -15,7 +15,6 @@
 # You should have received a copy of the GNU General Public License
 # along with IPyPBX.  If not, see <http://www.gnu.org/licenses/>.
 
-#from ipypbx import models
 from PyQt4 import QtCore, QtGui, QtSql
 
 
index 4c95e8e..e913aba 100644 (file)
@@ -1,4 +1,3 @@
-BEGIN;
 CREATE TABLE "ipypbxweb_connection" (
     "id" integer NOT NULL PRIMARY KEY,
     "name" varchar(100) NOT NULL,
@@ -47,7 +46,7 @@ CREATE TABLE "ipypbxweb_endpoint" (
     "id" integer NOT NULL PRIMARY KEY,
     "user_id" varchar(100) NOT NULL,
     "password" varchar(100) NOT NULL,
-    "domain" varchar(100) NOT NULL,
+    "domain_id" integer NOT NULL REFERENCES "ipypbxweb_domain" ("id"),
     "is_active" bool NOT NULL
 )
 ;
@@ -55,7 +54,7 @@ CREATE TABLE "ipypbxweb_extension" (
     "id" integer NOT NULL PRIMARY KEY,
     "destination_match" varchar(100) NOT NULL,
     "xml_dialplan" text NOT NULL,
-    "domain" varchar(100) NOT NULL,
+    "domain_id" integer NOT NULL REFERENCES "ipypbxweb_domain" ("id"),
     "endpoint_id" integer NOT NULL REFERENCES "ipypbxweb_endpoint" ("id"),
     "authenticate_calls" bool NOT NULL,
     "is_active" bool NOT NULL
@@ -64,5 +63,6 @@ CREATE TABLE "ipypbxweb_extension" (
 CREATE INDEX "ipypbxweb_sipprofile_connection_id" ON "ipypbxweb_sipprofile" ("connection_id");
 CREATE INDEX "ipypbxweb_domain_sip_profile_id" ON "ipypbxweb_domain" ("sip_profile_id");
 CREATE INDEX "ipypbxweb_gateway_sip_profile_id" ON "ipypbxweb_gateway" ("sip_profile_id");
-CREATE INDEX "ipypbxweb_extension_endpoint_id" ON "ipypbxweb_extension" ("endpoint_id");
-COMMIT;
+CREATE INDEX "ipypbxweb_endpoint_domain_id" ON "ipypbxweb_endpoint" ("domain_id");
+CREATE INDEX "ipypbxweb_extension_domain_id" ON "ipypbxweb_extension" ("domain_id");
+CREATE INDEX "ipypbxweb_extension_endpoint_id" ON "ipypbxweb_extension" ("endpoint_id");
\ No newline at end of file
index aeb2478..a99a34d 100644 (file)
@@ -53,9 +53,9 @@ def setupDb(prefix=PREFIX, dbname=DB_NAME):
             # Split into individual queries.
             sql_queries = sql_script.split(';')
 
-            # Execute all queries except BEGIN/COMMIT sequences.
+            # Execute all queries except last that is empty.
             query = QtSql.QSqlQuery()
-            for query_string in sql_queries[1:-2]:
+            for query_string in sql_queries[:-1]:
                 query.exec_(query_string)
     else:
         # Something went horribly wrong.
@@ -70,12 +70,8 @@ if __name__ == '__main__':
     locale = QtCore.QLocale.system().name()
     translator = QtCore.QTranslator()
     
-#    if translator.load("/home/antisvin/dev/git/ipypbx/src/ipypbx/locale/ipypbx_ru.qm"):
     if translator.load("ipypbx_%s" % locale.toLower(), "ipypbx/locale"):
         QtGui.QApplication.installTranslator(translator)
-    else:
-        print locale
-    print translator.translate('MainWindow', 'Name').toUtf8()
 
     setupDb()
     main = QtGui.QMainWindow()
@@ -89,5 +85,5 @@ if __name__ == '__main__':
         controllers.EndpointController, controllers.ExtensionController):
         controllerClass(parent=main, views=views)
 
-    app.exec_()
-#    sys.exit()
+    sys.exit(app.exec_())
+
index 04fbde6..7a944d8 100644 (file)
@@ -64,7 +64,7 @@ class Gateway(models.Model):
 class Endpoint(models.Model):
     user_id = models.CharField(max_length=100)
     password = models.CharField(max_length=100)
-    domain = models.CharField(max_length=100)
+    domain = models.ForeignKey(Domain)
     is_active = models.BooleanField()