diff options
author | Filipp Lepalaan <filipp@mac.com> | 2016-02-29 23:27:28 +0200 |
---|---|---|
committer | Filipp Lepalaan <filipp@mac.com> | 2016-02-29 23:27:28 +0200 |
commit | 65df597329bbb602dd382695c639aab3776123ea (patch) | |
tree | b320bbad0514530ff8e1faf56d73afcd7b10ed0b /servo | |
parent | ce705c3cef767803700629d9598a2ebaff14687d (diff) | |
download | Servo-65df597329bbb602dd382695c639aab3776123ea.tar.gz Servo-65df597329bbb602dd382695c639aab3776123ea.tar.bz2 Servo-65df597329bbb602dd382695c639aab3776123ea.zip |
Close GSX repairs before closing service order
Diffstat (limited to 'servo')
-rw-r--r-- | servo/models/order.py | 13 | ||||
-rw-r--r-- | servo/models/repair.py | 41 |
2 files changed, 30 insertions, 24 deletions
diff --git a/servo/models/order.py b/servo/models/order.py index 2fa3097..8d8eddd 100644 --- a/servo/models/order.py +++ b/servo/models/order.py @@ -348,12 +348,6 @@ class Order(models.Model): """ Closes this service order """ - self.notify("close_order", _(u"Order %s closed") % self.code, user) - self.closed_by = user - self.closed_at = timezone.now() - self.state = self.STATE_CLOSED - self.save() - if Configuration.autocomplete_repairs(): for r in self.repair_set.active(): try: @@ -366,6 +360,12 @@ class Order(models.Model): if self.queue and self.queue.status_closed: self.set_status(self.queue.status_closed, user) + self.notify("close_order", _(u"Order %s closed") % self.code, user) + self.closed_by = user + self.closed_at = timezone.now() + self.state = self.STATE_CLOSED + self.save() + def reopen(self, user): """ Re-opens this service order @@ -373,6 +373,7 @@ class Order(models.Model): self.state = Order.STATE_OPEN self.closed_at = None self.save() + msg = _("Order %s reopened") % self.code self.notify("reopen", msg, user) return msg diff --git a/servo/models/repair.py b/servo/models/repair.py index d947055..2836759 100644 --- a/servo/models/repair.py +++ b/servo/models/repair.py @@ -86,7 +86,7 @@ class ChecklistItemValue(models.Model): class ActiveManager(models.Manager): use_for_related_fields = True - + def active(self): """ GSX repairs that have been submitted, and not marked complete @@ -585,19 +585,6 @@ class Repair(models.Model): except IndexError: pass - def complete(self, user): - """ - Marks this repair as being complete - """ - self.completed_at = timezone.now() - self.completed_by = user - self.save() - - queue = self.order.queue - if queue.status_repair_completed: - status = queue.status_repair_completed - self.order.set_status(status, user) - def get_sn_update_parts(self): """ Returns parts eligible for SN update @@ -606,7 +593,7 @@ class Repair(models.Model): def close(self, user): """ - Marks this GSX repair as complete + Mark the GSX repair as complete """ self.connect_gsx(user) repair = self.get_gsx_repair() @@ -646,9 +633,24 @@ class Repair(models.Model): status = repair.status() self.set_status(status.repairStatus, user) - self.complete(user) + def complete(self, user): + """ + Mark our local copy of this GSX repair as complete + """ + self.completed_at = timezone.now() + self.completed_by = user + self.save() + + msg = _('GSX repair %s marked complete') % self.confirmation + self.order.notify('gsx_repair_complete', msg, user) + + queue = self.order.queue + if queue.status_repair_completed: + status = queue.status_repair_completed + self.order.set_status(status, user) + def duplicate(self, user): """ Makes a copy of this GSX Repair @@ -673,8 +675,11 @@ class Repair(models.Model): def get_absolute_url(self): if self.submitted_at is None: - return reverse('repairs-edit_repair', args=[self.order.pk, self.pk]) - return reverse('repairs-view_repair', args=[self.order.pk, self.pk]) + url = 'repairs-edit_repair' + else: + url = 'repairs-view_repair' + + return reverse(url, args=[self.order.pk, self.pk]) def __unicode__(self): if self.pk is not None: |