Added django command for generating SQL tables creation script
authorStas Shtin <antisvin@gmail.com>
Sun, 11 Apr 2010 12:39:34 +0000 (16:39 +0400)
committerStas Shtin <antisvin@gmail.com>
Sun, 11 Apr 2010 12:39:34 +0000 (16:39 +0400)
src/ipypbxweb/management/__init__.py [new file with mode: 0644]
src/ipypbxweb/management/commands/__init__.py [new file with mode: 0644]
src/ipypbxweb/management/commands/dumpsql.py [new file with mode: 0644]

diff --git a/src/ipypbxweb/management/__init__.py b/src/ipypbxweb/management/__init__.py
new file mode 100644 (file)
index 0000000..78d5397
--- /dev/null
@@ -0,0 +1,16 @@
+# Copyright (c) Stas Shtin, 2010
+
+# This file is part of IPyPBX.
+
+# IPyPBX is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# IPyPBX is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with IPyPBX.  If not, see <http://www.gnu.org/licenses/>.
diff --git a/src/ipypbxweb/management/commands/__init__.py b/src/ipypbxweb/management/commands/__init__.py
new file mode 100644 (file)
index 0000000..78d5397
--- /dev/null
@@ -0,0 +1,16 @@
+# Copyright (c) Stas Shtin, 2010
+
+# This file is part of IPyPBX.
+
+# IPyPBX is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# IPyPBX is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with IPyPBX.  If not, see <http://www.gnu.org/licenses/>.
diff --git a/src/ipypbxweb/management/commands/dumpsql.py b/src/ipypbxweb/management/commands/dumpsql.py
new file mode 100644 (file)
index 0000000..63d2451
--- /dev/null
@@ -0,0 +1,37 @@
+# Copyright (c) Stas Shtin, 2010
+
+# This file is part of IPyPBX.
+
+# IPyPBX is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# IPyPBX is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with IPyPBX.  If not, see <http://www.gnu.org/licenses/>.
+
+import os
+from django.core.management import base, color
+from django.core.management.commands import sqlall
+
+
+class Command(base.NoArgsCommand):
+    def handle_noargs(self, **options):
+        sqlall_command = sqlall.Command()
+        sqlall_command.style = color.no_style()
+        sql_script = sqlall_command.handle('ipypbxweb', **options)
+
+        open(os.path.join(
+            os.path.dirname(__file__),
+            '../../../ipypbx/create.sql'), 'w'
+             ).write(sql_script)
+
+        return 'SQL creation script written'
+        
+             
+