diff options
author | 2010-08-06 16:09:59 +0300 | |
---|---|---|
committer | 2010-08-06 17:11:17 +0300 | |
commit | b66e08546785bb94f674fe2df0daf515fd36d6a2 (patch) | |
tree | a2b21e7a5ab82608dd6c78292e9c94cf3ab23613 | |
parent | Added jquery to tree (diff) | |
download | gsoc2010-grumpy-b66e08546785bb94f674fe2df0daf515fd36d6a2.tar.gz gsoc2010-grumpy-b66e08546785bb94f674fe2df0daf515fd36d6a2.tar.bz2 gsoc2010-grumpy-b66e08546785bb94f674fe2df0daf515fd36d6a2.zip |
Added developer dashboard
-rw-r--r-- | grumpy/models.py | 10 | ||||
-rw-r--r-- | grumpy/templates/_userinfo.html | 2 | ||||
-rw-r--r-- | grumpy/templates/dashboard.html | 19 | ||||
-rw-r--r-- | grumpy/templates/layout.html | 7 | ||||
-rw-r--r-- | grumpy/webapp.py | 14 |
5 files changed, 46 insertions, 6 deletions
diff --git a/grumpy/models.py b/grumpy/models.py index e099069..241afde 100644 --- a/grumpy/models.py +++ b/grumpy/models.py @@ -41,6 +41,9 @@ class Developer(db.Model): def __init__(self, email): self.email = email + def __repr__(self): + return '<%s> - %s' % (self.__class__.__name__, self.email) + class Ebuild(db.Model): """Represents single ebuilds (cpv) in the system""" @@ -156,12 +159,13 @@ class Package(db.Model): qaissues = db.relationship("PkgIssue", backref='qa_issues', \ cascade='all, delete-orphan') devs = db.relationship(Developer, secondary=package_developers, \ - backref='packages') + backref=db.backref('packages', \ + order_by=["%s.key" % __tablename__])) herds = db.relationship(Herd, secondary=package_herds, backref='packages') ebuilds = db.relationship(Ebuild, backref='package', \ - cascade='all, delete-orphan', \ - collection_class=column_mapped_collection(Ebuild.cpv)) + cascade='all, delete-orphan', \ + collection_class=column_mapped_collection(Ebuild.cpv)) def __init__(self, ebuild_src, mtime=time.time()): self.key = ebuild_src.key diff --git a/grumpy/templates/_userinfo.html b/grumpy/templates/_userinfo.html index e0eec2f..704ee79 100644 --- a/grumpy/templates/_userinfo.html +++ b/grumpy/templates/_userinfo.html @@ -1,7 +1,7 @@ {% macro show_box(g) -%} {% if g.user -%} <ul> -<li>{{ g.user.email.split('@')[0] | e }} +<li><a href="{{ url_for('dashboard') }}">{{ g.user.email.split('@')[0] | e }}</a> <li><a href="{{ url_for('logout') }}">Log out</a> </ul> {% if g.user.regtoken -%} diff --git a/grumpy/templates/dashboard.html b/grumpy/templates/dashboard.html new file mode 100644 index 0000000..0bec1f0 --- /dev/null +++ b/grumpy/templates/dashboard.html @@ -0,0 +1,19 @@ +{% extends "layout.html" %} +{% block body %} +<h2>Hi, {{ g.user.email.split('@')[0] }}</h2> +<h3>Managed packages</h3> +{% if pkgs %} +<table id="owned_pkgs"> +<thead> + <tr><th>Package</th></tr> +</thead> +<tbody> +{% for pkg in pkgs %} +<tr><td>{{ pkg.key | e }}</td></tr> +{% endfor %} +</tbody> +</table> +{% else %} +You are not listed as maintainer of any packages +{% endif %} +{% endblock %} diff --git a/grumpy/templates/layout.html b/grumpy/templates/layout.html index 381e32c..be8339f 100644 --- a/grumpy/templates/layout.html +++ b/grumpy/templates/layout.html @@ -2,6 +2,13 @@ <!doctype html> <head> <title>{% block title %}Welcome{% endblock %} | Grumpy</title> +<script type="text/javascript" language="javascript" src="{{ url_for('static', filename='js/jquery.min.js' )}}"></script> +<script type="text/javascript" language="javascript" src="{{ url_for('static', filename='js/jquery.dataTables.min.js' )}}"></script> +<script type="text/javascript"> +$(document).ready(function() { + $('#owned_pkgs').dataTable(); +} ); +</script> </head> {{ userinfo.show_box(g) }} <div class=menu> diff --git a/grumpy/webapp.py b/grumpy/webapp.py index 3973236..68bb96f 100644 --- a/grumpy/webapp.py +++ b/grumpy/webapp.py @@ -9,7 +9,7 @@ :license: BSD, see LICENSE for details. """ from . import app -from .models import db, Category, Package, User +from .models import db, Category, Developer, Package, User from .utils import requires_auth_basic, send_email from flask import (flash, g, jsonify, redirect, render_template, request, \ @@ -26,6 +26,17 @@ def before_request(): g.user = User.query.filter_by(openid=session['openid']).first() @app.route('/') +def dashboard(): + if g.user is None: + return redirect(url_for('index')) + # Fetch maintainer info + dev = Developer.query.filter_by(email=g.user.email).first() + pkgs = None + if dev and len(dev.packages): + pkgs = dev.packages + return render_template('dashboard.html', pkgs=pkgs) + + @app.route('/browse/') def index(): cats = Category.query.order_by(Category.name.asc()).all() @@ -118,7 +129,6 @@ def confirm_account(email): db.session.commit() return render_template('confirm_account.html', success=True) - @app.route('/_api/1.0/tinderbox/') @requires_auth_basic def tinderbox_api(): |