Skip to content

Commit a87083c

Browse files
committed
docs: formatting fixes
1 parent 2187303 commit a87083c

File tree

1 file changed

+22
-6
lines changed

1 file changed

+22
-6
lines changed

tasks.md

+22-6
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ You can preview your work by running `flask run` in the root of your fork. Then
6262

6363
## 1.4 - Create Index Template
6464

65-
@pytest.mark.index-template In the root of the `templates` folder, create a file called `index.html`. Add a single line to the file:
65+
@pytest.mark.index-template In the root of the `templates` folder, create a file called `index.html`. Add a single line to the file:
66+
6667
- `<h1>Jobs</h1>`
6768

6869
## 1.5 - Index Route Function
@@ -77,6 +78,7 @@ For now let’s setup a basic route that displays our simplified `index.html` te
7778
## 1.6 - Route Decorators
7879

7980
@pytest.mark.app-route-decoractors Still in `app.py`:
81+
8082
- Attach a `route()` decorator with the URL of `/` to the `jobs` function.
8183
- Attach an additional route decorator of `/jobs`. **Note: The `jobs` function can now be reached at `/` and `/jobs`**
8284

@@ -108,7 +110,7 @@ For the `href` use the mustache template markup `{{}}` and the flask `url_for()`
108110

109111
## 2.3 - Add Custom CSS
110112

111-
@pytest.mark.add-custom-css For the second `<link>` tag in `layout.html` construct an `href` for the file `css/app.css`, also in the `static` folder, using the same method. Don't forget `rel` attribute.
113+
@pytest.mark.add-custom-css For the second `<link>` tag in `layout.html` construct an `href` for the file `css/app.css`, also in the `static` folder, using the same method. Don't forget the `rel` attribute.
112114

113115
## 2.4 - Add FontAwesome
114116

@@ -117,6 +119,7 @@ For the `href` use the mustache template markup `{{}}` and the flask `url_for()`
117119
## 2.5 - Extend Base Template
118120

119121
@pytest.mark.extend-base-template To use `layout.html` as the base template:
122+
120123
- Open `index.html`, above the `<h1>` use the template markup `{% %}` and the extends tag to inherit `layout.html`.
121124
- Wrap the `<h1>` element in a `block` called `content`.
122125

@@ -155,6 +158,7 @@ In the body of the `get_db` function use the built-in `getattr()` function to ge
155158
## 3.6 - sqlite3 Row Factory
156159

157160
@pytest.mark.app-sqlite3-row-factory To make accessing data easier, after the if statement in `get_db`:
161+
158162
- Set the row_factory of `db` to `sqlite3.Row`. **Note: All rows returned from the database will be named tuples.**
159163
- Return the `db` variable.
160164

@@ -169,6 +173,7 @@ In the body of `query_db` create a variable called `db`. Assign this variable th
169173
## 3.8 - Query Database Function Parameters
170174

171175
@pytest.mark.app-query-database-function-parameters Still working with the `query_db` function:
176+
172177
- Add three parameters: `query`, `args`, and `one`.
173178
- Set the default of `args` to an empty tuple `()`.
174179
- Set the default of `one` to `False`.
@@ -178,21 +183,25 @@ In the body of `query_db` create a variable called `db`. Assign this variable th
178183

179184
## 3.10 - Query Database Function Fetchall
180185
@pytest.mark.app-query-database-function-fetchall In the body of `query_db`:
186+
181187
- `fetchall` data from the `cursor` and assign it to a variable called `results`.
182188
- Close the `cursor` with the `close` function.
183189

184190
## 3.11 - Query Database Function Single
185191
@pytest.mark.app-query-database-function-single Next, in the function body of `query_db` add a test if `one` is `True`:
192+
186193
- if true return a ternary if, `results[0] if results else None`.
187194
- else return all `results`.
188195

189196
## 3.12 - Close the Connection
190197

