You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by br...@apache.org on 2016/01/08 19:02:31 UTC

[01/10] allura git commit: [#8024] ticket:872 Cleanup

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 <de...@gmail.com>
Authored: Mon Dec 21 23:47:15 2015 +0200
Committer: Dave Brondsema <da...@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
 


[05/10] allura git commit: [#8024] ticket:871 Finished ticket

Posted by br...@apache.org.
[#8024] ticket:871 Finished ticket

* change way for getting limit and page, added link for back to admin home,
*  added test for check SiteNotification on page, removed unnecessary css styles


Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/de3cd011
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/de3cd011
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/de3cd011

Branch: refs/heads/master
Commit: de3cd011a8514eceed3fe7852aaa086b4061bd56
Parents: d89d598
Author: Denis Kotov <de...@gmail.com>
Authored: Wed Dec 9 20:28:27 2015 +0200
Committer: Dave Brondsema <da...@brondsema.net>
Committed: Fri Jan 8 12:18:11 2016 -0500

----------------------------------------------------------------------
 Allura/allura/controllers/site_admin.py         | 13 +++-------
 .../site_admin_site_notifications_list.html     | 25 +++-----------------
 .../allura/tests/functional/test_site_admin.py  | 23 ++++++++++++++++--
 3 files changed, 27 insertions(+), 34 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/de3cd011/Allura/allura/controllers/site_admin.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/site_admin.py b/Allura/allura/controllers/site_admin.py
index 550f5af..ca45c46 100644
--- a/Allura/allura/controllers/site_admin.py
+++ b/Allura/allura/controllers/site_admin.py
@@ -433,23 +433,16 @@ class SiteNotificationController(object):
         c.page_list = W.page_list
         c.page_size = W.page_size
 
-        try:
-            page_url = int(page)
-        except ValueError:
-            page_url = 0
-        try:
-            limit = int(limit)
-        except ValueError:
-            limit = 25
+        limit, page = h.paging_sanitizer(limit, page)
 
         query = M.notification.SiteNotification.query.find().sort('_id', -1)
         count = query.count()
-        notifications = paginate.Page(query.all(), page_url+1, limit)
+        notifications = paginate.Page(query.all(), page+1, limit)
 
         return {
             'notifications': notifications,
             'count': count,
-            'page_url': page_url,
+            'page_url': page,
             'limit': limit
         }
 

http://git-wip-us.apache.org/repos/asf/allura/blob/de3cd011/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 7ab0ad7..5d469a2 100644
--- a/Allura/allura/templates/site_admin_site_notifications_list.html
+++ b/Allura/allura/templates/site_admin_site_notifications_list.html
@@ -21,8 +21,9 @@
 
 {% extends 'allura:templates/site_admin.html' %}
 {% block content %}
+  <div class="grid-23"><a href="/nf/admin">Back to Site Admin Home</a></div>
+  <div class="grid-23"><a href="">Create a new notification</a></div>
   {{c.page_size.display(limit=limit, page=page_url, count=count)}}
-  <div class="grid-24"><a href="">Create a new notification</a></div>
   <table id="site_notifications">
     <thead>
       <tr>
@@ -31,7 +32,7 @@
         <th>Content</th>
         <th>User Role</th>
         <th>Page Regex</th>
-        <th>Page Type</th>
+        <th>Page Tool Type</th>
         <th></th>
       </tr>
     </thead>
@@ -57,32 +58,12 @@
 
 {% block extra_css %}
 <style type="text/css">
-    .paging {
-        float: right;
-        margin: 1em;
-    }
     .pad table {
       width: 915px;
     }
     td {
         max-width: 200px;
     }
-    th.header {
-        background-image: url("{{g.forge_static('images/bg.gif')}}");
-        cursor: pointer;
-        font-weight: bold;
-        background-repeat: no-repeat;
-        background-position: center left;
-        padding-left: 20px;
-    }
-    th.headerSortUp {
-        background-image: url("{{g.forge_static('images/asc.gif')}}");
-        background-color: #6bb3fd;
-    }
-    th.headerSortDown {
-        background-image: url("{{g.forge_static('images/desc.gif')}}");
-        background-color: #6bb3fd;
-    }
 </style>
 {% endblock %}
 

http://git-wip-us.apache.org/repos/asf/allura/blob/de3cd011/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 a0c5371..ad44be3 100644
--- a/Allura/allura/tests/functional/test_site_admin.py
+++ b/Allura/allura/tests/functional/test_site_admin.py
@@ -177,15 +177,34 @@ class TestSiteAdmin(TestController):
         assert 'Login' in r
 
     def test_site_notifications(self):
+        M.notification.SiteNotification(active=True,
+                                        impressions=0,
+                                        content='test1',
+                                        user_role='test2',
+                                        page_regex='test3',
+                                        page_tool_type='test4')
+        ThreadLocalORMSession().flush_all()
+        assert M.notification.SiteNotification.query.find().count() == 1
+
         r = self.app.get('/nf/admin/site_notifications/', extra_environ=dict(
             username='root'))
-        headers = r.html.find('table').findAll('th')
+        table = r.html.find('table')
+        headers = table.findAll('th')
+        row = table.findAll('td')
+
         assert headers[0].contents[0] == 'Active'
         assert headers[1].contents[0] == 'Impressions'
         assert headers[2].contents[0] == 'Content'
         assert headers[3].contents[0] == 'User Role'
         assert headers[4].contents[0] == 'Page Regex'
-        assert headers[5].contents[0] == 'Page Type'
+        assert headers[5].contents[0] == 'Page Tool Type'
+
+        assert row[0].contents[0].contents[0] == 'True'
+        assert row[1].contents[0].contents[0] == '0'
+        assert row[2].contents[0].contents[0] == 'test1'
+        assert row[3].contents[0].contents[0] == 'test2'
+        assert row[4].contents[0].contents[0] == 'test3'
+        assert row[5].contents[0].contents[0] == 'test4'
 
 
 class TestProjectsSearch(TestController):


[07/10] allura git commit: [#8024] ticket:884 fix test

Posted by br...@apache.org.
[#8024] ticket:884 fix test


Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/38988bb3
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/38988bb3
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/38988bb3

Branch: refs/heads/master
Commit: 38988bb35a32f9039899c3e531477ac8b6260670
Parents: fffcb88
Author: Denis Kotov <de...@gmail.com>
Authored: Thu Jan 7 22:05:59 2016 +0200
Committer: Dave Brondsema <da...@brondsema.net>
Committed: Fri Jan 8 12:18:12 2016 -0500

----------------------------------------------------------------------
 Allura/allura/tests/functional/test_site_admin.py | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/38988bb3/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 41aa8d3..b55dcbc 100644
--- a/Allura/allura/tests/functional/test_site_admin.py
+++ b/Allura/allura/tests/functional/test_site_admin.py
@@ -258,8 +258,7 @@ class TestSiteAdmin(TestController):
         r = self.app.get('/nf/admin/site_notifications/{}/edit'.format(note._id))
 
         assert r
-
-        assert (u'selected', u'selected') in r.html.find('form').findAll('option')[1].attrs
+        assert 'checked' in r.form['active'].attrs
         assert r.form['impressions'].value == '0'
         assert r.form['content'].value == 'test1'
         assert r.form['user_role'].value == 'test2'


[08/10] allura git commit: [#8024] ticket:884 Change form for SiteNotification

Posted by br...@apache.org.
[#8024] ticket:884 Change form for SiteNotification


Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/b14217d5
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/b14217d5
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/b14217d5

Branch: refs/heads/master
Commit: b14217d5838e407a31154720be4e06f1b6dc7f6e
Parents: e21f60d
Author: Denis Kotov <de...@gmail.com>
Authored: Tue Jan 5 23:26:07 2016 +0200
Committer: Dave Brondsema <da...@brondsema.net>
Committed: Fri Jan 8 12:18:12 2016 -0500

----------------------------------------------------------------------
 Allura/allura/controllers/site_admin.py                     | 2 +-
 Allura/allura/lib/validators.py                             | 2 +-
 .../site_admin_site_notifications_create_update.html        | 9 +++------
 3 files changed, 5 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/b14217d5/Allura/allura/controllers/site_admin.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/site_admin.py b/Allura/allura/controllers/site_admin.py
index 0faebdf..d18248a 100644
--- a/Allura/allura/controllers/site_admin.py
+++ b/Allura/allura/controllers/site_admin.py
@@ -484,7 +484,7 @@ class SiteNotificationController(object):
             )
         form_value = {}
         form_value['active'] = str(self.note.active)
-        form_value['imressions'] = self.note.impressions
+        form_value['impressions'] = self.note.impressions
         form_value['content'] = self.note.content
         form_value['user_role'] = self.note.user_role if self.note.user_role is not None else ''
         form_value['page_regex'] = self.note.page_regex if self.note.page_regex is not None else ''

http://git-wip-us.apache.org/repos/asf/allura/blob/b14217d5/Allura/allura/lib/validators.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/validators.py b/Allura/allura/lib/validators.py
index e0e8e06..39985c7 100644
--- a/Allura/allura/lib/validators.py
+++ b/Allura/allura/lib/validators.py
@@ -307,7 +307,7 @@ class CreateTaskSchema(fe.Schema):
 
 
 class CreateSiteNotificationSchema(fe.Schema):
-    active = fev.StringBool()
+    active = fev.StringBool(if_missing=False)
     impressions = fev.Int(not_empty=True)
     content = fev.UnicodeString(not_empty=True)
     user_role = fev.FancyValidator(not_empty=False, if_empty=None)

http://git-wip-us.apache.org/repos/asf/allura/blob/b14217d5/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
index f9ba0ed..3acf0bb 100644
--- a/Allura/allura/templates/site_admin_site_notifications_create_update.html
+++ b/Allura/allura/templates/site_admin_site_notifications_create_update.html
@@ -68,17 +68,14 @@
   <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>
+      <input type="checkbox" name="active" value="yes" {%- if not form_values -%} checked {%- elif form_values|length and form_values.get('active') -%} checked {% endif %}>
     </div>
     {{error('active')}}
   </div>
   <div>
     <label>Impressions</label>
     <div class="input">
-      <input name="impressions" value="{{form_values.get('impressions', '0')}}" />
+      <input name="impressions" value="{{form_values.get('impressions', '10')}}" />
     </div>
     {{error('impressions')}}
   </div>
@@ -92,7 +89,7 @@
   <div>
     <label>User Role</label>
     <div class="input">
-      <input name="user_role" value="{{form_values.get('user_role', '')}}" />
+      <input name="user_role" value="{{form_values.get('user_role', '')}}" placeholder="e.g. Admin, Developer"/>
     </div>
     {{error('user_role')}}
   </div>


[06/10] allura git commit: [#8024] ticket:884 Amend docs

Posted by br...@apache.org.
[#8024] ticket:884 Amend docs


Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/c2f79938
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/c2f79938
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/c2f79938

Branch: refs/heads/master
Commit: c2f79938b2fda6250a99422256a37c9a141da1be
Parents: 38988bb
Author: Igor Bondarenko <je...@gmail.com>
Authored: Fri Jan 8 12:42:10 2016 +0200
Committer: Dave Brondsema <da...@brondsema.net>
Committed: Fri Jan 8 12:18:12 2016 -0500

----------------------------------------------------------------------
 Allura/docs/getting_started/administration.rst | 32 +++++++++++----------
 1 file changed, 17 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/c2f79938/Allura/docs/getting_started/administration.rst
----------------------------------------------------------------------
diff --git a/Allura/docs/getting_started/administration.rst b/Allura/docs/getting_started/administration.rst
index c6d23cb..50a3f0f 100644
--- a/Allura/docs/getting_started/administration.rst
+++ b/Allura/docs/getting_started/administration.rst
@@ -42,6 +42,7 @@ The admin interface allows you to:
 * Manage "trove" categories (for user skill choices)
 * Subscribe a user to an artifact
 * Reclone a repository
+* :ref:`Manage site notifications <site-notifications>`
 
 Customizing appearance
 ======================
@@ -301,34 +302,35 @@ Requires running: :command:`pip install suds` first. ::
 
     usage: paster script development.ini ../scripts/teamforge-import.py -- --help
 
+.. _site-notifications:
 
 Site Notifications
 ==================
 
-Allura has support for site-wide notifications that appear below the site header,
-but there is currently no UI for managing them.  They can easily be inserted via
-manual mongo queries, however:
+Allura has support for site-wide notifications that appear below the site
+header.  UI for managing them can be found under "Site Notifications" in the
+left sidebar on the :ref:`site admin interface <site-admin-interface>`.
+
+For example, setting available options to:
 
 .. code-block:: console
 
-    > db.site_notification.insert({
-    ... active: true,
-    ... impressions: 10,
-    ... content: 'You can now reimport exported project data.',
-    ... user_role: 'Developer',
-    ... page_regex: '(Home|browse_pages)',
-    ... page_tool_type: 'wiki'
-    ... })
+    Active:      ✓
+    Impressions: 10
+    Content:     You can now reimport exported project data.
+    User Role:   Developer
+    Page Regex:  (Home|browse_pages)
+    Page Type:   wiki
 
-This will create a notification that will be shown for 10 page views or until
+will create a notification that will be shown for 10 page views or until
 the user closes it manually.  The notification will be shown only for users
 which have role 'Developer' or higher in one of their projects.  And if url of
 the current page is matching regex :code:`(Home|browse_pages)` and app
-tool type is :code:`wiki`.  An :code:`impressions` value of 0 will show the
+tool type is :code:`wiki`.  An "Impressions" value of 0 will show the
 notification indefinitely (until closed).  The notification content can contain
 HTML.  Only the most recent notification will be shown, unless it has
-:code:`active:false`, in which case no notification will be shown.
-:code:`user_role`, :code:`page_regex` and :code:`page_tool_type` are optional.
+"Active" unchecked, in which case no notification will be shown.
+"User Role", "Page Regex" and "Page Type" are optional.
 
 .. _delete-projects:
 


[03/10] allura git commit: [#8024] ticket:871 remove trancate filter from tool_type column

Posted by br...@apache.org.
[#8024] ticket:871 remove trancate filter from tool_type column


Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/ea39da6a
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/ea39da6a
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/ea39da6a

Branch: refs/heads/master
Commit: ea39da6a5ae595837ad926e7cd3244f4dff8b3e4
Parents: de3cd01
Author: Denis Kotov <de...@gmail.com>
Authored: Wed Dec 9 20:38:23 2015 +0200
Committer: Dave Brondsema <da...@brondsema.net>
Committed: Fri Jan 8 12:18:11 2016 -0500

----------------------------------------------------------------------
 Allura/allura/templates/site_admin_site_notifications_list.html | 4 ++--
 Allura/allura/tests/functional/test_site_admin.py               | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/ea39da6a/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 5d469a2..7f88e54 100644
--- a/Allura/allura/templates/site_admin_site_notifications_list.html
+++ b/Allura/allura/templates/site_admin_site_notifications_list.html
@@ -32,7 +32,7 @@
         <th>Content</th>
         <th>User Role</th>
         <th>Page Regex</th>
-        <th>Page Tool Type</th>
+        <th>Page Type</th>
         <th></th>
       </tr>
     </thead>
@@ -43,7 +43,7 @@
       <td><small class="tooltip" title="{{ note.content }}">{{ note.content|truncate(50) }}</small></td>
       <td><small>{{ note.user_role if note.user_role}}</small></td>
       <td><small class="tooltip" title="{{ note.page_regex }}">{{ note.page_regex|truncate(20) if note.page_regex}}</small></td>
-      <td><small class="tooltip" title="{{ note.page_tool_type }}">{{ note.page_tool_type|truncate(20) if note.page_tool_type}}</small></td>
+      <td><small>{{ note.page_tool_type if note.page_tool_type}}</small></td>
       <td>
           <a href="">Edit</a><br>
           <a href="">Delete</a>

http://git-wip-us.apache.org/repos/asf/allura/blob/ea39da6a/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 ad44be3..6b4187f 100644
--- a/Allura/allura/tests/functional/test_site_admin.py
+++ b/Allura/allura/tests/functional/test_site_admin.py
@@ -197,7 +197,7 @@ class TestSiteAdmin(TestController):
         assert headers[2].contents[0] == 'Content'
         assert headers[3].contents[0] == 'User Role'
         assert headers[4].contents[0] == 'Page Regex'
-        assert headers[5].contents[0] == 'Page Tool Type'
+        assert headers[5].contents[0] == 'Page Type'
 
         assert row[0].contents[0].contents[0] == 'True'
         assert row[1].contents[0].contents[0] == '0'


[04/10] allura git commit: [#8024] ticket:871 Added SiteNotifications in admin

Posted by br...@apache.org.
[#8024] ticket:871 Added SiteNotifications in admin

* Add new controller for showing SiteNotifications, add link in admin menu,
* add tests


Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/d89d598f
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/d89d598f
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/d89d598f

Branch: refs/heads/master
Commit: d89d598f44405767ea9dc9bdd48a8ae318b6fef2
Parents: d2e8761
Author: Denis Kotov <de...@gmail.com>
Authored: Wed Dec 9 02:13:05 2015 +0200
Committer: Dave Brondsema <da...@brondsema.net>
Committed: Fri Jan 8 12:18:11 2016 -0500

----------------------------------------------------------------------
 Allura/allura/controllers/site_admin.py         |  37 +++++++
 .../site_admin_site_notifications_list.html     | 108 +++++++++++++++++++
 .../allura/tests/functional/test_site_admin.py  |  18 ++++
 3 files changed, 163 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/d89d598f/Allura/allura/controllers/site_admin.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/site_admin.py b/Allura/allura/controllers/site_admin.py
index b6c0223..550f5af 100644
--- a/Allura/allura/controllers/site_admin.py
+++ b/Allura/allura/controllers/site_admin.py
@@ -47,6 +47,7 @@ from allura.scripts.delete_projects import DeleteProjects
 import allura
 
 from urlparse import urlparse
+from webhelpers import paginate
 
 
 log = logging.getLogger(__name__)
@@ -66,6 +67,7 @@ class SiteAdminController(object):
         c.site_admin_sidebar_menu = self.sidebar_menu()
         self.user = AdminUserDetailsController()
         self.delete_projects = DeleteProjectsController()
+        self.site_notifications = SiteNotificationController()
 
     def _check_security(self):
         with h.push_context(config.get('site_admin_project', 'allura'),
@@ -92,6 +94,7 @@ class SiteAdminController(object):
             SitemapEntry('Search Projects', base_url + 'search_projects', ui_icon=g.icons['search']),
             SitemapEntry('Delete Projects', base_url + 'delete_projects', ui_icon=g.icons['delete']),
             SitemapEntry('Search Users', base_url + 'search_users', ui_icon=g.icons['search']),
+            SitemapEntry('Site Notifications', base_url + 'site_notifications', ui_icon=g.icons['admin']),
         ]
         for ep_name in sorted(g.entry_points['site_admin']):
             g.entry_points['site_admin'][ep_name]().update_sidebar_menu(links)
@@ -417,6 +420,40 @@ class DeleteProjectsController(object):
         redirect('.')
 
 
+class SiteNotificationController(object):
+
+    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):
+        c.page_list = W.page_list
+        c.page_size = W.page_size
+
+        try:
+            page_url = int(page)
+        except ValueError:
+            page_url = 0
+        try:
+            limit = int(limit)
+        except ValueError:
+            limit = 25
+
+        query = M.notification.SiteNotification.query.find().sort('_id', -1)
+        count = query.count()
+        notifications = paginate.Page(query.all(), page_url+1, limit)
+
+        return {
+            'notifications': notifications,
+            'count': count,
+            'page_url': page_url,
+            'limit': limit
+        }
+
+
 class TaskManagerController(object):
 
     def _check_security(self):

http://git-wip-us.apache.org/repos/asf/allura/blob/d89d598f/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
new file mode 100644
index 0000000..7ab0ad7
--- /dev/null
+++ b/Allura/allura/templates/site_admin_site_notifications_list.html
@@ -0,0 +1,108 @@
+{#-
+       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 = "site_notifications" %}
+{% set hide_left_bar = True %}
+
+{% extends 'allura:templates/site_admin.html' %}
+{% block content %}
+  {{c.page_size.display(limit=limit, page=page_url, count=count)}}
+  <div class="grid-24"><a href="">Create a new notification</a></div>
+  <table id="site_notifications">
+    <thead>
+      <tr>
+        <th>Active</th>
+        <th>Impressions</th>
+        <th>Content</th>
+        <th>User Role</th>
+        <th>Page Regex</th>
+        <th>Page Type</th>
+        <th></th>
+      </tr>
+    </thead>
+    {% for note in notifications %}
+    <tr>
+      <td><small>{{ note.active }}</small></td>
+      <td><small>{{ note.impressions}}</small></td>
+      <td><small class="tooltip" title="{{ note.content }}">{{ note.content|truncate(50) }}</small></td>
+      <td><small>{{ note.user_role if note.user_role}}</small></td>
+      <td><small class="tooltip" title="{{ note.page_regex }}">{{ note.page_regex|truncate(20) if note.page_regex}}</small></td>
+      <td><small class="tooltip" title="{{ note.page_tool_type }}">{{ note.page_tool_type|truncate(20) if note.page_tool_type}}</small></td>
+      <td>
+          <a href="">Edit</a><br>
+          <a href="">Delete</a>
+      </td>
+    </tr>
+    {% endfor %}
+  </table>
+    <div class="grid-23">
+    {{c.page_list.display(limit=limit, page=page_url, count=count)}}
+  </div>
+{% endblock %}
+
+{% block extra_css %}
+<style type="text/css">
+    .paging {
+        float: right;
+        margin: 1em;
+    }
+    .pad table {
+      width: 915px;
+    }
+    td {
+        max-width: 200px;
+    }
+    th.header {
+        background-image: url("{{g.forge_static('images/bg.gif')}}");
+        cursor: pointer;
+        font-weight: bold;
+        background-repeat: no-repeat;
+        background-position: center left;
+        padding-left: 20px;
+    }
+    th.headerSortUp {
+        background-image: url("{{g.forge_static('images/asc.gif')}}");
+        background-color: #6bb3fd;
+    }
+    th.headerSortDown {
+        background-image: url("{{g.forge_static('images/desc.gif')}}");
+        background-color: #6bb3fd;
+    }
+</style>
+{% endblock %}
+
+{% 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');
+        });
+        });
+    </script>
+{% endblock %}
+
+
+

http://git-wip-us.apache.org/repos/asf/allura/blob/d89d598f/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 fd81965..a0c5371 100644
--- a/Allura/allura/tests/functional/test_site_admin.py
+++ b/Allura/allura/tests/functional/test_site_admin.py
@@ -169,6 +169,24 @@ class TestSiteAdmin(TestController):
             task_name='allura.tests.functional.test_site_admin.test_task'))
         assert json.loads(r.body)['doc'] == 'test_task doc string'
 
+    def test_site_notifications_access(self):
+        self.app.get('/nf/admin/site_notifications', extra_environ=dict(
+            username='test_user'), status=403)
+        r = self.app.get('/nf/admin/site_notifications', extra_environ=dict(
+            username='*anonymous'), status=302).follow()
+        assert 'Login' in r
+
+    def test_site_notifications(self):
+        r = self.app.get('/nf/admin/site_notifications/', extra_environ=dict(
+            username='root'))
+        headers = r.html.find('table').findAll('th')
+        assert headers[0].contents[0] == 'Active'
+        assert headers[1].contents[0] == 'Impressions'
+        assert headers[2].contents[0] == 'Content'
+        assert headers[3].contents[0] == 'User Role'
+        assert headers[4].contents[0] == 'Page Regex'
+        assert headers[5].contents[0] == 'Page Type'
+
 
 class TestProjectsSearch(TestController):
 


[02/10] allura git commit: [#8024] ticket:872 Add, edit, remove for site notifications

Posted by br...@apache.org.
[#8024] ticket:872 Add, edit, remove for site notifications

* Add controller for Adding, editing and deleting SiteNotifications,
* Add templates for this cntrollers
* Edit link in site_admin_site_notifications_list
* Add tests


Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/454565e6
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/454565e6
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/454565e6

Branch: refs/heads/master
Commit: 454565e69a2fd5d6529e925289c9350caade5d05
Parents: ea39da6
Author: Denis Kotov <de...@gmail.com>
Authored: Fri Dec 11 14:43:51 2015 +0200
Committer: Dave Brondsema <da...@brondsema.net>
Committed: Fri Jan 8 12:18:11 2016 -0500

----------------------------------------------------------------------
 Allura/allura/controllers/site_admin.py         |  73 ++++++++++++
 Allura/allura/lib/validators.py                 |   9 ++
 .../site_admin_site_notifications_edit.html     | 118 +++++++++++++++++++
 .../site_admin_site_notifications_list.html     |   6 +-
 .../site_admin_site_notifications_new.html      | 118 +++++++++++++++++++
 .../allura/tests/functional/test_site_admin.py  | 115 ++++++++++++++++++
 6 files changed, 436 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/454565e6/Allura/allura/controllers/site_admin.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/site_admin.py b/Allura/allura/controllers/site_admin.py
index ca45c46..878e9aa 100644
--- a/Allura/allura/controllers/site_admin.py
+++ b/Allura/allura/controllers/site_admin.py
@@ -30,6 +30,7 @@ from pylons import tmpl_context as c
 from pylons import request
 from formencode import validators, Invalid
 from webob.exc import HTTPNotFound, HTTPFound
+from ming.odm import ThreadLocalORMSession
 
 from allura.app import SitemapEntry
 from allura.lib import helpers as h
@@ -422,6 +423,14 @@ class DeleteProjectsController(object):
 
 class SiteNotificationController(object):
 
+    def __init__(self, note=None):
+        self.note = note
+
+    @expose()
+    def _lookup(self, id, *remainder):
+        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')):
@@ -446,6 +455,63 @@ class SiteNotificationController(object):
             'limit': limit
         }
 
+    @expose('jinja:allura:templates/site_admin_site_notifications_new.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 {},
+        )
+
+    @expose()
+    @require_post()
+    @validate(v.CreateSiteNotificationSchema(), error_handler=new)
+    def create(self, active, impressions, content, user_role, page_regex, page_tool_type):
+        """Post a new note"""
+        M.notification.SiteNotification(
+            active=active, impressions=impressions, content=content,
+            user_role=user_role, page_regex=page_regex,
+            page_tool_type=page_tool_type)
+        ThreadLocalORMSession().flush_all()
+        redirect('../site_notifications')
+
+    @expose('jinja:allura:templates/site_admin_site_notifications_edit.html')
+    def edit(self):
+        if c.form_values:
+            return dict(
+                form_errors=c.form_errors or {},
+                form_values=c.form_values or {},
+            )
+        form_value = {}
+        form_value['active'] = str(self.note.active)
+        form_value['imressions'] = self.note.impressions
+        form_value['content'] = self.note.content
+        form_value['user_role'] = self.note.user_role if self.note.user_role is not None else ''
+        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)
+
+    @expose()
+    @require_post()
+    @validate(v.CreateSiteNotificationSchema(), error_handler=edit)
+    def update(self, active=True, impressions=0, content='', user_role=None, page_regex=None, page_tool_type=None):
+        self.note.active = active
+        self.note.impressions = impressions
+        self.note.content = content
+        self.note.user_role = user_role
+        self.note.page_regex = page_regex
+        self.note.page_tool_type = page_tool_type
+        ThreadLocalORMSession().flush_all()
+        redirect('..')
+
+    @expose()
+    def delete(self):
+        self.note.delete()
+        ThreadLocalORMSession().flush_all()
+        redirect(request.referer)
+
 
 class TaskManagerController(object):
 
@@ -692,3 +758,10 @@ 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/454565e6/Allura/allura/lib/validators.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/validators.py b/Allura/allura/lib/validators.py
index 344af39..1f2bf6a 100644
--- a/Allura/allura/lib/validators.py
+++ b/Allura/allura/lib/validators.py
@@ -306,6 +306,15 @@ class CreateTaskSchema(fe.Schema):
     path = PathValidator(strip=True, if_missing={}, if_empty={})
 
 
+class CreateSiteNotificationSchema(fe.Schema):
+    active = fev.StringBool()
+    impressions = fev.Int(not_empty=True)
+    content = fev.NotEmpty(messages=dict(empty='Please enter a value'))
+    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)
+
+
 class DateValidator(fev.FancyValidator):
 
     def _to_python(self, value, state):

http://git-wip-us.apache.org/repos/asf/allura/blob/454565e6/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
new file mode 100644
index 0000000..07dc916
--- /dev/null
+++ b/Allura/allura/templates/site_admin_site_notifications_edit.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>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/454565e6/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 7f88e54..f400a96 100644
--- a/Allura/allura/templates/site_admin_site_notifications_list.html
+++ b/Allura/allura/templates/site_admin_site_notifications_list.html
@@ -22,7 +22,7 @@
 {% extends 'allura:templates/site_admin.html' %}
 {% block content %}
   <div class="grid-23"><a href="/nf/admin">Back to Site Admin Home</a></div>
-  <div class="grid-23"><a href="">Create a new notification</a></div>
+  <div class="grid-23"><a href="new">Create a new notification</a></div>
   {{c.page_size.display(limit=limit, page=page_url, count=count)}}
   <table id="site_notifications">
     <thead>
@@ -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="">Edit</a><br>
-          <a href="">Delete</a>
+          <a href="{{ note._id }}/edit">Edit</a><br>
+          <a href="{{ note._id }}/delete">Delete</a>
       </td>
     </tr>
     {% endfor %}

http://git-wip-us.apache.org/repos/asf/allura/blob/454565e6/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
new file mode 100644
index 0000000..8123d97
--- /dev/null
+++ b/Allura/allura/templates/site_admin_site_notifications_new.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>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/454565e6/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 6b4187f..c8f98cc 100644
--- a/Allura/allura/tests/functional/test_site_admin.py
+++ b/Allura/allura/tests/functional/test_site_admin.py
@@ -18,6 +18,7 @@
 
 import json
 import datetime as dt
+import bson
 
 from mock import patch, MagicMock
 from nose.tools import assert_equal, assert_in, assert_not_in
@@ -206,6 +207,120 @@ class TestSiteAdmin(TestController):
         assert row[4].contents[0].contents[0] == 'test3'
         assert row[5].contents[0].contents[0] == 'test4'
 
+    def test_site_notification_new_template(self):
+        r = self.app.get('/nf/admin/site_notifications/new')
+
+        assert r
+        assert 'New Site Notification' in r
+        assert 'Active' in r
+        assert 'Impressions' in r
+        assert 'Content' in r
+        assert 'User Role' in r
+        assert 'Page Regex' in r
+        assert 'Page Type' in r
+
+    def test_site_notification_create(self):
+        count = M.notification.SiteNotification.query.find().count()
+        active = 'True'
+        impressions = '7'
+        content = 'test1'
+        user_role = 'test2'
+        page_regex = 'test3'
+        page_tool_type = 'test4'
+        r = self.app.post('/nf/admin/site_notifications/create', params=dict(
+            active=active,
+            impressions=impressions,
+            content=content,
+            user_role=user_role,
+            page_regex=page_regex,
+            page_tool_type=page_tool_type))
+        note = M.notification.SiteNotification.query.find().sort('_id', -1).next()
+
+        assert '/nf/admin/site_notifications' in r.location
+
+        assert M.notification.SiteNotification.query.find().count() == count + 1
+
+        assert note.active == bool('True')
+        assert note.impressions == int(impressions)
+        assert note.content == content
+        assert note.user_role == user_role
+        assert note.page_regex == page_regex
+        assert note.page_tool_type == page_tool_type
+
+    def test_site_notification_edit_template(self):
+        note = M.notification.SiteNotification(active=True,
+                                               impressions=0,
+                                               content='test1',
+                                               user_role='test2',
+                                               page_regex='test3',
+                                               page_tool_type='test4')
+        ThreadLocalORMSession().flush_all()
+        r = self.app.get('/nf/admin/site_notifications/{}/edit'.format(note._id))
+
+        assert r
+
+        assert (u'selected', u'selected') in r.html.find('form').findAll('option')[1].attrs
+        assert r.form['impressions'].value == '0'
+        assert r.form['content'].value == 'test1'
+        assert r.form['user_role'].value == 'test2'
+        assert r.form['page_regex'].value == 'test3'
+        assert r.form['page_tool_type'].value == 'test4'
+
+        assert 'Edit Site Notification' in r
+        assert 'Active' in r
+        assert 'Impressions' in r
+        assert 'Content' in r
+        assert 'User Role' in r
+        assert 'Page Regex' in r
+        assert 'Page Type' in r
+
+    def test_site_notification_update(self):
+        active = 'True'
+        impressions = '7'
+        content = 'test1'
+        user_role = 'test2'
+        page_regex = 'test3'
+        page_tool_type = 'test4'
+
+        note = M.notification.SiteNotification(active=False,
+                                               impressions=0,
+                                               content='test')
+        ThreadLocalORMSession().flush_all()
+
+        count = M.notification.SiteNotification.query.find().count()
+
+        r = self.app.post('/nf/admin/site_notifications/{}/update'.format(note._id), params=dict(
+            active=active,
+            impressions=impressions,
+            content=content,
+            user_role=user_role,
+            page_regex=page_regex,
+            page_tool_type=page_tool_type))
+        ThreadLocalORMSession().flush_all()
+
+        note = M.notification.SiteNotification.query.find().sort('_id', -1).next()
+
+        assert '/nf/admin/site_notifications' in r.location
+        assert M.notification.SiteNotification.query.find().count() == count
+        assert note.active == bool('True')
+        assert note.impressions == int(impressions)
+        assert note.content == content
+        assert note.user_role == user_role
+        assert note.page_regex == page_regex
+        assert note.page_tool_type == page_tool_type
+
+    def test_site_notification_delete(self):
+        note = M.notification.SiteNotification(active=False,
+                                               impressions=0,
+                                               content='test')
+        ThreadLocalORMSession().flush_all()
+
+        count = M.notification.SiteNotification.query.find().count()
+
+        self.app.get('/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
+
 
 class TestProjectsSearch(TestController):
 


[09/10] allura git commit: [#8024] ticket:884 fix checkbox, add placeholder for page_tool_type

Posted by br...@apache.org.
[#8024] ticket:884 fix checkbox, add placeholder for page_tool_type


Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/fffcb88d
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/fffcb88d
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/fffcb88d

Branch: refs/heads/master
Commit: fffcb88d374cd965e7a85c60ccf70de0057b3e42
Parents: b14217d
Author: Denis Kotov <de...@gmail.com>
Authored: Wed Jan 6 15:19:59 2016 +0200
Committer: Dave Brondsema <da...@brondsema.net>
Committed: Fri Jan 8 12:18:12 2016 -0500

----------------------------------------------------------------------
 Allura/allura/controllers/site_admin.py                |  2 +-
 .../site_admin_site_notifications_create_update.html   | 13 ++++++++-----
 2 files changed, 9 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/fffcb88d/Allura/allura/controllers/site_admin.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/site_admin.py b/Allura/allura/controllers/site_admin.py
index d18248a..b543f3e 100644
--- a/Allura/allura/controllers/site_admin.py
+++ b/Allura/allura/controllers/site_admin.py
@@ -464,7 +464,7 @@ class SiteNotificationController(object):
     @expose()
     @require_post()
     @validate(v.CreateSiteNotificationSchema(), error_handler=new)
-    def create(self, active, impressions, content, user_role, page_regex, page_tool_type):
+    def create(self, impressions, content, user_role, page_regex, page_tool_type, active=False):
         """Post a new note"""
         M.notification.SiteNotification(
             active=active, impressions=impressions, content=content,

http://git-wip-us.apache.org/repos/asf/allura/blob/fffcb88d/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
index 3acf0bb..e02284e 100644
--- a/Allura/allura/templates/site_admin_site_notifications_create_update.html
+++ b/Allura/allura/templates/site_admin_site_notifications_create_update.html
@@ -34,14 +34,17 @@
   }
   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  input:not([type="checkbox"]),
+  form > div textarea,
+  form > .input {
+    width: 300px;
+  }
   form > div label {
     width: 100px;
   }
@@ -68,7 +71,7 @@
   <div>
     <label>Active</label>
     <div class="input">
-      <input type="checkbox" name="active" value="yes" {%- if not form_values -%} checked {%- elif form_values|length and form_values.get('active') -%} checked {% endif %}>
+      <input type="checkbox" name="active" value="yes" {%- if not form_values|length -%} checked {%- elif form_values.get('active') == 'True' -%} checked {% endif %}>
     </div>
     {{error('active')}}
   </div>
@@ -96,14 +99,14 @@
   <div>
     <label>Page Regex</label>
     <div class="input">
-      <input name="page_regex" value="{{form_values.get('page_regex', '')}}" />
+      <input name="page_regex" value="{{form_values.get('page_regex', '')}}" placeholder="e.g. (Home|browse_pages)"/>
     </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', '')}}" />
+      <input name="page_tool_type" value="{{form_values.get('page_tool_type', '')}}" placeholder="e.g. Wiki, Tickets"/>
     </div>
     {{error('page_tool_type')}}
   </div>


[10/10] allura git commit: [#8024] tweak checkbox value so it stays checked, if you get an error on submitting

Posted by br...@apache.org.
[#8024] tweak checkbox value so it stays checked, if you get an error on submitting


Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/d46244c7
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/d46244c7
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/d46244c7

Branch: refs/heads/master
Commit: d46244c7314646c9692ed7573f918d4612fb8a7f
Parents: c2f7993
Author: Dave Brondsema <da...@brondsema.net>
Authored: Fri Jan 8 13:01:53 2016 -0500
Committer: Dave Brondsema <da...@brondsema.net>
Committed: Fri Jan 8 13:01:53 2016 -0500

----------------------------------------------------------------------
 .../templates/site_admin_site_notifications_create_update.html     | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/d46244c7/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
index e02284e..0d3c730 100644
--- a/Allura/allura/templates/site_admin_site_notifications_create_update.html
+++ b/Allura/allura/templates/site_admin_site_notifications_create_update.html
@@ -71,7 +71,7 @@
   <div>
     <label>Active</label>
     <div class="input">
-      <input type="checkbox" name="active" value="yes" {%- if not form_values|length -%} checked {%- elif form_values.get('active') == 'True' -%} checked {% endif %}>
+      <input type="checkbox" name="active" value="True" {%- if not form_values|length -%} checked {%- elif form_values.get('active') == 'True' -%} checked {% endif %}>
     </div>
     {{error('active')}}
   </div>