添加新接口

This commit is contained in:
tangshuangpku@hotmail.com 2016-06-07 00:59:47 +08:00
parent e5f2202104
commit fa14046104
5 changed files with 91 additions and 9 deletions

View File

@ -35,7 +35,7 @@
</div>
</div>
<div class="box-body">
<form id="form" class="form-hrizontal" action="/workspace/add/" method="POST">
<form id="form" class="form-horizontal" action="/workspace/add/" method="POST">
<div class="row">
<div class="form-group"><label class="col-sm-2 control-label">Workspace Name</label>

View File

@ -0,0 +1,76 @@
{% extends "base_AdminLTE.html" %}
{% block title %}Docklet | Create Notification{% endblock %}
{% block panel_title %}Add New Notifications{% endblock %}
{% block panel_list %}
<ol class="breadcrumb">
<li>
<a href="/dashboard/"><i class="fa fa-dashboard"></i>Home</a>
</li>
<li>
<a href="/notification/"><i class="fa fa-envelope"></i>Notifications</a>
</li>
<li class="active">
<strong>Add New Notifications</strong>
</li>
</ol>
{% endblock %}
{##}
{% block content %}
<div class="row">
<div class="col-lg-12">
<div class="box box-info">
<div class="box-header with-border">
<h3 class="box-title">Add New Notifications</h3>
<div class="box-tools pull-right">
<button type="button" class="btn btn-box-tool" data-widget="collapse">
<i class="fa fa-minus"></i>
</button>
<button type="button" class="btn btn-box-tool" data-widget="remove">
<i class="fa fa-times"></i>
</button>
</div>
</div>
<div class="box-body">
<form id="notificationForm" class="form-horizontal" action="/notification/create/" method="post">
<div class="form-group">
<label class="col-sm-2 control-label">Title</label>
<div class="col-sm-10">
<input type="text" class="form-control" name="title" id="title">
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">Content</label>
<div class="col-sm-10">
<textarea class="form-control" name="content" id="title"></textarea>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">Groups</label>
<div class="col-sm-10">
<input type="checkbox" checked name="groups" value="none" style="display: none">
<input type="checkbox" name="groups" value="all">all&nbsp;&nbsp;
{% for group_name in groups %}
<input type="checkbox" name="groups" value="{{ group_name }}">{{ group_name }}&nbsp;&nbsp;
{% endfor %}
</div>
</div>
<div class="form-group">
<div class="col-sm-4 col-sm-offset-2">
<button class="btn btn-primary" type="submit">Create</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
{% endblock %}
{% block script_src %}
{% endblock %}

View File

@ -33,12 +33,11 @@
</div>
<div class="box-body">
<p>test rendering...</p>
{% for title in notification_titles %}
<p>{{ title }}</p>
{% endfor %}
<p>
<a href="/notification/create/">
<button type="button" class="btn btn-primary"><i class="fa fa-plus"></i> Add new notification</button>
</a>
</p>
<div class="table table-responsive">
<table id="notificationTable" class="table table-striped table-bordered">
<thead>
@ -58,7 +57,7 @@
<td>{{ notify['title'] }}</td>
<td>{{ notify['content'] }}</td>
<td>
{% for group_name in notify['groups'] %}{{ group_name }}&nbsp;{% endfor %}
{% for group_name in notify['groups'] %}<code>{{ group_name }}</code>&nbsp;&nbsp;{% endfor %}
</td>
<td>{{ notify['create_date'] }}</td>
<td>{{ notify['status'] }}</td>

View File

@ -358,7 +358,7 @@ def notification_list():
return NotificationView.as_view()
@app.route("/notification/create/", methods=['POST'])
@app.route("/notification/create/", methods=['GET', 'POST'])
@administration_required
def create_notification():
return CreateNotificationView.as_view()

View File

@ -15,6 +15,13 @@ class NotificationView(normalView):
class CreateNotificationView(normalView):
template_path = 'create_notification.html'
@classmethod
def get(cls):
groups = dockletRequest.post('/user/groupNameList/')['groups']
return cls.render(cls.template_path, groups=groups)
@classmethod
def post(cls):
dockletRequest.post('/notification/create/', request.form)