aboutsummaryrefslogtreecommitdiffstats
path: root/servo
diff options
context:
space:
mode:
authorFilipp Lepalaan <filipp@mac.com>2015-11-18 22:41:40 +0200
committerFilipp Lepalaan <filipp@mac.com>2015-11-18 22:41:40 +0200
commit085832888a6ebee7f0b2d23c68ef887833f2a94d (patch)
tree31363288b92ea742b9e10ff21990bd77b8bdbf82 /servo
parent15ea45e17ebe662b4a105a0a61d6e46dcf591358 (diff)
downloadServo-085832888a6ebee7f0b2d23c68ef887833f2a94d.tar.gz
Servo-085832888a6ebee7f0b2d23c68ef887833f2a94d.tar.bz2
Servo-085832888a6ebee7f0b2d23c68ef887833f2a94d.zip
Cleanup
Diffstat (limited to 'servo')
-rw-r--r--servo/management/commands/checkescalations.py16
-rw-r--r--servo/models/order.py3
-rw-r--r--servo/models/rules.py11
-rw-r--r--servo/tasks.py3
-rw-r--r--servo/templates/checkin/index.html4
-rwxr-xr-xservo/templates/modal.html2
-rw-r--r--servo/templates/rules/list_rules.html1
-rw-r--r--servo/views/customer.py5
8 files changed, 35 insertions, 10 deletions
diff --git a/servo/management/commands/checkescalations.py b/servo/management/commands/checkescalations.py
index 488bda9..a4dfd5f 100644
--- a/servo/management/commands/checkescalations.py
+++ b/servo/management/commands/checkescalations.py
@@ -4,6 +4,8 @@ from django.db.models import Q
from django.utils import timezone
from django.core.management.base import BaseCommand, CommandError
+from servo.lib.utils import empty
+from servo.exceptions import ConfigurationError
from servo.models import Configuration, Note, User, Escalation
@@ -11,16 +13,22 @@ class Command(BaseCommand):
help = "Check updates for open escalations"
def handle(self, *args, **options):
+ # get local user to create notes as
uid = Configuration.conf('imap_act')
-
- if uid in [None, '']:
- return
+
+ if empty(uid):
+ raise ConfigurationError('Incoming message user not defined')
user = User.objects.get(pk=uid)
tz = timezone.get_current_timezone()
for i in Escalation.objects.exclude(Q(escalation_id='') | Q(status='C')):
- i.gsx_account.connect(i.created_by)
+ # connect per-user since the escalations can be under different ship-tos
+ try:
+ i.gsx_account.connect(i.created_by)
+ except Exception:
+ continue # skip auth errors so we don't get stuck
+
r = i.get_escalation().lookup()
aware = timezone.make_aware(r.lastModifiedTimestamp, tz)
diff --git a/servo/models/order.py b/servo/models/order.py
index 1a76a37..b5c4138 100644
--- a/servo/models/order.py
+++ b/servo/models/order.py
@@ -430,6 +430,9 @@ class Order(models.Model):
pass
def set_location(self, new_location, user):
+ """
+ Moves order to new location
+ """
# move the products too
for soi in self.serviceorderitem_set.all():
product = soi.product
diff --git a/servo/models/rules.py b/servo/models/rules.py
index 1e6ec2d..460a0b6 100644
--- a/servo/models/rules.py
+++ b/servo/models/rules.py
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
+import json
from django.db import models
from django.core.cache import cache
@@ -12,6 +13,13 @@ from django.utils.translation import ugettext_lazy as _
from servo.models import Event, Queue
+class RuleManager:
+
+ def all(self):
+ f = open('local_rules.json', 'r')
+ return json.loads(f.read())
+
+
class ServoModel(models.Model):
class Meta:
abstract = True
@@ -19,6 +27,9 @@ class ServoModel(models.Model):
class Rule(ServoModel):
+
+ objects = RuleManager()
+
description = models.CharField(max_length=128, default=_('New Rule'))
MATCH_CHOICES = (
('ANY', _('Any')),
diff --git a/servo/tasks.py b/servo/tasks.py
index a10cb54..ed92331 100644
--- a/servo/tasks.py
+++ b/servo/tasks.py
@@ -10,6 +10,7 @@ from django.conf import settings
from django.core.cache import cache
from servo.lib.utils import empty
+from servo.exceptions import ConfigurationError
from servo.models import Configuration, User, Order, Note, Template
@@ -163,7 +164,7 @@ def check_mail():
uid = Configuration.conf('imap_act')
if empty(uid):
- raise ValueError('Incoming message user not configured')
+ raise ConfigurationError('Incoming message user not configured')
counter = 0
user = User.objects.get(pk=uid)
diff --git a/servo/templates/checkin/index.html b/servo/templates/checkin/index.html
index d7928fb..c197d31 100644
--- a/servo/templates/checkin/index.html
+++ b/servo/templates/checkin/index.html
@@ -34,7 +34,7 @@
</ul>
{% endif %}
<ul class="nav navbar-nav pull-right">
- {% if request.user.is_authenticated %}
+ {% if request.user.is_authenticated %}
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">{% bootstrap_icon "user" %} {{ request.session.checkin_user_name }} <b class="caret"></b></a>
<ul class="dropdown-menu">
@@ -48,7 +48,7 @@
<li><a href="{% url 'accounts-logout' %}" data-modal="#modal">{% bootstrap_icon "off" %} {% trans "Log out" %}...</a></li>
</ul>
</li>
- {% endif %}
+ {% endif %}
</ul>
</div><!--/.nav-collapse -->
</div>
diff --git a/servo/templates/modal.html b/servo/templates/modal.html
index d6f75db..dbd3d37 100755
--- a/servo/templates/modal.html
+++ b/servo/templates/modal.html
@@ -3,7 +3,7 @@
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">&times;</button>
- <h3>{% block header %} {{ title }} {% endblock header %}</h3>
+ <h4>{% block header %} {{ title }} {% endblock header %}</h4>
</div>
<div class="modal-body">
{% block body %}
diff --git a/servo/templates/rules/list_rules.html b/servo/templates/rules/list_rules.html
index 9aef78e..ccfdd26 100644
--- a/servo/templates/rules/list_rules.html
+++ b/servo/templates/rules/list_rules.html
@@ -11,6 +11,7 @@
<ul class="nav nav-pills nav-stacked">
<li class="nav-header">{% trans "Rules" %}</li>
{% for o in object_list %}
+ <li>{{ o }}</li>
<li class="{% active_url request o.get_admin_url %}"><a href="{{ o.get_admin_url }}">{{ o.get_name }}</a></li>
{% endfor %}
</ul>
diff --git a/servo/views/customer.py b/servo/views/customer.py
index 1372419..56e0a4b 100644
--- a/servo/views/customer.py
+++ b/servo/views/customer.py
@@ -54,9 +54,10 @@ def prepare_view(request, group='all'):
customer_list = all_customers.filter(groups=g)
title = g.name
+ groups = CustomerGroup.objects.all()
+
page = request.GET.get('page')
customers = paginate(customer_list, page, 40)
- groups = CustomerGroup.objects.all()
return locals()
@@ -283,7 +284,7 @@ def move(request, pk, new_parent=None):
try:
customer.move_to(new_parent)
- customer.save() # To update fullname
+ customer.save() # To update fullname
messages.success(request, msg)
except Exception as e:
messages.error(request, e)