Permalink
Browse files

Add "Message of the day" field to trees

  • Loading branch information...
1 parent 257a811 commit 2db5a50013dd16caae0864923bc35a7aae439f23 @graememcc graememcc committed Aug 23, 2012
Showing with 31 additions and 4 deletions.
  1. +17 −3 treestatus/app.py
  2. +2 −0 treestatus/model.py
  3. +8 −0 treestatus/static/style.css
  4. +4 −1 treestatus/templates/tree.html
View
@@ -259,6 +259,15 @@ def del_tree(self, who, tree, reason):
self._mcDelete('tree:%s' % tree)
self._mcDelete('trees')
+ def set_motd(self, who, tree, message):
+ session = request.session
+ db_tree = session.query(model.DbTree).get(tree)
+ db_tree.message_of_the_day = message
+ self.log(tree, who, 'motd', message)
+ session.commit()
+ if self.memcache:
+ self._mcPut('tree:%s' % tree, db_tree.to_dict(), expires=60)
+
status = Status()
import flask
@@ -546,12 +555,17 @@ def update_tree(tree):
if '_method' in request.form and request.form['_method'] == 'DELETE':
return delete_tree(tree)
- if not 'reason' in request.form or not 'status' in request.form:
+ if not 'reason' in request.form or not 'status' in request.form or not 'message' in request.form:
flask.abort(400)
# Update tree status
- tags = dumps(request.form.getlist('tags'))
- status.set_status(request.environ['REMOTE_USER'], tree, request.form['status'], request.form['reason'], tags)
+ if 'reason' in request.form or 'status' in request.form:
+ tags = dumps(request.form.getlist('tags'))
+ status.set_status(request.environ['REMOTE_USER'], tree, request.form['status'], request.form['reason'], tags)
+
+ if 'message' in request.form and request.form['message'] != t['message_of_the_day']:
+ status.set_motd(request.environ['REMOTE_USER'], tree, request.form['message'])
+
return flask.redirect("/%s?nc" % tree, 303)
@app.route('/<path:tree>', methods=['DELETE'])
View
@@ -18,12 +18,14 @@ class DbTree(DbBase):
tree = Column(String(32), primary_key=True)
status = Column(String(64), default="open", nullable=False)
reason = Column(String(256), default="", nullable=False)
+ message_of_the_day = Column(String(800), default="", nullable=False)
def to_dict(self):
return dict(
tree=self.tree,
status=self.status,
reason=self.reason,
+ message_of_the_day=self.message_of_the_day,
)
class DbLog(DbBase):
@@ -74,6 +74,10 @@ a:hover.loginout, a:active.loginout {
text-decoration: none;
}
+form * {
+ vertical-align: middle;
+}
+
.error {
color: red;
}
@@ -147,6 +151,10 @@ td.tableSheriff, td.tableAdmin {
margin-right: 5px;
}
+.submit {
+ margin-top: 5px;
+}
+
#container {
min-height: 100%;
position: relative;
@@ -37,8 +37,11 @@
<label for="infra">Infrastructure related?
<input type="checkbox" name="tags" value="infra" id="infra" />
</label><br/>
+ <label for="message">MOTD
+ <textarea name="message" id="message" cols="95">{{tree.message_of_the_day}}</textarea>
+ </label><br/>
<input type="hidden" name="token" value="{{token}}" />
- <span class="atRight"><input type="submit" value="Submit"/></span>
+ <span class="atRight"><input class="submit" type="submit" value="Submit"/></span>
</form>
</div>
{% endif -%}

0 comments on commit 2db5a50

Please sign in to comment.