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