allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [01/10] allura git commit: [#8024] ticket:872 Cleanup
Date Fri, 08 Jan 2016 18:02:31 GMT
Repository: allura
Updated Branches:
  refs/heads/master d2e8761bd -> d46244c73


[#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/e21f60d2
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/e21f60d2
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/e21f60d2

Branch: refs/heads/master
Commit: e21f60d291a21c96f2418bb05f51f0d1cd915d96
Parents: 454565e
Author: Denis Kotov <deniskkotov@gmail.com>
Authored: Mon Dec 21 23:47:15 2015 +0200
Committer: Dave Brondsema <dave@brondsema.net>
Committed: Fri Jan 8 12:18:11 2016 -0500

----------------------------------------------------------------------
 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/e21f60d2/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/e21f60d2/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/e21f60d2/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/e21f60d2/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/e21f60d2/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/e21f60d2/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/e21f60d2/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
 


Mime
View raw message