Skip to content

Commit

Permalink
forms, views, templates: Add comic title field support.
Browse files Browse the repository at this point in the history
  • Loading branch information
MostAwesomeDude committed Jun 26, 2011
1 parent 44be175 commit ad4381b
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion newrem/forms.py
Expand Up @@ -54,7 +54,8 @@ class UploadForm(Form):
file = FileField("Select a file to upload",
validators=(FileRequired("Must upload a comic!"),
FileAllowed(images, "Images only!")))
characters = TagListField("Characters")
title = TextField("Title", validators=(Required(),))
index = IntegerField("Where to insert this comic?",
validators=(Required(),))
characters = TagListField("Characters")
submit = SubmitField("Upload!")
4 changes: 2 additions & 2 deletions newrem/templates/comics.html
@@ -1,7 +1,7 @@
{% extends "base.html" %}
{% block body %}
Here's comic number {{ comic.id }}, uploaded {{ comic.time }}. It features
these characters:
Here's comic number {{ comic.id }} "{{ comic.title }}" uploaded
{{ comic.time }}. It features these characters:
<ul>
{% for character in comic.characters %}
<li>{{ character.name }}</li>
Expand Down
1 change: 1 addition & 0 deletions newrem/templates/upload.html
Expand Up @@ -6,6 +6,7 @@
enctype="multipart/form-data">
{{ form.hidden_tag() }}
{{ forms.render_field(form.file) }}
{{ forms.render_field(form.title) }}
{{ forms.render_field(form.index) }}
{{ forms.render_field(form.characters) }}
{{ forms.render_field(form.submit) }}
Expand Down
1 change: 1 addition & 0 deletions newrem/views.py
Expand Up @@ -119,6 +119,7 @@ def upload():
form.file.file.save(path)
comic = Comic(filename)
comic.characters = characters
comic.title = form.title.data

if form.index.data == 0:
comic.insert_at_head()
Expand Down

0 comments on commit ad4381b

Please sign in to comment.