Add ticket panel
Change-Id: I92b94a2ecbe6c57b494bcff180b30d3803c49d2d
This commit is contained in:
parent
dad8cf3ac3
commit
249442babc
@ -18,7 +18,7 @@ import horizon
|
|||||||
class Ticket(horizon.Dashboard):
|
class Ticket(horizon.Dashboard):
|
||||||
name = _("Ticket")
|
name = _("Ticket")
|
||||||
slug = "ticket"
|
slug = "ticket"
|
||||||
panels = ('workflows',)
|
panels = ('workflows', 'tickets')
|
||||||
default_panel = 'workflows'
|
default_panel = 'workflows'
|
||||||
|
|
||||||
|
|
||||||
|
@ -23,3 +23,10 @@ def data(TEST):
|
|||||||
workflow_1.name = "test-workflow"
|
workflow_1.name = "test-workflow"
|
||||||
|
|
||||||
TEST.workflows.add(workflow_1)
|
TEST.workflows.add(workflow_1)
|
||||||
|
|
||||||
|
# Tickets
|
||||||
|
TEST.tickets = test_data_utils.TestDataContainer()
|
||||||
|
ticket_1 = mock.Mock()
|
||||||
|
ticket_1.name = "test-ticket"
|
||||||
|
|
||||||
|
TEST.tickets.add(ticket_1)
|
||||||
|
0
evoque_dashboard/tickets/__init__.py
Normal file
0
evoque_dashboard/tickets/__init__.py
Normal file
25
evoque_dashboard/tickets/panel.py
Normal file
25
evoque_dashboard/tickets/panel.py
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
|
import horizon
|
||||||
|
|
||||||
|
from evoque_dashboard import dashboard
|
||||||
|
|
||||||
|
|
||||||
|
class Tickets(horizon.Panel):
|
||||||
|
name = _("Tickets")
|
||||||
|
slug = 'tickets'
|
||||||
|
|
||||||
|
|
||||||
|
dashboard.Ticket.register(Tickets)
|
41
evoque_dashboard/tickets/tables.py
Normal file
41
evoque_dashboard/tickets/tables.py
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
|
from horizon import tables
|
||||||
|
from horizon.utils import filters
|
||||||
|
|
||||||
|
|
||||||
|
class TicketsTable(tables.DataTable):
|
||||||
|
name = tables.Column("name", verbose_name=_("Name"))
|
||||||
|
created = tables.Column(
|
||||||
|
"created_at",
|
||||||
|
verbose_name=_("Created"),
|
||||||
|
filters=(
|
||||||
|
filters.parse_isotime,
|
||||||
|
filters.timesince_or_never
|
||||||
|
)
|
||||||
|
)
|
||||||
|
updated = tables.Column(
|
||||||
|
"updated_at",
|
||||||
|
verbose_name=_("Updated"),
|
||||||
|
filters=(
|
||||||
|
filters.parse_isotime,
|
||||||
|
filters.timesince_or_never
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
class Meta(object):
|
||||||
|
name = "tickets"
|
||||||
|
verbose_name = _("Tickets")
|
||||||
|
table_actions = (tables.FilterAction,)
|
11
evoque_dashboard/tickets/templates/tickets/index.html
Normal file
11
evoque_dashboard/tickets/templates/tickets/index.html
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
{% extends 'base.html' %}
|
||||||
|
{% load i18n %}
|
||||||
|
{% block title %}{% trans "Tickets" %}{% endblock %}
|
||||||
|
|
||||||
|
{% block page_header %}
|
||||||
|
{% include "horizon/common/_page_header.html" with title=_("Tickets") %}
|
||||||
|
{% endblock page_header %}
|
||||||
|
|
||||||
|
{% block main %}
|
||||||
|
{{ table.render }}
|
||||||
|
{% endblock %}
|
37
evoque_dashboard/tickets/tests.py
Normal file
37
evoque_dashboard/tickets/tests.py
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
# Copyright 2015 99Cloud Technologies Co., Ltd.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
|
# not use this file except in compliance with the License. You may obtain
|
||||||
|
# a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
# License for the specific language governing permissions and limitations
|
||||||
|
# under the License.
|
||||||
|
|
||||||
|
from django.core.urlresolvers import reverse
|
||||||
|
from django import http
|
||||||
|
|
||||||
|
from mox3.mox import IsA # noqa
|
||||||
|
|
||||||
|
from evoque_dashboard import api
|
||||||
|
from evoque_dashboard.test import helpers as test
|
||||||
|
|
||||||
|
INDEX_URL = reverse('horizon:ticket:tickets:index')
|
||||||
|
|
||||||
|
|
||||||
|
class TicketsTest(test.TestCase):
|
||||||
|
|
||||||
|
@test.create_stubs({api.evoque: ('ticket_list',)})
|
||||||
|
def test_index(self):
|
||||||
|
tickets = self.tickets.list()
|
||||||
|
api.evoque.ticket_list(
|
||||||
|
IsA(http.HttpRequest)).AndReturn(tickets)
|
||||||
|
self.mox.ReplayAll()
|
||||||
|
|
||||||
|
res = self.client.get(INDEX_URL)
|
||||||
|
self.assertTemplateUsed(res, 'ticket/tickets/index.html')
|
||||||
|
self.assertEqual(len(tickets), 1)
|
22
evoque_dashboard/tickets/urls.py
Normal file
22
evoque_dashboard/tickets/urls.py
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
from django.conf.urls import patterns # noqa
|
||||||
|
from django.conf.urls import url # noqa
|
||||||
|
|
||||||
|
from evoque_dashboard.tickets import views
|
||||||
|
|
||||||
|
|
||||||
|
urlpatterns = patterns(
|
||||||
|
'',
|
||||||
|
url(r'^$', views.IndexView.as_view(), name='index'),
|
||||||
|
)
|
33
evoque_dashboard/tickets/views.py
Normal file
33
evoque_dashboard/tickets/views.py
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
|
from evoque_dashboard.api import evoque
|
||||||
|
from evoque_dashboard.tickets.tables import TicketsTable
|
||||||
|
|
||||||
|
from horizon import exceptions
|
||||||
|
from horizon import tables
|
||||||
|
|
||||||
|
|
||||||
|
class IndexView(tables.DataTableView):
|
||||||
|
table_class = TicketsTable
|
||||||
|
template_name = 'ticket/tickets/index.html'
|
||||||
|
|
||||||
|
def get_data(self):
|
||||||
|
try:
|
||||||
|
tickets = evoque.ticket_list(self.request)
|
||||||
|
except Exception:
|
||||||
|
tickets = []
|
||||||
|
exceptions.handle(self.request,
|
||||||
|
_('Unable to retrieve tickets.'))
|
||||||
|
return tickets
|
Loading…
Reference in New Issue
Block a user