版本更新发布WEB化(5)_视图和模板

模板有三个,一个版本更新的基础的模板,带测试和正式更新的模板、只带正式更新的模板,模板写的比较简单。视图函数就一个,写的稍显复杂。
1、版本更新的基础模板,主要控制左边区域的项目选择

1
2
3
4
5
6
7
8
9
10
11
12
13
14
{% extends "body2col.html" %} 
{% block tablist %}
<li role="presentation" {%block active_1%}{%endblock%}><a href="/version/project1">project1</a></li>
<li role="presentation" {%block active_2%}{%endblock%}><a href="/version/project2">project2</a></li>
<li role="presentation" {%block active_2%}{%endblock%}><a href="/version/project3">project3</a></li>
<br>
<br>
<li role="presentation" {%block active_3%}{%endblock%}><a href="/version/project4">project4</a></li>
<li role="presentation" {%block active_4%}{%endblock%}><a href="/version/project5">project5</a></li>
<li role="presentation" {%block active_5%}{%endblock%}><a href="/version/project6">project6</a></li>
{% endblock %}
{% block rightarea%}
版本更新页面
{% endblock%}

2、只带正式更新功能的模板

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
{% extends "versionapp/verindex.html" %} 
{%block active_1 %}{ {active_1}}{%endblock%}
{%block active_2 %}{ {active_2}}{%endblock%}
{%block active_3 %}{ {active_3}}{%endblock%}
{%block active_4 %}{ {active_4}}{%endblock%}
{%block active_5 %}{ {active_5}}{%endblock%}
{%block active_6 %}{ {active_6}}{%endblock%}
{% block rightarea%}
<div class="bs-example">
<table class="table table-striped table-bordered">
<thead>
<tr>
<th>ZIP</th>
<th>MEM</th>
<th>TIME</th>
<th>STATE</th>
<th>ACTION</th>
</tr>
</thead>
<tbody>
<tr>
<form action="{ {url}}?action=upload" enctype="multipart/form-data" method="post">
<td width="15%">
<input type="file" name="zipname" />
</td>
<td width="15%">{ { lastup.1 }}</td>
<td width="25%">{ { lastup.2 }}</td>
<td width="20%">
<input type="text" class="form-control" name="filename" placeholder="Input Zip Name">
</td>
<td width="25%">
<input class="btn btn-info" type="submit" value="上传" title="上传文件"/>
</td> {% csrf_token %}
</form>
</tr>
<tr>
<td>{ { lastup.0 }}</td>
<td>{ { lastup.1 }}</td>
<td>{ { lastup.2 }}</td>
<td>{ { lastup.3 }}</td>
<td>
<a type="button" class="btn btn-success" href="{ {url}}?action=update&object=release">更新</a>
</td>
</tr>
{% for sub in upinfo %}
{% if sub %}
{% if forloop.first %}
<tr>
<td>{ { sub.0 }}</td>
<td>{ { sub.1 }}</td>
<td>{ { sub.2 }}</td>
<td>{ { sub.3 }}</td>
<td>
<a type="button" class="btn btn-warning" href="{ {url}}?action=rowback">回滚</a>
</td>
</tr>
{% else %}
<tr>
<td>{ { sub.0 }}</td>
<td>{ { sub.1 }}</td>
<td>{ { sub.2 }}</td>
<td>{ { sub.3 }}</td>
<td>
<button type="button" class="btn btn-info active">已归档</button>
</td>
</tr>
{% endif %}
{% endif %}
{% endfor %}
</tbody>
</table>
</div>
<pre>{ {value}}
{% if gitinfo %}
<strong>repo文件改变信息:</strong>
{ {gitinfo.0}}
<strong>repo提交文件信息:</strong>
{ {gitinfo.1}}
<strong>以下主机版本已更新:</strong>
{ {gitinfo.2}} {% endif %}
</pre>
{% endblock%}

3、带测试和正式更新功能的模板,此模板是上一个的加强,新增了测试测试环境控制。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
{% extends "versionapp/verindex.html" %} 
{%block active_1 %}{ {active_1}}{%endblock%}
{%block active_2 %}{ {active_2}}{%endblock%}
{%block active_3 %}{ {active_3}}{%endblock%}
{%block active_4 %}{ {active_4}}{%endblock%}
{%block active_5 %}{ {active_5}}{%endblock%}
{%block active_6 %}{ {active_6}}{%endblock%}
{% block rightarea%}
<div class="bs-example">
<table class="table table-striped table-bordered">
<thead>
<tr>
<th>ZIP</th>
<th>MEM</th>
<th>TIME</th>
<th>STATE</th>
<th>ACTION</th>
</tr>
</thead>
<tbody>
<tr>
<form action="{ {url}}?action=upload" enctype="multipart/form-data" method="post">
<td width="15%">
<input type="file" name="zipname" />
</td>
<td width="15%">{ { lastup.1 }}</td>
<td width="25%">{ { lastup.2 }}</td>
<td width="20%">
<input type="text" class="form-control" name="filename" placeholder="Input Zip Name">
</td>
<td width="25%">
<input class="btn btn-info" type="submit" value="上传" title="上传文件"/>
</td>
{% csrf_token %}
</form>
</tr>
<tr>
<td>{ { lastup.0 }}</td>
<td>{ { lastup.1 }}</td>
<td>{ { lastup.2 }}</td>
<td>{ { lastup.3 }}</td>
<td>
<a type="button" class="btn btn-success" href="{ {url}}?action=update&object=release">更新</a>
</td>
</tr>
{% for sub in upinfo %}
{% if sub %}
{% if forloop.first %}
<tr>
<td>{ { sub.0 }}</td>
<td>{ { sub.1 }}</td>
<td>{ { sub.2 }}</td>
<td>{ { sub.3 }}</td>
<td>
<a type="button" class="btn btn-warning" href="{ {url}}?action=rowback">回滚</a>
</td>
</tr>
{% else %}
<tr>
<td>{ { sub.0 }}</td>
<td>{ { sub.1 }}</td>
<td>{ { sub.2 }}</td>
<td>{ { sub.3 }}</td>
<td>
<button type="button" class="btn btn-info active">已归档</button>
</td>
</tr>
{% endif %}
{% endif %}
{% endfor %}
</tbody>
</table>
</div>
<pre>{ {value}}
{% if gitinfo %}
<strong>repo文件改变信息:</strong>
{ {gitinfo.0}}
<strong>repo提交文件信息:</strong>
{ {gitinfo.1}}
<strong>以下主机版本已更新:</strong>
{ {gitinfo.2}} {% endif %}
</pre>
{% endblock%}

4、视图函数写的稍加复杂且含有太多敏感信息,处于安全考虑就不贴了,记住视图函数一个就可以了,版本更新的开发基本就结束了,具体的效果可以看《第一个运维平台_第二版》

----------------本文结束 感谢阅读----------------