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 2014/08/25 13:33:36 UTC
[16/42] git commit: [#7278] ticket:612 Page,
form and pagination controls
[#7278] ticket:612 Page, form and pagination controls
Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/5f904ef6
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/5f904ef6
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/5f904ef6
Branch: refs/heads/je/42cc_7585
Commit: 5f904ef612c98c1f811bc645b9c7c13e5c252e6d
Parents: f12e4aa
Author: Igor Bondarenko <je...@gmail.com>
Authored: Fri Jul 25 15:01:42 2014 +0300
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Thu Aug 21 18:49:52 2014 +0000
----------------------------------------------------------------------
Allura/allura/controllers/site_admin.py | 18 +++++++++++
Allura/allura/lib/widgets/forms.py | 23 ++++++++++++++
.../templates/site_admin_search_projects.html | 33 ++++++++++++++++++++
3 files changed, 74 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/allura/blob/5f904ef6/Allura/allura/controllers/site_admin.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/site_admin.py b/Allura/allura/controllers/site_admin.py
index 0b215f8..abe5800 100644
--- a/Allura/allura/controllers/site_admin.py
+++ b/Allura/allura/controllers/site_admin.py
@@ -37,6 +37,7 @@ from allura.lib.plugin import SiteAdminExtension
from allura.lib.security import require_access
from allura.lib.widgets import form_fields as ffw
from allura.ext.admin.widgets import AuditLog
+from allura.lib.widgets import forms
from allura import model as M
from allura.command.show_models import dfs, build_model_inheritance_graph
import allura
@@ -51,6 +52,7 @@ class W:
page_list = ffw.PageList()
page_size = ffw.PageSize()
audit = AuditLog()
+ search_projects_form = forms.SearchProjectsForm()
class SiteAdminController(object):
@@ -82,6 +84,7 @@ class SiteAdminController(object):
SitemapEntry('Reclone Repo', base_url + 'reclone_repo', ui_icon=g.icons['admin']),
SitemapEntry('Task Manager', base_url + 'task_manager?state=busy', ui_icon=g.icons['stats']),
SitemapEntry('Users Audit Log', base_url + 'users', ui_icon=g.icons['admin']),
+ SitemapEntry('Search Projects', base_url + 'search_projects', ui_icon=g.icons['search']),
]
for ep_name in sorted(g.entry_points['site_admin']):
g.entry_points['site_admin'][ep_name]().update_sidebar_menu(links)
@@ -284,6 +287,21 @@ class SiteAdminController(object):
flash('Can not add comment "%s" for user %s' % (comment, user))
redirect(request.referer)
+ @without_trailing_slash
+ @expose('jinja:allura:templates/site_admin_search_projects.html')
+ @validate(validators=dict(q=validators.UnicodeString(if_empty=None),
+ limit=validators.Int(if_invalid=None),
+ page=validators.Int(if_empty=0, if_invalid=0)))
+ def search_projects(self, q=None, page=0, limit=None, **kw):
+ c.search_projects_form = W.search_projects_form
+ c.page_list = W.page_list
+ c.page_size = W.page_size
+ return {
+ 'count': 2,
+ 'page': page,
+ 'limit': limit,
+ }
+
class TaskManagerController(object):
http://git-wip-us.apache.org/repos/asf/allura/blob/5f904ef6/Allura/allura/lib/widgets/forms.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/widgets/forms.py b/Allura/allura/lib/widgets/forms.py
index 3a257c1..a8f2dda 100644
--- a/Allura/allura/lib/widgets/forms.py
+++ b/Allura/allura/lib/widgets/forms.py
@@ -1079,3 +1079,26 @@ class AwardGrantForm(ForgeForm):
validator=fev.UnicodeString(not_empty=False),
attrs={'rows': 5, 'cols': 30}),
]
+
+
+class SearchProjectsForm(ForgeForm):
+ defaults = dict(
+ ForgeForm.defaults,
+ action='',
+ method='get',
+ submit_text=None)
+
+ @property
+ def fields(self):
+ return [
+ ew.RowField(fields=[
+ ew.SingleSelectField(
+ name='f',
+ show_label=False,
+ options=['shortname']),
+ ew.InputField(name='q', show_label=False),
+ ew.SubmitButton(
+ show_label=False,
+ attrs={'value': 'Search'},
+ show_errors=False),
+ ])]
http://git-wip-us.apache.org/repos/asf/allura/blob/5f904ef6/Allura/allura/templates/site_admin_search_projects.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/site_admin_search_projects.html b/Allura/allura/templates/site_admin_search_projects.html
new file mode 100644
index 0000000..51d6969
--- /dev/null
+++ b/Allura/allura/templates/site_admin_search_projects.html
@@ -0,0 +1,33 @@
+{#-
+ 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.
+-#}
+{% extends 'allura:templates/site_admin.html' %}
+
+{% block title %}Search Projects{% endblock %}
+{% block header %}Search Projects{% endblock %}
+
+{% block content %}
+ <div class="grid-19">
+ {{ c.search_projects_form.display() }}
+ </div>
+
+ <div class="grid-19">
+ {{c.page_list.display(limit=limit, page=page, count=count)}}
+ {{c.page_size.display(limit=limit, page=page, count=count)}}
+ </div>
+{% endblock %}