Skip to content

Commit e0b3413

Browse files
committed
Update column definitions in index table of section 14 to only have 3 columns.
1 parent cce6e9b commit e0b3413

File tree

26 files changed

+62
-93
lines changed

26 files changed

+62
-93
lines changed

curriculum/section14/lectures/06_create_form_with_wtforms/README.md

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,7 @@ excerpt: Learn how to use WTForms to create a form that you can easily render us
1111
draft: true
1212
---
1313

14-
- [ ] Set metadata above
15-
- [ ] Start writing!
16-
- [ ] Create `start` folder
17-
- [ ] Create `end` folder
18-
- [ ] Write TL;DR
14+
1915
- [ ] Create per-file diff between `end` and `start` (use "Compare Folders")
2016

2117

@@ -32,9 +28,9 @@ pip install flask-wtf
3228

3329
### What is a CSRF token?
3430

35-
Cross-Site Request Forgery (CSRF)[^csrf] is a web security vulnerability. Essentially it allows an attacker to go back to a previously-submitted form, and re-submit it.
31+
Cross-Site Request Forgery (CSRF)[^csrf] is a web security vulnerability. It allows an attacker to trick the browser into submitting a form that sends data to your application, without the user noticing it.
3632

37-
By including a unique token generated by the Flask server in all requests, it prevents the possibility of a CSRF attack because the attacker can't just load the previously-visited page and re-submit the form. They must re-load the page first, for which they'll need to log-in.
33+
By including a unique token generated by the Flask server in all requests, it prevents the possibility of a CSRF attack because the attacker will need the server to generate the form, which comes with the whole HTML page and usually requires the user to log-in first.
3834

3935
## Create a WTForm Class
4036
Let's create a new file called `movie_library/forms.py`. There, we will create a Python class that represents our form.

curriculum/section14/lectures/07_render_wtform_with_jinja_macros/README.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,7 @@ Note that I've made it be able to receive `GET` and `POST` requests. The templat
4545

4646
For now, the `POST` request does nothing. Let's render our form first, and handle receiving the data in the next lecture.
4747

48-
## Render the WTForms form in the template
49-
50-
### How to render a WTForms field
48+
## How to render a WTForms field
5149

5250
First things first, let's create our `templates/new_form.html` file. This is where our form will live:
5351

@@ -109,7 +107,8 @@ A field consists of three parts:
109107

110108
You can pass CSS classes to the label and field with the `class_` keyword argument.
111109

112-
### Extract the rendering of a field into a macro
110+
## Extract the rendering of a field into a macro
111+
113112
We have three fields in our form: `title`, `director`, and `year`. All three fields will be rendered in exactly the same way: with `field.label()`, `field()`, and a list of errors.
114113

