Notification list, Notification delete, and Notification create action and button

This commit is contained in:
cindy oneill 2014-06-09 16:14:18 -06:00
parent 7aabb29772
commit 8213375e3c
7 changed files with 36 additions and 15 deletions

View File

@ -210,7 +210,6 @@ class BaseAlarmForm(forms.SelfHandlingForm):
expressionWidget = textAreaWidget
notificationWidget = NotificationCreateWidget()
self.fields['name'] = forms.CharField(label=_("Name"),
required=required,
max_length=250,

View File

@ -81,7 +81,6 @@ def show_host(data):
class ShowAlarmHistory(tables.LinkAction):
name = 'history'
verbose_name = _('Show History')
#url = constants.URL_PREFIX + 'history'
classes = ('btn-edit',)
def get_link_url(self, datum):

View File

@ -236,8 +236,8 @@ def transform_alarm_history(results, name):
newlist = []
for item in results:
temp = {}
temp['alarm_id'] = item['alarm_id']
temp['name'] = name
temp['alarm_id'] = item['alarm_id']
temp['name'] = name
temp['old_state'] = item['old_state']
temp['new_state'] = item['new_state']
temp['timestamp'] = item['timestamp']
@ -365,8 +365,8 @@ class AlarmHistoryView(tables.DataTableView):
try:
results = api.monitor.alarm_history(self.request, id)
except:
messages.error(self.request,
_("Could not retrieve alarm history for %s") % id)
messages.error(self.request,
_("Could not retrieve alarm history for %s") % id)
return transform_alarm_history(results, name)
def get_context_data(self, **kwargs):

View File

@ -44,10 +44,10 @@ def monclient(request, password=None):
'ca_file': cacert,
'username': request.user.username,
'password': password
#'timeout': args.timeout,
#'ca_file': args.ca_file,
#'cert_file': args.cert_file,
#'key_file': args.key_file,
# 'timeout': args.timeout,
# 'ca_file': args.ca_file,
# 'cert_file': args.cert_file,
# 'key_file': args.key_file,
}
client = mon_client.Client(api_version, endpoint, **kwargs)
client.format_parameters = format_parameters
@ -92,7 +92,8 @@ def notification_list(request, marker=None, paginate=False):
def notification_delete(request, notification_id):
return monclient(request).notifications.delete(notification_id)
return monclient(request).notifications.delete(
notification_id=notification_id)
def notification_get(request, notification_id):

View File

@ -7,7 +7,5 @@
{% endblock page_header %}
{% load url from future %}
{% block main %}
Need to implement list notifications
<a href="{% url 'horizon:overcloud:notifications:notification_create' %}" class="btn btn-small btn-run showspinner">{% trans 'Create Notification' %}</a>
{{ table.render }}
{% endblock %}

View File

@ -24,4 +24,7 @@ urlpatterns = patterns(
url(r'^notification_create$',
views.NotificationCreateView.as_view(),
name='notification_create'),
# url(r'^notification_edit/(?P<id>[^/]+)$',
# views.NotificationEditView.as_view(),
# name='notification_edit'),
)

View File

@ -16,20 +16,41 @@
import logging
from django.contrib import messages
from django.core.urlresolvers import reverse_lazy, reverse # noqa
from django.views.generic import TemplateView
from horizon import forms
from horizon import tables
from . import forms as alarm_forms
from . import constants
from monitoring import api
from .tables import NotificationsTable
LOG = logging.getLogger(__name__)
class IndexView(TemplateView):
class IndexView(tables.DataTableView):
table_class = NotificationsTable
template_name = constants.TEMPLATE_PREFIX + 'index.html'
def dispatch(self, *args, **kwargs):
return super(IndexView, self).dispatch(*args, **kwargs)
def get_data(self):
results = []
try:
results = api.monitor.notification_list(self.request)
except:
messages.error(self.request, _("Could not retrieve notifications"))
return results
def get_context_data(self, **kwargs):
context = super(IndexView, self).get_context_data(**kwargs)
return context
class NotificationCreateView(forms.ModalFormView):
form_class = alarm_forms.CreateMethodForm