# HG changeset patch # User Steve Losh # Date 1272736282 14400 # Node ID 9d032dbf867dcd257fcb1b953092827217289fce # Parent b8654f4e6386218003e5cf572497276bb2cda5f3 Add signoff support to the web UI. diff -r b8654f4e6386 -r 9d032dbf867d review/api.py --- a/review/api.py Sat May 01 11:48:45 2010 -0400 +++ b/review/api.py Sat May 01 13:51:22 2010 -0400 @@ -330,6 +330,12 @@ { 'message': 'Initialize review data for changeset %s' % self.node, 'addremove': True, }) + def signoffs_for_user(self, username): + return filter(lambda s: s.author == username, self.signoffs) + + def signoffs_for_current_user(self): + return self.signoffs_for_user(self.ui.username()) + def add_signoff(self, message, opinion='', force=False): """Add (and commit) a signoff for the given revision. @@ -339,7 +345,7 @@ will be raised unless the force argument is used. """ - existing = filter(lambda s: s.author == self.ui.username(), self.signoffs) + existing = self.signoffs_for_current_user() if existing: if not force: diff -r b8654f4e6386 -r 9d032dbf867d review/web_media/comments.js --- a/review/web_media/comments.js Sat May 01 11:48:45 2010 -0400 +++ b/review/web_media/comments.js Sat May 01 13:51:22 2010 -0400 @@ -9,6 +9,12 @@ return false; }); + $("p.signoff-activate a").click(function(event) { + $(event.target).hide(); + $(event.target).closest("div").children("form").fadeIn("fast"); + return false; + }); + $("tr.rem.commentable,tr.add.commentable,tr.con.commentable").click(function(event) { $(event.target).closest("tr").addClass("comment-line-selected"); var filename = $(event.target).closest("tr").find(".line-data").children(".filename").first().text(); diff -r b8654f4e6386 -r 9d032dbf867d review/web_templates/changeset.html --- a/review/web_templates/changeset.html Sat May 01 11:48:45 2010 -0400 +++ b/review/web_templates/changeset.html Sat May 01 13:51:22 2010 -0400 @@ -37,12 +37,12 @@

Signoffs

{% for signoff in rcset.signoffs %} -
+
{{ macros.gravatar(signoff, utils) }}
{{ utils['templatefilters'].person(signoff.author) }} - signed off as {{ signoff.opinion }} on this changeset, saying: + signed off as {{ signoff.opinion or "neutral" }} on this changeset, saying:
{{ signoff.message }}
@@ -51,7 +51,27 @@ {% if not read_only %}
-

Sign off on this changeset (currently unimplemented)

+

+ {% if cu_signoff %} + Change your signoff + {% else %} + Sign off on this changeset + {% endif %} +

+
+
+ Yes + No + Neutral +
+
+ + +
+
+ +
+
{% endif %} diff -r b8654f4e6386 -r 9d032dbf867d review/web_ui.py --- a/review/web_ui.py Sat May 01 11:48:45 2010 -0400 +++ b/review/web_ui.py Sat May 01 13:51:22 2010 -0400 @@ -73,12 +73,22 @@ rev_id = args[0] if kwargs and not self.read_only: + signoff = kwargs.get('signoff', None) + if signoff: + if signoff not in ['yes', 'no', 'neutral']: + return 'Invalid signoff type.' + if signoff == 'neutral': + signoff = '' + body = kwargs.get('new-signoff-body', '') + rcset = self.datastore[rev_id] + rcset.add_signoff(body, signoff, force=True) + raise cherrypy.HTTPRedirect("/changeset/%s/" % rev_id) + filename = kwargs.get('filename', '') lines = str(kwargs['lines']) if 'lines' in kwargs else '' if lines: lines = lines.split(',') body = kwargs['new-comment-body'] - print filename, lines, body if body: rcset = self.datastore[rev_id] @@ -89,11 +99,15 @@ rcset = self.datastore[rev_id] rev = rcset.target[rev_id] + cu_signoffs = rcset.signoffs_for_current_user() + cu_signoff = cu_signoffs[0] if cu_signoffs else None + print cu_signoff + return jinja_env.get_template('changeset.html').render( read_only=self.read_only, utils=utils, datastore=self.datastore, title='%s:%s' % (rev.rev(), short(rev.node())), - rcset=rcset, rev=rev, + rcset=rcset, rev=rev, cu_signoff=cu_signoff )