115114
Therefore this is a perfect candidate for a Jinja macro!
@@ -147,7 +146,7 @@ Now we can just import that from `templates/new_form.html` and use it three time
147146
{% endblock %}
148147
```
149148

150-
### Render all the form fields
149+
## Render all the form fields (including CSRF field)
151150

152151
There are two more fields we need to include in our form: the CSRF protection field, and the submit button.
153152

curriculum/section14/lectures/09_display_table_of_all_movies/README.md

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,9 @@ First we'll start with creating the table and defining the columns and their siz
4747
{% if movies_data %}
4848
<table class="table">
4949
<colgroup>
50-
<col style="width: 55%">
51-
<col style="width: 20%">
50+
<col style="width: 60%">
51+
<col style="width: 25%">
5252
<col style="width: 15%">
53-
<col style="width: 10%">
5453
</colgroup>
5554
<thead>
5655

@@ -72,10 +71,9 @@ Next, we'll define the headers:
7271
{% if movies_data %}
7372
<table class="table">
7473
<colgroup>
75-
<col style="width: 55%">
76-
<col style="width: 20%">
74+
<col style="width: 60%">
75+
<col style="width: 25%">
7776
<col style="width: 15%">
78-
<col style="width: 10%">
7977
</colgroup>
8078
<thead>
8179
<th class="table__cell table__cell--header">Title</th>
@@ -101,10 +99,9 @@ And finally, with a `for` loop, put the data in the table:
10199
{% if movies_data %}
102100
<table class="table">
103101
<colgroup>
104-
<col style="width: 55%">
105-
<col style="width: 20%">
102+
<col style="width: 60%">
103+
<col style="width: 25%">
106104
<col style="width: 15%">
107-
<col style="width: 10%">
108105
</colgroup>
109106
<thead>
110107
<tr class="table__header">
@@ -141,10 +138,9 @@ Let's add some text in there to tell users to add a new movie when that happens:
141138
{% if movies_data %}
142139
<table class="table">
143140
<colgroup>
144-
<col style="width: 55%">
145-
<col style="width: 20%">
141+
<col style="width: 60%">
142+
<col style="width: 25%">
146143
<col style="width: 15%">
147-
<col style="width: 10%">
148144
</colgroup>
149145
<thead>
150146
<tr class="table__header">
@@ -181,10 +177,9 @@ Finally, we also need a way to add new movies even if there is already a movie i
181177
{% if movies_data %}
182178
<table class="table">
183179
<colgroup>
184-
<col style="width: 55%">
185-
<col style="width: 20%">
180+
<col style="width: 60%">
181+
<col style="width: 25%">
186182
<col style="width: 15%">
187-
<col style="width: 10%">
188183
</colgroup>
189184
<thead>
190185
<tr class="table__header">

curriculum/section14/lectures/09_display_table_of_all_movies/end/movie_library/templates/index.html

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@
88
{% if movies_data %}
99
<table class="table">
1010
<colgroup>
11-
<col style="width: 55%">
12-
<col style="width: 20%">
11+
<col style="width: 60%">
12+
<col style="width: 25%">
1313
<col style="width: 15%">
14-
<col style="width: 10%">
1514
</colgroup>
1615
<thead>
1716
<tr class="table__header">

curriculum/section14/lectures/10_create_page_movie_details/end/movie_library/templates/index.html

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,9 @@
99
{%- if movies_data %}
1010
<table class="table">
1111
<colgroup>
12-
<col style="width: 55%">
13-
<col style="width: 20%">
12+
<col style="width: 60%">
13+
<col style="width: 25%">
1414
<col style="width: 15%">
15-
<col style="width: 10%">
1615
</colgroup>
1716
<thead>
1817
<tr class="table__header">

curriculum/section14/lectures/10_create_page_movie_details/start/movie_library/templates/index.html

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,9 @@
99
{%- if movies_data %}
1010
<table class="table">
1111
<colgroup>
12-
<col style="width: 55%">
13-
<col style="width: 20%">
12+
<col style="width: 60%">
13+
<col style="width: 25%">
1414
<col style="width: 15%">
15-
<col style="width: 10%">
1615
</colgroup>
1716
<thead>
1817
<tr class="table__header">

curriculum/section14/lectures/11_setting_movie_rating/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ Now we've got this, but the icons are not filled even if the rating of the movie
7979

8080
To change the styling of some icons but not others we'll need to give them an additional CSS class, which I'll call `.star--filled`.
8181

82-
### Jinja `loop` variables
82+
### CSS classes in the loop
8383

8484
Since the Jinja loop goes from 0 to 4, what we need to do is:
8585

@@ -148,7 +148,7 @@ So what we can do is, in each link, include a `rating` query string parameter eq
148148
Here's how to do that:
149149

150150
```jinja2
151-
% for i in range(5) %}
151+
{% for i in range(5) %}
152152
<a class="rating__link" href="{{ url_for('pages.rate_movie', _id=movie._id, rating=i+1) }}">
153153
{{ star("star " + ("star--filled" if movie.rating > i else "")) }}
154154
</a>

curriculum/section14/lectures/11_setting_movie_rating/end/movie_library/templates/index.html

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,9 @@
99
{%- if movies_data %}
1010
<table class="table">
1111
<colgroup>
12-
<col style="width: 55%">
13-
<col style="width: 20%">
12+
<col style="width: 60%">
13+
<col style="width: 25%">
1414
<col style="width: 15%">
15-
<col style="width: 10%">
1615
</colgroup>
1716
<thead>
1817
<tr class="table__header">

curriculum/section14/lectures/11_setting_movie_rating/start/movie_library/templates/index.html

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,9 @@
99
{%- if movies_data %}
1010
<table class="table">
1111
<colgroup>
12-
<col style="width: 55%">
13-
<col style="width: 20%">
12+
<col style="width: 60%">
13+
<col style="width: 25%">
1414
<col style="width: 15%">
15-
<col style="width: 10%">
1615
</colgroup>
1716
<thead>
1817
<tr class="table__header">

curriculum/section14/lectures/12_setting_movie_watched_date/end/movie_library/templates/index.html

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,9 @@
99
{%- if movies_data %}
1010
<table class="table">
1111
<colgroup>
12-
<col style="width: 55%">
13-
<col style="width: 20%">
12+
<col style="width: 60%">
13+
<col style="width: 25%">
1414
<col style="width: 15%">
15-
<col style="width: 10%">
1615
</colgroup>
1716
<thead>
1817
<tr class="table__header">

0 commit comments

Comments
 (0)