Permalink
Browse files

Merge pull request #9 from adregner/comments

Comments support
  • Loading branch information...
2 parents d85f7b8 + 2dc1bdb commit 73c0e7edb26f1ca9005d365e1e19a3f0bb82df3c @major committed Apr 16, 2012
Showing with 42 additions and 4 deletions.
  1. +20 −3 clouddns-gui.py
  2. +11 −0 templates/actions-records.html
  3. +4 −0 templates/index.html
  4. +7 −1 templates/records.html
View
@@ -60,16 +60,18 @@ def index(domainname=None):
if domainname:
domain = g.raxdns.get_domain(name=domainname)
records = domain.get_records()
+ domaincomment = domain.comment
else:
domain = None
records = None
+ domaincomment = None
#### TODO: Implement an API limits display
# limits_resp = g.raxdns.make_request('GET', ['limits'])
# limits = json.loads(limits_resp.read())
return render_template('index.html', domainobj=domain, domainname=domainname,
- domainlist=domainlist, records=records)
+ domainlist=domainlist, domaincomment=domaincomment, records=records)
@app.route("/domains/add", methods=['POST'])
@@ -197,6 +199,19 @@ def adjust_ttl(domainname=None):
return redirect("/domains/%s" % domainname)
+@app.route("/domains/<domainname>/comment", methods=['POST'])
+def domain_comment(domainname=None):
+ """Edits the comment on a domain"""
+
+ # Get the domain from the API
+ domain = g.raxdns.get_domain(name=domainname)
+
+ # Set the comment
+ domain.update(comment=request.form['comment'])
+
+ return redirect("/domains/%s" % domainname)
+
+
@app.route("/domains/<domainname>/add_record", methods=['POST'])
def add_record(domainname=None):
"""Handles adding records"""
@@ -220,15 +235,17 @@ def add_record(domainname=None):
formvars['data'],
formvars['type'],
ttl=int(formvars['ttl']),
- priority=formvars['priority'])
+ priority=formvars['priority'],
+ comment=formvars['comment'])
# Submit without priority for anything else
else:
domain.create_record(
formvars['name'],
formvars['data'],
formvars['type'],
- ttl=int(formvars['ttl']))
+ ttl=int(formvars['ttl']),
+ comment=formvars['comment'])
# Flash a friendly message
flash("Record added")
@@ -13,6 +13,7 @@ <h4>Add a record to {{domainname}}:</h4>
<th>Name</th>
<th>Data</th>
<th>Priority</th>
+ <th>Comment</th>
<th>TTL</th>
<th>&nbsp;</th>
</tr>
@@ -42,6 +43,9 @@ <h4>Add a record to {{domainname}}:</h4>
<input type="text" name="priority" class="span1"><br>
<em>MX/SRV only</em>
</td>
+ <td>
+ <input type="text" name="comment" class="span2">
+ </td>
<td>
<input type="text" name="ttl" class="span1" value="3600">
</td>
@@ -72,6 +76,13 @@ <h4>Adjust TTL's for all records:</h4>
{% endif %}
+ <hr>
+ <h4>Domain Comment</h4>
+ <form method="post" action="/domains/{{ domainname }}/comment">
+ <input type="text" class="span3" name="comment" value="{% if domaincomment %}{{ domaincomment }}{% endif %}">
+ <button class="btn btn-warning btn-small" type="submit">Save</button>
+ </form>
+
<hr>
<h4>Want to delete this domain?</h4>
Type <em>REALLYDELETE</em> in the text field and press Delete Domain. <br>
View
@@ -36,6 +36,10 @@ <h3>
<span style="color: grey">
({{ domain.id }})
</span>
+ {% if domain.comment %}
+ <br/>
+ &nbsp;&nbsp;&nbsp;&nbsp;{{ domain.comment }}
+ {% endif %}
</li>
{% else %}
<h3>
View
@@ -6,6 +6,7 @@
<th>Name</th>
<th>Data</th>
<th>Priority</th>
+ <th>Comment</th>
<th>TTL</th>
<th>&nbsp;</th>
</tr>
@@ -26,7 +27,7 @@
<td>
<input type="text" name="data" value="{{ record.data }}" class="span3">
</td>
- {% if record.type == "MX" or record.type == "SRV" %}
+ {% if record.type == "MX" %}
<td>
{{ record.priority }}
</td>
@@ -35,6 +36,11 @@
-
</td>
{% endif %}
+ <td>
+ {% if record.comment %}
+ {{ record.comment }}
+ {% endif %}
+ </td>
<td>
<input type="text" name="ttl" value="{{ record.ttl }}" style="width: 50px;">
</td>

0 comments on commit 73c0e7e

Please sign in to comment.