[Pkg-debile-commits] [debile-web] 01/01: Draft of the ajax interface
Sylvestre Ledru
sylvestre at alioth.debian.org
Tue Aug 27 13:27:02 UTC 2013
This is an automated email from the git hooks/post-receive script.
sylvestre pushed a commit to branch update-usuability
in repository debile-web.
commit e400b68b8a74afb7e58bada03b8f15f56c079691
Author: Sylvestre Ledru <sylvestre.ledru at scilab-enterprises.com>
Date: Tue Aug 27 15:27:39 2013 +0200
Draft of the ajax interface
---
debile/blueprints/frontend.py | 26 ++++++++++++++++++++++++--
templates/search.html | 10 +++++-----
2 files changed, 29 insertions(+), 7 deletions(-)
diff --git a/debile/blueprints/frontend.py b/debile/blueprints/frontend.py
index 9d4e6b0..0cb2e77 100644
--- a/debile/blueprints/frontend.py
+++ b/debile/blueprints/frontend.py
@@ -18,10 +18,10 @@
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
-from flask import Blueprint, render_template, send_file, request
+from flask import Blueprint, render_template, send_file, request, redirect
from flask.ext.jsonpify import jsonify
-from sqlalchemy.orm import joinedload
+from sqlalchemy.orm import joinedload, cast
from lucy.orm import Package, Source, Binary, Machine, User, Job, Group
from lucy.archive import UserRepository
@@ -396,3 +396,25 @@ def search_package():
print packages_query
result = [r[0] for r in packages_query]
return jsonify(result)
+
+ at frontend.route('/package/', methods=['POST'])
+ at frontend.route('/package/<package_name>/', methods=['GET'])
+def package(package_name=""):
+ if request.method == 'POST':
+ # Switch a better url
+ return redirect('/package/'+request.form['package']+'/')
+
+ session = Session()
+ import logging
+ logging.basicConfig(filename='db.log')
+ logging.getLogger('sqlalchemy.engine').setLevel(logging.INFO)
+ packages_query = session.query(Source, Job.type, Job.subtype, Job.arch)\
+ .join(Job, Job.package_id == Source.source_id)\
+ .filter(Source.name == package_name)
+#.having(Source.version.max())
+
+ return render_template('package.html', **{
+ "package_name": package_name,
+ "package": packages_query,
+ })
+
diff --git a/templates/search.html b/templates/search.html
index 6e5a89d..5047ae9 100644
--- a/templates/search.html
+++ b/templates/search.html
@@ -7,9 +7,6 @@
</script>
<script type="text/javascript">
-function yourChangeHandler() {
-alert("foo");
-}
$(function() {
$( "#package" ).autocomplete({
source: function( request, response ) {
@@ -31,15 +28,18 @@ alert("foo");
</style>
<table><tr><td>By package</td><td>
-<form id="searchPackageForm" action="/package/">
+<form id="searchPackageForm" action="/package/" method="POST">
{{form.hidden_tag()}}
<div class="ui-widget">{{form.package(size=20)}}
<input type="submit" value="Search" /></div>
</form>
</td></tr>
<tr><td>By maintainer</td><td>
-<form>
+<form id="searchPackageForm" action="/package/">
+ {{form.hidden_tag()}}
+ <div class="ui-widget">
{{form.maintainer(size=20)}} <input type="submit" value="Search" />
+ </div>
</form>
</td></tr>
</table>
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-debile/debile-web.git
More information about the Pkg-debile-commits
mailing list