diff options
author | Filipp Lepalaan <filipp@mac.com> | 2016-02-03 13:16:21 +0200 |
---|---|---|
committer | Filipp Lepalaan <filipp@mac.com> | 2016-02-03 13:16:21 +0200 |
commit | 5091347c3ee9ef1bb92b3bc4b8b802f48326f30a (patch) | |
tree | c7428885fbdf77ef2d582dec1ca68cf2ed23de24 /servo | |
parent | 5976f01b0affa0351e94c8893123acc118b4015c (diff) | |
download | Servo-5091347c3ee9ef1bb92b3bc4b8b802f48326f30a.tar.gz Servo-5091347c3ee9ef1bb92b3bc4b8b802f48326f30a.tar.bz2 Servo-5091347c3ee9ef1bb92b3bc4b8b802f48326f30a.zip |
Cleanup
Diffstat (limited to 'servo')
-rw-r--r-- | servo/models/repair.py | 19 | ||||
-rwxr-xr-x | servo/templates/devices/upload_devices.html | 2 | ||||
-rwxr-xr-x | servo/templates/devices/view.html | 29 | ||||
-rw-r--r-- | servo/views/device.py | 8 | ||||
-rw-r--r-- | servo/views/gsx.py | 15 |
5 files changed, 41 insertions, 32 deletions
diff --git a/servo/models/repair.py b/servo/models/repair.py index 9649b86..db983dc 100644 --- a/servo/models/repair.py +++ b/servo/models/repair.py @@ -68,7 +68,7 @@ class ChecklistItem(models.Model): def __unicode__(self): return self.title - + class Meta: app_label = "servo" @@ -177,7 +177,7 @@ class Repair(models.Model): component_data = models.TextField(default='', editable=False) consumer_law = models.NullBooleanField( - default=None, + default=None, help_text=_('Repair is eligible for consumer law coverage') ) acplus = models.NullBooleanField( @@ -189,6 +189,9 @@ class Repair(models.Model): symptom_code = models.CharField(max_length=7, default='') issue_code = models.CharField(max_length=7, default='') + def is_submitted(self): + return self.submitted_at is not None + def get_symptom_code_choices(self): """ Returns the possible symptom codes for the current serial number @@ -263,7 +266,7 @@ class Repair(models.Model): po.sales_order = self.order po.save() return po - + def warranty_status(self): """ Gets warranty status for this device and these parts @@ -323,7 +326,7 @@ class Repair(models.Model): except Product.DoesNotExist: p = Product.from_gsx(new_part.lookup()) p.save() - + oi = self.order.add_product(p, 1, self.created_by) oi.comptia_code = part.comptiaCode or '' @@ -335,7 +338,7 @@ class Repair(models.Model): sp.order(self.created_by) sp.save() - + def submit(self, customer_data): """ Creates a new GSX repair and all the documentation that goes along with it @@ -346,7 +349,7 @@ class Repair(models.Model): if not self.order.queue: raise ValueError(_("Order has not been assigned to a queue")) - + repair_data = self.to_gsx() if self.repair_type == "CA": @@ -611,7 +614,7 @@ class Repair(models.Model): 'RPR.COM.036': Repair for Unit $1 is already marked as complete. 'RPR.COM.019': This repair cannot be updated. 'RPR.LKP.16': This Repair Cannot be Updated.Repair is not Open. - 'RPR.COM.136': Repair $1 cannot be marked complete as the Warranty + 'RPR.COM.136': Repair $1 cannot be marked complete as the Warranty Claims Certification Form status is either Declined or Hold. 'ENT.UPL.022': 'Confirmation # $1 does not exist.' """ @@ -626,7 +629,7 @@ class Repair(models.Model): 'RPR.COM.136', 'ENT.UPL.022', ) - + if e.code not in errorlist: raise e diff --git a/servo/templates/devices/upload_devices.html b/servo/templates/devices/upload_devices.html index 04cdc47..ba857bf 100755 --- a/servo/templates/devices/upload_devices.html +++ b/servo/templates/devices/upload_devices.html @@ -13,4 +13,4 @@ {% block footer %} <a class="btn btn-default" href="{{ STATIC_URL }}/examples/upload_devices.xlsx">{% trans "Download example" %}</a> <button type="submit" class="btn btn-primary">{% trans "Submit" %}</button> -{% endblock footer %}
\ No newline at end of file +{% endblock footer %} diff --git a/servo/templates/devices/view.html b/servo/templates/devices/view.html index 8234cd7..b2cd3db 100755 --- a/servo/templates/devices/view.html +++ b/servo/templates/devices/view.html @@ -21,9 +21,9 @@ {% else %} <a href="#" class="btn btn-primary disabled"><i class="icon-share-alt icon-white"></i> {% trans "Use in current order" %}</a> {% endif %} - {% if device.pk %} + {% if device.pk %} <a href="{% url 'devices-create_order' device.pk %}" class="btn"><i class="icon-plus"></i> {% trans "Create Service Order" %}</a> - {% endif %} + {% endif %} <div class="btn-group"> <a class="btn dropdown-toggle" data-toggle="dropdown" href="#"> <i class="icon-cog"></i> <span class="caret"></span> @@ -62,12 +62,22 @@ </div> </div> <div class="tab-pane" id="tab2"> - {% include "orders/list.html" with orders=device.order_set.all %} + {% include "orders/list.html" %} + </div> + {% if device.is_apple_device %} + <div class="tab-pane" id="tab3"> + <h4>{% trans "Submitted GSX repairs" %}</h4> + <div id="gsx-container" data-source="{% url 'devices-search_gsx_repairs' pk=device.pk %}"> + <div class="progress active"> + <div class="bar" style="width:100%;" data-progress="0"></div> + </div> + <p class="text-center muted">{% trans "Fetching repairs..." %}</p> + </div> <hr/> <h4>{% trans "Local GSX repairs" %}</h4> <table class="table"> <tbody> - {% for r in device.repair_set.all %} + {% for r in repairs %} <tr> <td>{{ r.confirmation }}</td> <td>{{ r.created_at|date }}</td> @@ -77,21 +87,12 @@ </tr> {% empty %} <tr> - <td colspan="4">{% trans "No local GSX repairs found" %}</td> + <td colspan="5">{% trans "No local GSX repairs found" %}</td> </tr> {% endfor %} </tbody> </table> </div> - {% if device.is_apple_device %} - <div class="tab-pane" id="tab3"> - <div id="gsx-container" data-source="{% url 'devices-search_gsx_repairs' pk=device.pk %}"> - <div class="progress active"> - <div class="bar" style="width:100%;" data-progress="0"></div> - </div> - <p class="text-center muted">{% trans "Fetching repairs..." %}</p> - </div> - </div> {% endif %} </div> {% endblock fourth_column %} diff --git a/servo/views/device.py b/servo/views/device.py index de4cf96..2032a15 100644 --- a/servo/views/device.py +++ b/servo/views/device.py @@ -162,6 +162,8 @@ def edit_device(request, pk=None, product_line=None, model=None): def view_device(request, pk, product_line=None, model=None): data = prep_detail_view(request, pk, product_line, model) + data['repairs'] = data['device'].repair_set.all() + data['orders'] = data['device'].order_set.all() return render(request, "devices/view.html", data) @@ -193,7 +195,7 @@ def find(request): page = request.GET.get("page") devices = paginate(results, page, 100) - + return render(request, "devices/find.html", locals()) @@ -205,7 +207,7 @@ def parts(request, pk, order_id, queue_id): and the Location's corresponding GSX account """ from decimal import InvalidOperation - + device = get_object_or_404(Device, pk=pk) order = device.order_set.get(pk=order_id) @@ -366,7 +368,7 @@ def search_gsx_repairs(request, pk): Performs async GSX search for this device's GSX repairs """ device = get_object_or_404(Device, pk=pk) - + try: GsxAccount.default(request.user) results = {'results': device.get_gsx_repairs()} diff --git a/servo/views/gsx.py b/servo/views/gsx.py index 4208c23..12be6c9 100644 --- a/servo/views/gsx.py +++ b/servo/views/gsx.py @@ -64,7 +64,7 @@ def import_repair(request, order_pk, device_pk): return render(request, "repairs/import_repair.html", locals()) - + @permission_required("servo.change_order") def return_label(request, repair, part): """ @@ -134,9 +134,12 @@ def remove_part(request, repair, part): def delete_repair(request, repair_id): + """ + Deletes this unsubmitted GSX repair + """ repair = get_object_or_404(Repair, pk=repair_id) - - if repair.submitted_at: + + if repair.is_submitted(): messages.error(request, _('Submitted repairs cannot be deleted')) return redirect(repair.order) @@ -193,7 +196,7 @@ def prep_edit_view(request, repair, order=None, device=None): if not order.customer: raise ValueError(_("Cannot create GSX repair without valid customer data")) - + customer = order.customer.gsx_address(request.user.location) customer_form = GsxCustomerForm(initial=customer) @@ -292,7 +295,7 @@ def create_repair(request, order_id, device_id, type): """ from datetime import timedelta from django.utils import timezone - + order = get_object_or_404(Order, pk=order_id) device = order.devices.get(pk=device_id) @@ -328,7 +331,7 @@ def repair_details(request, confirmation): except Exception as e: data = {'error': e} return render(request, "snippets/error_modal.html", data) - + data = {'repair': repair} if request.method == "POST": |