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

[2/9] allura git commit: [#8024] ticket:871 Finished ticket

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

Branch: refs/heads/ib/8024a
Commit: 76e72e5919f70bb7081a29ae0d9ca93228c23c09
Parents: 5c25043
Author: Denis Kotov <de...@gmail.com>
Authored: Wed Dec 9 20:28:27 2015 +0200
Committer: Denis Kotov <de...@gmail.com>
Committed: Thu Jan 7 21:41:20 2016 +0200

----------------------------------------------------------------------
 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/76e72e59/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/76e72e59/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/76e72e59/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):