diff options
author | Filipp Lepalaan <filipp@mac.com> | 2017-04-24 22:26:17 +0300 |
---|---|---|
committer | Filipp Lepalaan <filipp@mac.com> | 2017-04-24 22:26:17 +0300 |
commit | 85e92ff2ee4ca30e0144790a1d95b8023595bf2f (patch) | |
tree | ff38ef1fe1957e00732ab43f891b7915a7a97274 /servo/management/commands | |
parent | 5934831e5921b78651418a589da3c67ed320a309 (diff) | |
download | Servo-85e92ff2ee4ca30e0144790a1d95b8023595bf2f.tar.gz Servo-85e92ff2ee4ca30e0144790a1d95b8023595bf2f.tar.bz2 Servo-85e92ff2ee4ca30e0144790a1d95b8023595bf2f.zip |
Cleanup
Diffstat (limited to 'servo/management/commands')
-rw-r--r-- | servo/management/commands/backup.py | 50 |
1 files changed, 25 insertions, 25 deletions
diff --git a/servo/management/commands/backup.py b/servo/management/commands/backup.py index 9d63b27..28129e6 100644 --- a/servo/management/commands/backup.py +++ b/servo/management/commands/backup.py @@ -24,7 +24,7 @@ def write(path, header, cursor): class Command(BaseCommand): help = 'Export this servo database in a portable format' - + def handle(self, *args, **options): # creates a folder, then dumps different portable tables as separate # files to it, then compresses the folder and deletes it @@ -33,50 +33,50 @@ class Command(BaseCommand): dirname = datetime.now().strftime('%Y%m%d-%H%M') backupdir = os.path.join(settings.BACKUP_DIR, dirname) - + if not os.path.exists(backupdir): os.mkdir(backupdir) path = os.path.join(backupdir, 'notes.csv') cursor = connection.cursor() - cursor.execute("""SELECT id, order_id, created_by_id, created_at, body - FROM servo_note""") + cursor.execute("""SELECT id, order_id, created_by_id, created_at, body + FROM servo_note""") header = ['ID', 'ORDER_ID', 'USER_ID', 'CREATED_AT', 'NOTE'] write(path, header, cursor) path = os.path.join(backupdir, 'users.csv') header = ['ID', 'USERNAME', 'FIRST_NAME', 'LAST_NAME', 'EMAIL'] - cursor.execute("""SELECT id, username, first_name, last_name, email + cursor.execute("""SELECT id, username, first_name, last_name, email FROM servo_user WHERE is_visible = TRUE""") write(path, header, cursor) path = os.path.join(backupdir, 'orders.csv') - header = ['ID', 'CODE', 'CREATED_AT', - 'CLOSED_AT', 'CUSTOMER_ID', 'USER_ID', 'QUEUE_ID'] - cursor.execute("""SELECT id, code, created_at, closed_at, + header = ['ID', 'CODE', 'CREATED_AT', + 'CLOSED_AT', 'CUSTOMER_ID', 'USER_ID', 'QUEUE_ID'] + cursor.execute("""SELECT id, code, created_at, closed_at, customer_id, user_id, queue_id FROM servo_order""") write(path, header, cursor) path = os.path.join(backupdir, 'queues.csv') header = ['ID', 'NAME', 'DESCRIPTION', - 'CLOSED_AT', 'CUSTOMER_ID', 'USER_ID', 'QUEUE_ID'] + 'CLOSED_AT', 'CUSTOMER_ID', 'USER_ID', 'QUEUE_ID'] cursor.execute("""SELECT id, title, description FROM servo_queue""") write(path, header, cursor) path = os.path.join(backupdir, 'devices.csv') header = ['ID', 'SERIAL_NUMBER', 'IMEI', - 'CONFIGURATION', 'WARRANTY_STATUS', 'PURCHASE_DATE', 'NOTES'] + 'CONFIGURATION', 'WARRANTY_STATUS', 'PURCHASE_DATE', 'NOTES'] cursor.execute("""SELECT id, sn, imei, configuration, warranty_status, purchased_on, notes FROM servo_device""") write(path, header, cursor) path = os.path.join(backupdir, 'repairs.csv') header = ['ID', 'ORDER_ID', 'DEVICE_ID', 'USER_ID', - 'SUBMITTED_AT', 'COMPLETED_AT', 'REQUEST_REVIEW', - 'TECH_ID', 'UNIT_RECEIVED', 'CONFIRMATION', - 'REFERENCE', 'SYMPTOM', 'DIAGNOSIS', 'NOTES'] + 'SUBMITTED_AT', 'COMPLETED_AT', 'REQUEST_REVIEW', + 'TECH_ID', 'UNIT_RECEIVED', 'CONFIRMATION', + 'REFERENCE', 'SYMPTOM', 'DIAGNOSIS', 'NOTES'] cursor.execute("""SELECT id, order_id, device_id, created_by_id, submitted_at, completed_at, request_review, tech_id, unit_received_at, confirmation, reference, @@ -85,10 +85,10 @@ class Command(BaseCommand): WHERE submitted_at IS NOT NULL""") write(path, header, cursor) - header = ['ID', 'CODE', 'TITLE', 'DESCRIPTION', - 'PRICE_PURCHASE_EXCHANGE', 'PRICE_PURCHASE_STOCK', - 'PRICE_SALES_EXCHANGE', 'PRICE_SALES_STOCK', 'COMPONENT_CODE', - 'PART_TYPE', 'EEE_CODE'] + header = ['ID', 'CODE', 'TITLE', 'DESCRIPTION', + 'PRICE_PURCHASE_EXCHANGE', 'PRICE_PURCHASE_STOCK', + 'PRICE_SALES_EXCHANGE', 'PRICE_SALES_STOCK', 'COMPONENT_CODE', + 'PART_TYPE', 'EEE_CODE'] cursor.execute("""SELECT id, code, title, description, price_purchase_exchange, price_purchase_stock, price_sales_exchange, price_sales_stock, @@ -98,8 +98,8 @@ class Command(BaseCommand): write(path, header, cursor) header = ['ID', 'PARENT_ID', 'NAME', 'PHONE', 'EMAIL', - 'STREET_ADDRESS', 'POSTAL_CODE', 'CITY' - 'COUNTRY', 'NOTES'] + 'STREET_ADDRESS', 'POSTAL_CODE', 'CITY' + 'COUNTRY', 'NOTES'] cursor.execute("""SELECT id, parent_id, name, phone, email, street_address, zip_code, city, country, notes FROM servo_customer""") @@ -108,9 +108,9 @@ class Command(BaseCommand): path = os.path.join(backupdir, 'order_products.csv') header = ['ID', 'PRODUCT_ID', 'ORDER_ID', 'CODE', 'TITLE', - 'DESCRIPTION', 'AMOUNT', 'SERIAL_NUMBER', 'KBB_SN', - 'IMEI', 'REPORTED', 'PRICE_CATEGORY', 'PRICE' - 'COMPTIA_CODE', 'COMPTIA_MODIFIER'] + 'DESCRIPTION', 'AMOUNT', 'SERIAL_NUMBER', 'KBB_SN', + 'IMEI', 'REPORTED', 'PRICE_CATEGORY', 'PRICE' + 'COMPTIA_CODE', 'COMPTIA_MODIFIER'] cursor.execute("""SELECT id, product_id, order_id, code, title, description, amount, sn, price, kbb_sn, imei, should_report, price_category, price, @@ -120,9 +120,9 @@ class Command(BaseCommand): path = os.path.join(backupdir, 'parts.csv') header = ['ID', 'REPAIR_ID', 'ORDER_ITEM_ID', - 'NUMBER', 'TITLE', 'COMPTIA_CODE', 'COMPTIA_MODIFIER', - 'RETURN_ORDER', 'RETURN_STATUS', 'RETURN_CODE', - 'ORDER_STATUS', 'COVERAGE', 'SHIP_TO', 'RETURNED_AT'] + 'NUMBER', 'TITLE', 'COMPTIA_CODE', 'COMPTIA_MODIFIER', + 'RETURN_ORDER', 'RETURN_STATUS', 'RETURN_CODE', + 'ORDER_STATUS', 'COVERAGE', 'SHIP_TO', 'RETURNED_AT'] cursor.execute("""SELECT id, repair_id, order_item_id, part_number, part_title, comptia_code, comptia_modifier, return_order, return_status, return_code, |