blob: dc5f06a792d0080b928889c232052089248f837c [file] [log] [blame]
Pingping Lind28ab982016-08-29 18:42:52 +00001from django.http import HttpResponse
2from django.views.generic import TemplateView, View
3from django import template
4from core.models import *
5import json
6import os
7import time
8import tempfile
9
10
11class MCordView(TemplateView):
12 head_template = r"""{% extends "admin/dashboard/dashboard_base.html" %}
13 {% load admin_static %}
14 {% block content %}
15 """
16
17 tail_template = r"{% endblock %}"
18
19 def get(self, request, name="root", *args, **kwargs):
20 head_template = self.head_template
21 tail_template = self.tail_template
22
23 title = request.GET.get('service', '')
24 url = "/mcord/?service=%s" % (title)
25
26 form = """
27 <h2 class="content-title">Change %s Service</h2>
28 <div id="content-main">
29 <form class="form-horizontal">
30 <div class="tab-content tab-content-main">
31 <div class="suit-include suit-tab suit-tab-administration hide">
32 <div class="left-nav">
33 <ul>
34 <li><a href="/admin/ceilometer/monitoringchannel/">Monitoring Channels</a></li>
35 </ul>
36 </div>
37 </div>
38 <fieldset class="module aligned suit-tab suit-tab-general show">
39 <div class="panel fieldset-body">
40 <div class="form-group field-backend_status_text ">
41 <label class="control-label col-xs-12 col-sm-2"><label>Backend status text:</label></label>
42 <div class="form-column col-xs-12 col-sm-8 col-md-6 col-lg-4">
43 <p><img src="/static/admin/img/icon_clock.gif"> Pending sync, last_status = 0 - Provisioning in progress</p>
44 </div>
45 </div>
46 <div class="form-group field-name ">
47 <label class="control-label col-xs-12 col-sm-2"><label class="required" for="id_name">Name:</label></label>
48 <div class="form-column widget-AdminTextInputWidget col-xs-12 col-sm-8 col-md-6 col-lg-4">
49 <input class="vTextField form-control" id="id_name" maxlength="30" name="name" type="text" value="%s">
50 <div class="help-block">Service Name</div>
51 </div>
52 </div>
53 <div class="form-group field-enabled ">
54 <label class="control-label col-xs-12 col-sm-2"><label class="vCheckboxLabel" for="id_enabled">Enabled</label></label>
55 <div class="form-column widget-CheckboxInput col-xs-12 col-sm-8 col-md-6 col-lg-4">
56 <input checked="checked" id="id_enabled" name="enabled" type="checkbox">
57 </div>
58 </div>
59 <div class="form-group field-versionNumber ">
60 <label class="control-label col-xs-12 col-sm-2"><label class="required" for="id_versionNumber">VersionNumber:</label></label>
61 <div class="form-column widget-AdminTextInputWidget col-xs-12 col-sm-8 col-md-6 col-lg-4">
62 <input class="vTextField form-control" id="id_versionNumber" maxlength="30" name="versionNumber" type="text">
63 <div class="help-block">Version of Service Definition</div>
64 </div>
65 </div>
66 <div class="form-group field-description ">
67 <label class="control-label col-xs-12 col-sm-2"><label for="id_description">Description:</label></label>
68 <div class="form-column widget-AdminTextareaWidget col-xs-12 col-sm-8 col-md-6 col-lg-4">
69 <textarea class="vLargeTextField form-control" cols="40" id="id_description" maxlength="254" name="description" rows="10"></textarea>
70 <div class="help-block">Description of Service</div>
71 </div>
72 </div>
73 <div class="form-group field-view_url ">
74 <label class="control-label col-xs-12 col-sm-2"><label for="id_view_url">View url:</label></label>
75 <div class="form-column widget-AdminTextInputWidget col-xs-12 col-sm-8 col-md-6 col-lg-4">
76 <input class="vTextField form-control" id="id_view_url" maxlength="1024" name="view_url" type="text" value="%s">
77 </div>
78 </div>
79 <div class="form-group field-icon_url ">
80 <label class="control-label col-xs-12 col-sm-2"><label for="id_icon_url">Icon url:</label></label>
81 <div class="form-column widget-AdminTextInputWidget col-xs-12 col-sm-8 col-md-6 col-lg-4">
82 <input class="vTextField form-control" id="id_icon_url" maxlength="1024" name="icon_url" type="text">
83 </div>
84 </div>
85 </div>
86 </fieldset>
87 </div>
88 </form>
89 <div class="form-buttons clearfix">
90 <button type="submit" class="btn btn-high btn-success" name="_save">Save</button>
91 <button type="submit" name="_continue" class=" btn btn-high btn-info">Save and continue editing</button>
92 <button type="submit" name="_addanother" class="btn btn-info">Save and add another</button>
93 <a href="delete/" class="text-error deletelink">Delete</a>
94 </div>
95 </div>
96 """ % (title, title, url)
97
98 t = template.Template(head_template + form + tail_template)
99
100 response_kwargs = {}
101 response_kwargs.setdefault('content_type', self.content_type)
102 return self.response_class(
103 request=request,
104 template=t,
105 **response_kwargs
106 )