Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

allow selection of content generators

  • Loading branch information...
commit 53e7c97ff083968c6d78ebc5d99632da11a58cac 1 parent adfa157
@rctay authored
Showing with 15 additions and 3 deletions.
  1. +5 −1 handlers.py
  2. +3 −1 post_deploy.py
  3. +7 −1 themes/default/admin/index.html
View
6 handlers.py
@@ -58,6 +58,7 @@ def render_to_response(self, template_name, template_vals=None, theme=None):
class AdminHandler(BaseHandler):
def get(self):
+ from generators import generator_list
offset = int(self.request.get('start', 0))
count = int(self.request.get('count', 20))
posts = models.BlogPost.all().order('-published').fetch(count, offset)
@@ -68,6 +69,7 @@ def get(self):
'prev_offset': max(0, offset - count),
'next_offset': offset + count,
'posts': posts,
+ 'generators': [cls.__name__ for cls in generator_list],
}
self.render_to_response("index.html", template_vals)
@@ -130,7 +132,9 @@ def get(self, post):
class RegenerateHandler(BaseHandler):
def post(self):
+ generators = self.request.get_all("generators")
+
regen = post_deploy.PostRegenerator()
- deferred.defer(regen.regenerate)
+ deferred.defer(regen.regenerate, classes=generators)
deferred.defer(post_deploy.try_post_deploy, force=True)
self.render_to_response("regenerating.html")
View
4 post_deploy.py
@@ -17,12 +17,14 @@ class PostRegenerator(object):
def __init__(self):
self.seen = set()
- def regenerate(self, batch_size=50, start_ts=None):
+ def regenerate(self, batch_size=50, start_ts=None, classes=None):
q = models.BlogPost.all().order('-published')
q.filter('published <', start_ts or datetime.datetime.max)
posts = q.fetch(batch_size)
for post in posts:
for generator_class, deps in post.get_deps(True):
+ if classes and (not generator_class.__name__ in classes):
+ continue
for dep in deps:
if (generator_class.__name__, dep) not in self.seen:
logging.warn((generator_class.__name__, dep))
View
8 themes/default/admin/index.html
@@ -57,6 +57,12 @@
<h2>Admin Actions</h2>
<form method="post" action="{{config.url_prefix}}/admin/regenerate">
- <input type="submit" value="Regenerate all posts" />
+ <label for="gen_list">Available content generators:</label><br />
+ <select multiple="true" id="gen_list" name="generators">
+ {% for gen in generators %}
+ <option selected="true">{{gen}}</option>
+ {% endfor %}
+ </select><br />
+ <input type="submit" value="Regenerate" />
</form>
{% endblock %}
Please sign in to comment.
Something went wrong with that request. Please try again.