From 85e92ff2ee4ca30e0144790a1d95b8023595bf2f Mon Sep 17 00:00:00 2001 From: Filipp Lepalaan Date: Mon, 24 Apr 2017 22:26:17 +0300 Subject: Cleanup --- servo/forms/admin.py | 2 +- servo/management/commands/backup.py | 50 ++++++++++++++++----------------- servo/models/note.py | 5 ++-- servo/templates/accounts/login.html | 2 +- servo/templates/accounts/logout.html | 2 +- servo/templates/checkin/error.html | 7 +++-- servo/templates/checkin/index.html | 3 +- servo/templates/default.html | 20 ++++++------- servo/templates/default_print.html | 8 ++++-- servo/templates/orders/edit.html | 2 +- servo/templates/orders/notes.html | 2 +- servo/tests/test_functional.py | 5 ++++ servo/views/account.py | 16 +++++------ servo/views/checkin.py | 54 +++++++++++++++++++----------------- 14 files changed, 93 insertions(+), 85 deletions(-) (limited to 'servo') diff --git a/servo/forms/admin.py b/servo/forms/admin.py index ec4ee56..d0c284a 100644 --- a/servo/forms/admin.py +++ b/servo/forms/admin.py @@ -295,7 +295,7 @@ class SettingsForm(BaseForm): initial=True, required=False, label=_("Enable check-in interface"), - help_text=_("Uncheck to disable the check-in interface") + help_text=_("Uncheck to disable the check-in interface completely") ) checkin_user = forms.ModelChoiceField( 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, diff --git a/servo/models/note.py b/servo/models/note.py index 8b2943f..3f48282 100644 --- a/servo/models/note.py +++ b/servo/models/note.py @@ -112,7 +112,8 @@ class Note(MPTTModel): is_reported = models.BooleanField( default=False, - verbose_name=_("Report") + verbose_name=_("Report"), + help_text=_('Show this note on the confirmation printout') ) is_read = models.BooleanField( default=True, @@ -178,7 +179,7 @@ class Note(MPTTModel): def zip_attachments(self): pass - + def get_default_sender(self): return Configuration.get_default_sender(self.created_by) diff --git a/servo/templates/accounts/login.html b/servo/templates/accounts/login.html index 80ba716..ea71bcc 100755 --- a/servo/templates/accounts/login.html +++ b/servo/templates/accounts/login.html @@ -2,7 +2,7 @@ {% load i18n %} {% block content %} - +
{% csrf_token %}
diff --git a/servo/templates/accounts/logout.html b/servo/templates/accounts/logout.html index 1b64d45..3bb9f34 100755 --- a/servo/templates/accounts/logout.html +++ b/servo/templates/accounts/logout.html @@ -2,7 +2,7 @@ {% load i18n %} {% block header %} -{% trans "Logging out?" %} +{% trans "Confirmation" %} {% endblock header %} {% block body %} diff --git a/servo/templates/checkin/error.html b/servo/templates/checkin/error.html index d21e91f..ee0ecc9 100644 --- a/servo/templates/checkin/error.html +++ b/servo/templates/checkin/error.html @@ -6,10 +6,11 @@ {% block main %}
- -

{% trans "It appears that an error has occurred." %}

+ {% trans +

{% trans "An error occurred." %}

{{ message }}

- {% trans "Try again" %} + {% trans "Try again" %} + {% trans "Return to login page" %}
{% endblock main %} diff --git a/servo/templates/checkin/index.html b/servo/templates/checkin/index.html index c197d31..545825d 100644 --- a/servo/templates/checkin/index.html +++ b/servo/templates/checkin/index.html @@ -50,8 +50,7 @@ {% endif %} -
- +
diff --git a/servo/templates/default.html b/servo/templates/default.html index 139d083..363f3c8 100755 --- a/servo/templates/default.html +++ b/servo/templates/default.html @@ -1,21 +1,21 @@ {% load servo_tags %} {% load humanize %} -{% load cache %} +{% load static %} {% load i18n %} - - - - - - - - - + + + + + + + + + {{ title }} | Servo diff --git a/servo/templates/default_print.html b/servo/templates/default_print.html index ed3f4de..6abee01 100755 --- a/servo/templates/default_print.html +++ b/servo/templates/default_print.html @@ -1,17 +1,19 @@ +{% load static %} {{ title }} - - + + +
{% block content %} {% endblock content %}
- + {% if request.user.autoprint %}