Skip to content

Commit

Permalink
List template bugfix; generating detail template.
Browse files Browse the repository at this point in the history
  • Loading branch information
audreyfeldroy committed Jul 12, 2011
1 parent 1881a17 commit dffa483
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
12 changes: 12 additions & 0 deletions startcbv/management/commands/startcbv.py
Expand Up @@ -53,7 +53,19 @@ def handle_label(self, app_name, directory=None, **options):
target = open(app_name + "/urls.py", 'w')
target.write(urls_generator(app_name, app_name.capitalize().rstrip("s")))
target.close()
target = open(app_name + "/views.py", 'w')
target.write(views_generator(app_name, app_name.capitalize().rstrip("s")))
target.close()

template_dir = 'templates/' + app_name
os.makedirs(template_dir)
target = open(template_dir + "/" + app_name.rstrip("s") + "_list.html", 'w')
target.write(list_template_generator(app_name, app_name.capitalize().rstrip("s")))
target.close()

target = open(template_dir + "/" + app_name.rstrip("s") + "_detail.html", 'w')
target.write(detail_template_generator(app_name, app_name.capitalize().rstrip("s")))
target.close()

# TODO: rather than using rstrip to create the singular form from the plural,
# use something like http://code.activestate.com/recipes/577781-pluralize-word-convert-singular-word-to-its-plural/
4 changes: 2 additions & 2 deletions startcbv/templates/startcbv/_list.html
@@ -1,11 +1,11 @@
{% templatetag openblock %} extends "base_generic.html" {% templatetag closeblock %}

{% templatetag openblock %} block title {% templatetag closeblock %}
All {{ model_name }}
All {{ app_name.capitalize }}
{% templatetag openblock %} endblock {% templatetag closeblock %}

{% templatetag openblock %} block content {% templatetag closeblock %}
<h1>All {{ model_name }}</h1>
<h1>All {{ app_name.capitalize }}</h1>

{% templatetag openblock %} if latest_{{ model_name.lower }}_list {% templatetag closeblock %}
<ul>
Expand Down

0 comments on commit dffa483

Please sign in to comment.