aboutsummaryrefslogtreecommitdiffstats
path: root/servo
diff options
context:
space:
mode:
Diffstat (limited to 'servo')
-rw-r--r--servo/forms/admin.py37
-rw-r--r--servo/migrations/0041_auto_20151023_1228.py29
-rw-r--r--servo/models/queue.py9
-rw-r--r--servo/templates/admin/queues/form.html16
-rw-r--r--servo/urls/admin.py20
-rw-r--r--servo/views/admin.py5
6 files changed, 92 insertions, 24 deletions
diff --git a/servo/forms/admin.py b/servo/forms/admin.py
index df99669..5118fc0 100644
--- a/servo/forms/admin.py
+++ b/servo/forms/admin.py
@@ -5,8 +5,8 @@ import io
from django import forms
from django import template
-from django.utils.translation import ugettext_lazy as _
from django.contrib.auth.models import Permission
+from django.utils.translation import ugettext_lazy as _
from servo.forms.base import BaseForm, BaseModelForm
from servo.forms.account import ProfileForm
@@ -137,7 +137,8 @@ class QueueForm(BaseModelForm):
gsx_soldto = forms.ChoiceField(required=False, choices=())
users = forms.ModelMultipleChoiceField(queryset=User.active.all(),
widget=forms.CheckboxSelectMultiple,
- required=False)
+ required=False
+ )
class Meta:
model = Queue
@@ -174,6 +175,20 @@ class StatusForm(BaseModelForm):
'limit_yellow': forms.TextInput(attrs={'class': 'input-mini'}),
}
+
+class QueueStatusForm(BaseModelForm):
+ class Meta:
+ model = QueueStatus
+ exclude = []
+ widgets = {'idx': forms.Select()}
+
+ def __init__(self, *args, **kwargs):
+ super(QueueStatusForm, self).__init__(*args, **kwargs)
+ statuses = QueueStatus.objects.filter(queue_id=self.instance.queue_id)
+ statuses = statuses.count() or 1
+ self.fields['idx'].widget.choices = [(i, i) for i in range(1, statuses+1)]
+
+
class UserForm(ProfileForm):
def clean_username(self):
reserved = (
@@ -219,6 +234,7 @@ class UserForm(ProfileForm):
'queues': forms.CheckboxSelectMultiple
}
+
class TemplateForm(BaseModelForm):
class Meta:
model = Template
@@ -413,9 +429,9 @@ class SettingsForm(BaseForm):
required=False,
label=_('Default Sender'),
choices=(
- ('user', _("User")),
- ('location', _("Location")),
- ('custom', _("Custom..."))
+ ('user', _("User")),
+ ('location', _("Location")),
+ ('custom', _("Custom..."))
),
help_text=_('Select the default sender address for outgoing emails')
)
@@ -449,13 +465,14 @@ class SettingsForm(BaseForm):
label=_('SMS Gateway'),
choices=(
('builtin', _('Built-in')),
- ('hqsms', 'HQSMS'),
- ('http', 'HTTP'),
- ('smtp', 'SMTP'),
- ('jazz', 'SMSjazz'),
+ ('hqsms', 'HQSMS'),
+ ('http', 'HTTP'),
+ ('smtp', 'SMTP'),
+ ('jazz', 'SMSjazz'),
),
initial='http',
- required=False)
+ required=False
+ )
sms_smtp_address = forms.EmailField(required=False, label=_('Email address'))
sms_http_url = forms.CharField(
max_length=128,
diff --git a/servo/migrations/0041_auto_20151023_1228.py b/servo/migrations/0041_auto_20151023_1228.py
new file mode 100644
index 0000000..8307e4f
--- /dev/null
+++ b/servo/migrations/0041_auto_20151023_1228.py
@@ -0,0 +1,29 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('servo', '0040_auto_20151020_2226'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='queuestatus',
+ name='idx',
+ field=models.IntegerField(default=1, verbose_name='Ordering'),
+ ),
+ migrations.AlterField(
+ model_name='repair',
+ name='acplus',
+ field=models.NullBooleanField(default=None, help_text='Repair is covered by AppleCare+', verbose_name='AppleCare+'),
+ ),
+ migrations.AlterField(
+ model_name='repair',
+ name='consumer_law',
+ field=models.NullBooleanField(default=None, help_text='Repair is eligible for consumer law coverage'),
+ ),
+ ]
diff --git a/servo/models/queue.py b/servo/models/queue.py
index 05f5f2c..eb8414e 100644
--- a/servo/models/queue.py
+++ b/servo/models/queue.py
@@ -246,14 +246,16 @@ class QueueStatus(models.Model):
queue = models.ForeignKey(Queue)
status = models.ForeignKey(Status)
- limit_green = models.IntegerField(default=1, verbose_name=_(u'green limit'))
- limit_yellow = models.IntegerField(default=15, verbose_name=_(u'yellow limit'))
+ limit_green = models.IntegerField(default=1, verbose_name=_(u'Green limit'))
+ limit_yellow = models.IntegerField(default=15, verbose_name=_(u'Yellow limit'))
limit_factor = models.IntegerField(
choices=Status.FACTOR_CHOICES,
- verbose_name=_(u'time unit'),
+ verbose_name=_(u'Time unit'),
default=Status.FACTOR_CHOICES[0][0]
)
+ idx = models.IntegerField(default=1, verbose_name=_(u'Ordering'))
+
def get_green_limit(self):
"""
Gets the green time limit for this QS
@@ -268,5 +270,6 @@ class QueueStatus(models.Model):
class Meta:
app_label = 'servo'
+ ordering = ('idx',)
# A status should only be defined once per queue
unique_together = ('queue', 'status',)
diff --git a/servo/templates/admin/queues/form.html b/servo/templates/admin/queues/form.html
index 119275a..b3991ec 100644
--- a/servo/templates/admin/queues/form.html
+++ b/servo/templates/admin/queues/form.html
@@ -8,6 +8,7 @@
<ul class="nav nav-tabs">
<li class="active"><a href="#tab1" data-toggle="tab">{% trans "General" %}</a></li>
<li><a href="#tab2" data-toggle="tab">{% trans "Statuses" %}</a></li>
+ <li><a href="#tab7" data-toggle="tab">{% trans "Locations" %}</a></li>
<li><a href="#tab5" data-toggle="tab">{% trans "Defaults" %}</a></li>
<li><a href="#tab3" data-toggle="tab">{% trans "GSX" %}</a></li>
<li><a href="#tab4" data-toggle="tab">{% trans "Templates" %}</a></li>
@@ -19,7 +20,6 @@
{% include "form_field_snippet.html" with field=form.priority %}
{% include "form_field_snippet.html" with field=form.description %}
<!--{% include "form_field_snippet.html" with field=form.keywords %}//-->
- {% include "form_field_snippet.html" with field=form.locations %}
</div>
<div class="tab-pane" id="tab2">
<table class="table table-condensed" id="table-queue-status">
@@ -27,6 +27,7 @@
<tr>
<th>{% trans "Status" %}</th>
<th colspan="3">{% trans "Time limits" %}</th>
+ <th>{% trans "Ordering" %}</th>
<th style="width:30px" class="text-center">{% trans "Delete" %}</th>
</tr>
</thead>
@@ -46,6 +47,9 @@
</table>
<a class="btn" id="add_more"><i class="icon-plus"></i> {% trans "Add Status" %}</a>
</div>
+ <div class="tab-pane" id="tab7">
+ {% include "form_field_snippet.html" with field=form.locations %}
+ </div>
<div class="tab-pane" id="tab5">
{% include "form_field_snippet.html" with field=form.status_created %}
{% include "form_field_snippet.html" with field=form.status_assigned %}
@@ -68,7 +72,15 @@
{% include "form_field_snippet.html" with field=form.users %}
</div>
</div>
- {% include "form_buttons.html" %}
+ <div class="form-actions">
+ <a class="btn btn-default" href="{% url 'admin-queues' %}">{% trans "Back" %}</a>
+ {% if queue.pk %}
+ <a class="btn btn-danger" data-modal="#modal" href="{% url 'admin-delete_queue' queue.pk %}">{% trans "Delete" %}</a>
+ {% else %}
+ <a class="btn btn-danger disabled" href="#">{% trans "Delete" %}</a>
+ {% endif %}
+ <button type="submit" class="btn btn-primary">{% trans "Save" %}</button>
+ </div>
</form>
{% endblock third_column %}
diff --git a/servo/urls/admin.py b/servo/urls/admin.py
index 1703da0..9ed61f2 100644
--- a/servo/urls/admin.py
+++ b/servo/urls/admin.py
@@ -18,8 +18,10 @@ urlpatterns = patterns(
url(r'^users/upload/$', 'upload_users', name="admin-upload_users"),
url(r'^users/(\d+)/edit/$', 'edit_user', name="admin-edit_user"),
url(r'^users/(\d+)/delete/$', 'delete_user', name="admin-delete_user"),
- url(r'^users/(\d+)/delete_tokens/$', 'delete_user_token', name="admin-delete_user_token"),
- url(r'^users/(\d+)/create_token/$', 'create_user_token', name="admin-create_user_token"),
+ url(r'^users/(\d+)/delete_tokens/$', 'delete_user_token',
+ name="admin-delete_user_token"),
+ url(r'^users/(\d+)/create_token/$', 'create_user_token',
+ name="admin-create_user_token"),
url(r'^groups/$', 'list_groups', name='admin-list_groups'),
url(r'^groups/new/$', 'edit_group', name="admin-create_group"),
@@ -35,7 +37,8 @@ urlpatterns = patterns(
url(r'^fields/(?P<type>[a-z]+)/$', 'fields', name='admin-fields'),
url(r'^fields/(?P<type>[a-z]+)/new/$', 'edit_field', name="admin-create_field"),
url(r'^fields/[a-z]+/(\d+)/delete/$', 'delete_field', name="admin-delete_field"),
- url(r'^fields/(?P<type>[a-z]+)/(?P<pk>\d+)/edit/$', 'edit_field', name="admin-edit_field"),
+ url(r'^fields/(?P<type>[a-z]+)/(?P<pk>\d+)/edit/$', 'edit_field',
+ name="admin-edit_field"),
url(r'^templates/$', 'list_templates', name='admin-list_templates'),
url(r'^templates/new/$', 'edit_template', name='admin-edit_template'),
@@ -43,16 +46,15 @@ urlpatterns = patterns(
url(r'^templates/(\d+)/delete/$', 'delete_template', name='admin-delete_template'),
url(r'^queues/$', 'queues', name='admin-queues'),
- #url(r'^queues/$', admin.QueueListView.as_view(), name='admin-queues'),
url(r'^queues/new/$', 'edit_queue', name="admin-create_queue"),
url(r'^queues/(?P<pk>\d+)/edit/$', 'edit_queue', name="admin-edit_queue"),
- #url(r'^queues/(?P<pk>\d+)/edit/$', admin.QueueListView.as_view(), name='admin-edit_queue'),
url(r'^queues/(\d+)/delete/$', 'delete_queue', name="admin-delete_queue"),
url(r'^gsx/accounts/$', 'list_gsx_accounts', name='admin-list_gsx_accounts'),
url(r'^gsx/accounts/new/$', 'edit_gsx_account', name='admin-edit_gsx_account'),
url(r'^gsx/accounts/(\d+)/$', 'edit_gsx_account', name='admin-edit_gsx_account'),
- url(r'^gsx/accounts/(\d+)?/delete/$', 'delete_gsx_account', name='admin-delete_gsx_account'),
+ url(r'^gsx/accounts/(\d+)?/delete/$', 'delete_gsx_account',
+ name='admin-delete_gsx_account'),
url(r'^locations/$', 'locations', name='admin-locations'),
url(r'^locations/new/$', 'edit_location', name='admin-create_location'),
@@ -64,8 +66,10 @@ urlpatterns = patterns(
url(r'^checklists/$', 'checklists', name='admin-checklists'),
url(r'^checklists/new/$', 'edit_checklist', name='admin-create_checklist'),
- url(r'^checklists/(?P<pk>\d+)/edit/$', 'edit_checklist', name='admin-edit_checklist'),
- url(r'^checklists/(?P<pk>\d+)/delete/$', 'delete_checklist', name='admin-delete_checklist'),
+ url(r'^checklists/(?P<pk>\d+)/edit/$', 'edit_checklist',
+ name='admin-edit_checklist'),
+ url(r'^checklists/(?P<pk>\d+)/delete/$', 'delete_checklist',
+ name='admin-delete_checklist'),
url(r'^rules/', include('servo.urls.rules')),
diff --git a/servo/views/admin.py b/servo/views/admin.py
index ed9f4d8..f617c41 100644
--- a/servo/views/admin.py
+++ b/servo/views/admin.py
@@ -590,7 +590,10 @@ def queues(request):
@staff_member_required
def edit_queue(request, pk=None):
- StatusFormSet = inlineformset_factory(Queue, QueueStatus, extra=1, exclude=[])
+ StatusFormSet = inlineformset_factory(Queue,
+ QueueStatus,
+ extra=1,
+ form=QueueStatusForm)
if pk is None:
queue = Queue()