You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by je...@apache.org on 2016/01/08 11:43:16 UTC
[6/9] allura git commit: [#8024] ticket:872 Cleanup
[#8024] ticket:872 Cleanup
Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/b4d25454
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/b4d25454
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/b4d25454
Branch: refs/heads/ib/8024a
Commit: b4d25454557444d4134d70c1e32e72f0c18269e9
Parents: 0a1a26c
Author: Denis Kotov <de...@gmail.com>
Authored: Mon Dec 21 23:47:15 2015 +0200
Committer: Denis Kotov <de...@gmail.com>
Committed: Thu Jan 7 21:41:21 2016 +0200
----------------------------------------------------------------------
Allura/allura/controllers/site_admin.py | 27 ++---
Allura/allura/lib/validators.py | 2 +-
..._admin_site_notifications_create_update.html | 118 +++++++++++++++++++
.../site_admin_site_notifications_edit.html | 118 -------------------
.../site_admin_site_notifications_list.html | 31 ++---
.../site_admin_site_notifications_new.html | 118 -------------------
.../allura/tests/functional/test_site_admin.py | 2 +-
7 files changed, 148 insertions(+), 268 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/allura/blob/b4d25454/Allura/allura/controllers/site_admin.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/site_admin.py b/Allura/allura/controllers/site_admin.py
index 878e9aa..0faebdf 100644
--- a/Allura/allura/controllers/site_admin.py
+++ b/Allura/allura/controllers/site_admin.py
@@ -431,11 +431,6 @@ class SiteNotificationController(object):
note = M.notification.SiteNotification.query.get(_id=bson.ObjectId(id))
return SiteNotificationController(note=note), remainder
- def _check_security(self):
- with h.push_context(config.get('site_admin_project', 'allura'),
- neighborhood=config.get('site_admin_project_nbhd', 'Projects')):
- require_access(c.project, 'admin')
-
@expose('jinja:allura:templates/site_admin_site_notifications_list.html')
@with_trailing_slash
def index(self, page=0, limit=25):
@@ -455,13 +450,15 @@ class SiteNotificationController(object):
'limit': limit
}
- @expose('jinja:allura:templates/site_admin_site_notifications_new.html')
+ @expose('jinja:allura:templates/site_admin_site_notifications_create_update.html')
@without_trailing_slash
def new(self, **kw):
"""Render the New SiteNotification form"""
return dict(
form_errors=c.form_errors or {},
form_values=c.form_values or {},
+ form_title='New Site Notification',
+ form_action='create'
)
@expose()
@@ -476,12 +473,14 @@ class SiteNotificationController(object):
ThreadLocalORMSession().flush_all()
redirect('../site_notifications')
- @expose('jinja:allura:templates/site_admin_site_notifications_edit.html')
- def edit(self):
+ @expose('jinja:allura:templates/site_admin_site_notifications_create_update.html')
+ def edit(self, **kw):
if c.form_values:
return dict(
form_errors=c.form_errors or {},
form_values=c.form_values or {},
+ form_title='Edit Site Notification',
+ form_action='update'
)
form_value = {}
form_value['active'] = str(self.note.active)
@@ -491,7 +490,9 @@ class SiteNotificationController(object):
form_value['page_regex'] = self.note.page_regex if self.note.page_regex is not None else ''
form_value['page_tool_type'] = self.note.page_tool_type if self.note.page_tool_type is not None else ''
return dict(form_errors={},
- form_values=form_value)
+ form_values=form_value,
+ form_title='Edit Site Notification',
+ form_action='update')
@expose()
@require_post()
@@ -507,6 +508,7 @@ class SiteNotificationController(object):
redirect('..')
@expose()
+ @require_post()
def delete(self):
self.note.delete()
ThreadLocalORMSession().flush_all()
@@ -758,10 +760,3 @@ class StatsSiteAdminExtension(SiteAdminExtension):
def update_sidebar_menu(self, links):
links.append(SitemapEntry('Stats', '/nf/admin/stats',
ui_icon=g.icons['stats']))
-
-
-class SNEditC(object):
- @expose()
- @with_trailing_slash
- def _default(self, *args, **kwargs):
- redirect('/')
http://git-wip-us.apache.org/repos/asf/allura/blob/b4d25454/Allura/allura/lib/validators.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/validators.py b/Allura/allura/lib/validators.py
index 1f2bf6a..e0e8e06 100644
--- a/Allura/allura/lib/validators.py
+++ b/Allura/allura/lib/validators.py
@@ -309,7 +309,7 @@ class CreateTaskSchema(fe.Schema):
class CreateSiteNotificationSchema(fe.Schema):
active = fev.StringBool()
impressions = fev.Int(not_empty=True)
- content = fev.NotEmpty(messages=dict(empty='Please enter a value'))
+ content = fev.UnicodeString(not_empty=True)
user_role = fev.FancyValidator(not_empty=False, if_empty=None)
page_regex = fev.FancyValidator(not_empty=False, if_empty=None)
page_tool_type = fev.FancyValidator(not_empty=False, if_empty=None)
http://git-wip-us.apache.org/repos/asf/allura/blob/b4d25454/Allura/allura/templates/site_admin_site_notifications_create_update.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/site_admin_site_notifications_create_update.html b/Allura/allura/templates/site_admin_site_notifications_create_update.html
new file mode 100644
index 0000000..f9ba0ed
--- /dev/null
+++ b/Allura/allura/templates/site_admin_site_notifications_create_update.html
@@ -0,0 +1,118 @@
+{#-
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-#}
+{% set page="task_manager" %}
+{% set sidebar_rel = '../' %}
+{% extends 'allura:templates/site_admin.html' %}
+
+{% block extra_css %}
+<style>
+ form {
+ margin: 1em;
+ }
+ form > div {
+ margin-bottom: 1em;
+ }
+ form > div > *{
+ display: inline-block;
+ vertical-align: top;
+ }
+ form > div input,
+ form > div textarea,
+ form > div select,
+ form > .input {
+ display: block;
+ width: 300px;
+ -webkit-box-sizing: border-box;
+ -moz-box-sizing: border-box;
+ box-sizing: border-box;
+ }
+ form > div label {
+ width: 100px;
+ }
+ .error {
+ width: 300px;
+ background: none;
+ border: none;
+ color: #f00;
+ margin: 0;
+ padding: 0 0 0 .8em;
+ }
+</style>
+{% endblock %}
+
+{% macro error(field) %}
+ {% if form_errors.get(field) %}
+ <span class="error">{{form_errors.get(field)}}</span>
+ {% endif %}
+{% endmacro %}
+
+{% block content %}
+<h2>{{ form_title }}</h2>
+<form method="POST" action="{{ form_action }}">
+ <div>
+ <label>Active</label>
+ <div class="input">
+ <select name="active">
+ <option value="False">No</option>
+ <option value="True" {%- if form_values.get('active') == 'True' -%}selected{%- endif -%}>Yes</option>
+ </select>
+ </div>
+ {{error('active')}}
+ </div>
+ <div>
+ <label>Impressions</label>
+ <div class="input">
+ <input name="impressions" value="{{form_values.get('impressions', '0')}}" />
+ </div>
+ {{error('impressions')}}
+ </div>
+ <div>
+ <label>Content</label>
+ <div class="input">
+ <textarea name="content" rows="4">{{form_values.get('content', '')}}</textarea>
+ </div>
+ {{error('content')}}
+ </div>
+ <div>
+ <label>User Role</label>
+ <div class="input">
+ <input name="user_role" value="{{form_values.get('user_role', '')}}" />
+ </div>
+ {{error('user_role')}}
+ </div>
+ <div>
+ <label>Page Regex</label>
+ <div class="input">
+ <input name="page_regex" value="{{form_values.get('page_regex', '')}}" />
+ </div>
+ {{error('page_regex')}}
+ </div>
+ <div>
+ <label>Page Type</label>
+ <div class="input">
+ <input name="page_tool_type" value="{{form_values.get('page_tool_type', '')}}" />
+ </div>
+ {{error('page_tool_type')}}
+ </div>
+
+
+ <input type="submit" value="Save"/><br/>
+ {{lib.csrf_token()}}
+</form>
+{% endblock %}
http://git-wip-us.apache.org/repos/asf/allura/blob/b4d25454/Allura/allura/templates/site_admin_site_notifications_edit.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/site_admin_site_notifications_edit.html b/Allura/allura/templates/site_admin_site_notifications_edit.html
deleted file mode 100644
index 07dc916..0000000
--- a/Allura/allura/templates/site_admin_site_notifications_edit.html
+++ /dev/null
@@ -1,118 +0,0 @@
-{#-
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--#}
-{% set page="task_manager" %}
-{% set sidebar_rel = '../' %}
-{% extends 'allura:templates/site_admin.html' %}
-
-{% block extra_css %}
-<style>
- form {
- margin: 1em;
- }
- form > div {
- margin-bottom: 1em;
- }
- form > div > *{
- display: inline-block;
- vertical-align: top;
- }
- form > div input,
- form > div textarea,
- form > div select,
- form > .input {
- display: block;
- width: 300px;
- -webkit-box-sizing: border-box;
- -moz-box-sizing: border-box;
- box-sizing: border-box;
- }
- form > div label {
- width: 100px;
- }
- .error {
- width: 300px;
- background: none;
- border: none;
- color: #f00;
- margin: 0;
- padding: 0 0 0 .8em;
- }
-</style>
-{% endblock %}
-
-{% macro error(field) %}
- {% if form_errors.get(field) %}
- <span class="error">{{form_errors.get(field)}}</span>
- {% endif %}
-{% endmacro %}
-
-{% block content %}
-<h2>Edit Site Notification</h2>
-<form method="POST" action="update" id="editnote">
- <div>
- <label>Active</label>
- <div class="input">
- <select name="active">
- <option value="False">No</option>
- <option value="True" {%- if form_values.get('active') == 'True' -%}selected{%- endif -%}>Yes</option>
- </select>
- </div>
- {{error('active')}}
- </div>
- <div>
- <label>Impressions</label>
- <div class="input">
- <input name="impressions" value="{{form_values.get('impressions', '0')}}" />
- </div>
- {{error('impressions')}}
- </div>
- <div>
- <label>Content</label>
- <div class="input">
- <textarea name="content" rows="4">{{form_values.get('content', '')}}</textarea>
- </div>
- {{error('content')}}
- </div>
- <div>
- <label>User Role</label>
- <div class="input">
- <input name="user_role" value="{{form_values.get('user_role', '')}}" />
- </div>
- {{error('user_role')}}
- </div>
- <div>
- <label>Page Regex</label>
- <div class="input">
- <input name="page_regex" value="{{form_values.get('page_regex', '')}}" />
- </div>
- {{error('page_regex')}}
- </div>
- <div>
- <label>Page Type</label>
- <div class="input">
- <input name="page_tool_type" value="{{form_values.get('page_tool_type', '')}}" />
- </div>
- {{error('page_tool_type')}}
- </div>
-
-
- <input type="submit" value="Save"/><br/>
- {{lib.csrf_token()}}
-</form>
-{% endblock %}
http://git-wip-us.apache.org/repos/asf/allura/blob/b4d25454/Allura/allura/templates/site_admin_site_notifications_list.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/site_admin_site_notifications_list.html b/Allura/allura/templates/site_admin_site_notifications_list.html
index f400a96..e795c94 100644
--- a/Allura/allura/templates/site_admin_site_notifications_list.html
+++ b/Allura/allura/templates/site_admin_site_notifications_list.html
@@ -45,8 +45,8 @@
<td><small class="tooltip" title="{{ note.page_regex }}">{{ note.page_regex|truncate(20) if note.page_regex}}</small></td>
<td><small>{{ note.page_tool_type if note.page_tool_type}}</small></td>
<td>
- <a href="{{ note._id }}/edit">Edit</a><br>
- <a href="{{ note._id }}/delete">Delete</a>
+ <a href="{{ note._id }}/edit">Edit</a><br>
+ <a href="{{ note._id }}/delete" class="sn_delete">Delete</a>
</td>
</tr>
{% endfor %}
@@ -69,19 +69,22 @@
{% block extra_js %}
<script>
- $(document).ready(function() {
- $(".tooltip").tooltipster({
- animation: 'fade',
- delay: 200,
- theme: 'tooltipster-light',
- trigger: 'hover',
- iconCloning: false
- }).focus(function () {
- $(this).tooltipster('show');
- }).blur(function () {
- $(this).tooltipster('hide');
- });
+ $(document).ready(function() {
+ $(".sn_delete").on("click", function(e){
+ e.preventDefault();
+ var elem = this;
+ $.ajax({
+ type: 'POST',
+ url: elem.href,
+ data: {
+ '_session_id': $.cookie('_session_id')
+ },
+ success: function(data) {
+ $(elem).parent().parent().remove();
+ }
+ });
});
+ });
</script>
{% endblock %}
http://git-wip-us.apache.org/repos/asf/allura/blob/b4d25454/Allura/allura/templates/site_admin_site_notifications_new.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/site_admin_site_notifications_new.html b/Allura/allura/templates/site_admin_site_notifications_new.html
deleted file mode 100644
index 8123d97..0000000
--- a/Allura/allura/templates/site_admin_site_notifications_new.html
+++ /dev/null
@@ -1,118 +0,0 @@
-{#-
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--#}
-{% set page="task_manager" %}
-{% set sidebar_rel = '../' %}
-{% extends 'allura:templates/site_admin.html' %}
-
-{% block extra_css %}
-<style>
- form {
- margin: 1em;
- }
- form > div {
- margin-bottom: 1em;
- }
- form > div > *{
- display: inline-block;
- vertical-align: top;
- }
- form > div input,
- form > div textarea,
- form > div select,
- form > .input {
- display: block;
- width: 300px;
- -webkit-box-sizing: border-box;
- -moz-box-sizing: border-box;
- box-sizing: border-box;
- }
- form > div label {
- width: 100px;
- }
- .error {
- width: 300px;
- background: none;
- border: none;
- color: #f00;
- margin: 0;
- padding: 0 0 0 .8em;
- }
-</style>
-{% endblock %}
-
-{% macro error(field) %}
- {% if form_errors.get(field) %}
- <span class="error">{{form_errors.get(field)}}</span>
- {% endif %}
-{% endmacro %}
-
-{% block content %}
-<h2>New Site Notification</h2>
-<form method="POST" action="create" id="newnote">
- <div>
- <label>Active</label>
- <div class="input">
- <select name="active">
- <option value="False">No</option>
- <option value="True" {%- if form_values.get('active') == 'True' -%}selected{%- endif -%}>Yes</option>
- </select>
- </div>
- {{error('active')}}
- </div>
- <div>
- <label>Impressions</label>
- <div class="input">
- <input name="impressions" value="{{form_values.get('impressions', '0')}}" />
- </div>
- {{error('impressions')}}
- </div>
- <div>
- <label>Content</label>
- <div class="input">
- <textarea name="content" rows="4">{{form_values.get('content', '')}}</textarea>
- </div>
- {{error('content')}}
- </div>
- <div>
- <label>User Role</label>
- <div class="input">
- <input name="user_role" value="{{form_values.get('user_role', '')}}" />
- </div>
- {{error('user_role')}}
- </div>
- <div>
- <label>Page Regex</label>
- <div class="input">
- <input name="page_regex" value="{{form_values.get('page_regex', '')}}" />
- </div>
- {{error('page_regex')}}
- </div>
- <div>
- <label>Page Type</label>
- <div class="input">
- <input name="page_tool_type" value="{{form_values.get('page_tool_type', '')}}" />
- </div>
- {{error('page_tool_type')}}
- </div>
-
-
- <input type="submit" value="Save"/><br/>
- {{lib.csrf_token()}}
-</form>
-{% endblock %}
http://git-wip-us.apache.org/repos/asf/allura/blob/b4d25454/Allura/allura/tests/functional/test_site_admin.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/functional/test_site_admin.py b/Allura/allura/tests/functional/test_site_admin.py
index c8f98cc..41aa8d3 100644
--- a/Allura/allura/tests/functional/test_site_admin.py
+++ b/Allura/allura/tests/functional/test_site_admin.py
@@ -317,7 +317,7 @@ class TestSiteAdmin(TestController):
count = M.notification.SiteNotification.query.find().count()
- self.app.get('/nf/admin/site_notifications/{}/delete'.format(note._id))
+ self.app.post('/nf/admin/site_notifications/{}/delete'.format(note._id))
assert M.notification.SiteNotification.query.find().count() == count -1
assert M.notification.SiteNotification.query.get(_id=bson.ObjectId(note._id)) is None