191198
@pytest.mark.app-close-the-connection In order to make sure the database connection is closed when the `app_context` is torn down:
199+
192200
- Create a function in `app.py` called `close_connection`.
193201
- Add a parameter called `exception` to the parameter list.
194202

195203
In the function body:
204+
196205
- Call `getattr` with three arguments `g`, `'_database'`, and `None`
197206
- Assign the return value to a `db` variable.
198207
- If `db` is not `None` `close` the `db`.
@@ -225,8 +234,9 @@ In the function body:
225234
## 4.5 - Show Job Macro Body
226235

227236
@pytest.mark.show-job-macro-body Next find the `<div>` with a class of `content` in the `show_job` macro and add a `<p>` tag.
228-
In `<p>` tag add the following:
229-
- `<a>` tag with an `href` of `{{ url_for('employer', employer_id=job['employer_id']) }}`.The content should be `{{ job['employer_name'] }}`.
237+
In `<p>` tag add the following:
238+
239+
- `<a>` tag with an `href` of `{{ url_for('employer', employer_id=job['employer_id']) }}`. The content should be `{{ job['employer_name'] }}`.
230240
- Line break
231241
- ${{ job['salary'] }}
232242
- Line break
@@ -239,20 +249,24 @@ In `<p>` tag add the following:
239249
## 4.7 - Show Jobs Macro For Loop
240250

241251
@pytest.mark.show-jobs-macro-for-loop Still in `_macros.html` and in the body of the `show_jobs` macro add the following HTML:
252+
242253
- Add a `<div>` with two classes `columns` and `is-multiline`.
243254
- In this `<div>` add a `for in` loop that loops through all jobs. **Note: Use the `{% %}` template syntax, don’t forget about ending the `for` loop.**
244255

245256
## 4.8 - Show Jobs Macro For Loop Body
246257

247-
@pytest.mark.show-jobs-macro-for-loop-body In the body of the `for` loop add a `<div>` with two classes `column` and `is-half`.
258+
@pytest.mark.show-jobs-macro-for-loop-body In the body of the `for` loop add a `<div>` with two classes `column` and `is-half`.
259+
248260
- In this `column` `<div>` add a call to the `show_job` macro passing in an individual `job` from the `for` loop.
249261

250262
## 4.9 - Import Macros
251263

252264
@pytest.mark.import-macros In `templates/layouts.html` import the `show_job`, and `show_jobs` macros using the following code:
265+
253266
```
254267
{% from '_macros.html' import show_job, show_jobs with context %}
255268
```
269+
256270
**Notes: Because each template extends `layouts.html` all of them will have access to these two new macros.**
257271

258272
## 4.10 - Import Macros
@@ -268,6 +282,7 @@ In `<p>` tag add the following:
268282
@pytest.mark.gather-all-jobs In `app.py` locate the `jobs` function.
269283

270284
Above the `render_template` function, call the `query_db` function:
285+
271286
- Pass in the SQL statement: `'SELECT job.id, job.title, job.description, job.salary, employer.id as employer_id, employer.name as employer_name FROM job JOIN employer ON employer.id = job.employer_id'`.
272287
- Assign the results of the call to a variable called `jobs`.
273288
- In the `render_template` function, pass a keyword argument of `jobs=jobs`.
@@ -309,7 +324,8 @@ Still in `app.py`, add a route decorator with the URL path `/job/<job_id>` to th
309324
## 5.5 - Job Route Data
310325

311326
@pytest.mark.app-job-route-data In the `job` function, above the `render_template` function, call the `query_db` function and assign the results of the call to a `job` variable.
312-
Pass these three arguments to `query_db`:
327+
Pass these three arguments to `query_db`:
328+
313329
- SQL Query: `'SELECT job.id, job.title, job.description, job.salary, employer.id as employer_id, employer.name as employer_name FROM job JOIN employer ON employer.id = job.employer_id WHERE job.id = ?'`
314330
- List Literal: [job_id]
315331
- True: This will bring back only one result.

0 commit comments

Comments
 (0)