allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [05/10] allura git commit: [#8024] ticket:871 Finished ticket
Date Fri, 08 Jan 2016 18:02:35 GMT
[#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 <deniskkotov@gmail.com>
Authored: Wed Dec 9 20:28:27 2015 +0200
Committer: Dave Brondsema <dave@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):


Mime
View raw message