Skip to content

Commit 7a8f190

Browse files
committed
docs: formatting changes
1 parent 768359d commit 7a8f190

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

tasks.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ In the body of each function return a call to `render_template()` passing the ap
8484

8585
## 2.1 - Create Layout Template
8686

87-
@pytest.mark.layout-template We want each template to have a consistent look and feel. We can create a base layout that each template can extend. First create a new file called `layout.html` in the root of the `templates` folder. Copy the basic structure of the file from the file called `templates.html`.
87+
@pytest.mark.layout-template We want each template to have a consistent look and feel. We can create a base layout that each template can extend. First, create a new file called `layout.html` in the root of the `templates` folder. Copy the basic structure of the file from the file called `templates.html`.
8888

8989
## 2.2 - Add Styles
9090

@@ -98,16 +98,16 @@ In the body of each function return a call to `render_template()` passing the ap
9898
- `employer.html`
9999
- `review.html`
100100

101-
Next create a new folder called `admin` in the `templates` folder, then create the following files:
101+
Next, create a new folder called `admin` in the `templates` folder, then create the following files:
102102
- `index.html`
103103
- `create.html`
104104

105105
## 2.4 - Template Files HTML
106-
@pytest.mark.template-files-html Locate the `templates.html` file in the the root of the project. To prevent having to write all HTML from scratch the HTML structure of several of the template files is given here. Each block has a comment that describes what HTML file, the HTML block, needs to be copied too. Copy each block to the correct file.
106+
@pytest.mark.template-files-html Locate the `templates.html` file in the root of the project. To prevent having to write all HTML from scratch the HTML structure of several of the template files is given here. Each block has a comment that describes what HTML file, the HTML block, needs to be copied too. Copy each block to the correct file.
107107

108108
## 2.5 - Extend Base Layout
109109

110-
@pytest.mark.extend-base-layout Each of the files list below needs to extend the base layout. This can be done by adding an `extends` directive with `{% %}` template syntax to the top of each file.
110+
@pytest.mark.extend-base-layout Each of the files listed below needs to extend the base layout. This can be done by adding an `extends` directive with `{% %}` template syntax to the top of each file.
111111

112112
- `job.html`
113113
- `employer.html`
@@ -127,15 +127,15 @@ Next create a new folder called `admin` in the `templates` folder, then create t
127127

128128
## 3.2 - Import Global Namespace
129129

130-
@pytest.mark.app-import-global-namespace To provide access to the database through out the application we are going to create a function that stores a reference to the database connection in the application_context. Before we can do that in the `from flask` statement add `g` to the import.
130+
@pytest.mark.app-import-global-namespace To provide access to the database throughout the application we are going to create a function that stores a reference to the database connection in the application_context. Before we can do that in the `from flask` statement add `g` to the import.
131131

132132
## 3.3 - Global Database Access
133133

134134
@pytest.mark.app-global-database-access At the top of `app.py` create a function called `get_db`. In the body of the function use the `getattr` function to get the `_database` attribute from the `g` object. If `_database` doesn't exist set the default to `None`. Assign the return value of the `getattr` function to`db`. Next test if `db` is `None` if it is set `db` to `g._database` and `sqlite3.connect(DATABASE)`. To make accessing data easier set the row_factory of `db` to sqlite3.row. This will set all rows to named tuples. Return the `db` variable.
135135

136136
## 3.4 - Querying the Database
137137

138-
@pytest.mark.app-querying-the-database Lets create a function below the `get_db` function to make it easier to query the database. Call the function `query_db`, have the function accept three parameters: `query`, `args`, and `one`. Set the default of `args` to an empty tuple `()`. Set the default of `one` to `False`. Call the newly created `get_db` function and assign the return value to a `db` variable. Call the `execute` function, passing in the `query` and `args` variables, on the `db` and assign the return value to a variable called `cursor`. `fetchall()` data from the `cursor` and assign it to a variable called `results`. Close the `cursor` with the `close` function. Next test if there are `results` else return `None`. If there are results test if `one` is `True` and return `results[0]` else return `results`.
138+
@pytest.mark.app-querying-the-database Let's create a function below the `get_db` function to make it easier to query the database. Call the function `query_db`, have the function accept three parameters: `query`, `args`, and `one`. Set the default of `args` to an empty tuple `()`. Set the default of `one` to `False`. Call the newly created `get_db` function and assign the return value to a `db` variable. Call the `execute` function, passing in the `query` and `args` variables, on the `db` and assign the return value to a variable called `cursor`. `fetchall()` data from the `cursor` and assign it to a variable called `results`. Close the `cursor` with the `close` function. Next test if there are `results` else return `None`. If there are results test if `one` is `True` and return `results[0]` else return `results`.
139139

140140
## 3.5 - Close the Connection
141141

@@ -149,7 +149,7 @@ Next create a new folder called `admin` in the `templates` folder, then create t
149149

150150
## 4.2 - Individual Job Details
151151

152-
@pytest.mark.app-individual-job-details To bring back just one job from the database we are going to use a where clause. In the where clause we will need a `job_id`. We are going to get this from the URL. In `app.py` locate the `job` function. In the route decorator for the function after the url path `/job` add `/<job_id>`. To use this `job_id` we also need to pass it to the job function add `job_id` to the parameter list of the `job` function. Above the `render_template` function, call the `query_db` function and assign the results of the call to a `job` variable. Pass the function three arguments:
152+
@pytest.mark.app-individual-job-details To bring back just one job from the database we are going to use a where clause. In the where clause we will need a `job_id`. We are going to get this from the URL. In `app.py` locate the `job` function. In the route decorator for the function after the URL path `/job` add `/<job_id>`. To use this `job_id` we also need to pass it to the job function add `job_id` to the parameter list of the `job` function. Above the `render_template` function, call the `query_db` function and assign the results of the call to a `job` variable. Pass the function three arguments:
153153
- 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 = ?'`
154154
- List Literal: [job_id]
155155
- True: This will bring back only one result.
@@ -158,7 +158,7 @@ In the `render_template` function, pass a keyword argument of `job=job`
158158

159159
## 4.3 - Individual Employer Details
160160

161-
@pytest.mark.app-individual-employer-details Similar to the `job` function the employer route will only need the details of one employer. Locate the `employer` function in `app.py`. Again we need the unique id of an employer and will receive this from the URL. Add `/<employer_id>` in the route decorator after `/employer`. So that the `employer` function has access to this value add `employer_id`to the parameter list. Make a call to `query_db` and assign tne return value to `employer`. Pass in the arguments:
161+
@pytest.mark.app-individual-employer-details Similar to the `job` function the employer route will only need the details of one employer. Locate the `employer` function in `app.py`. Again we need the unique id of an employer and will receive this from the URL. Add `/<employer_id>` in the route decorator after `/employer`. So that the `employer` function has access to this value add `employer_id`to the parameter list. Make a call to `query_db` and assign the return value to `employer`. Pass in the arguments:
162162
- SQL Query: 'SELECT * FROM employer WHERE id=?'
163163
- List Literal: [employer_id]
164164
- True: This will bring back only one result.
@@ -167,7 +167,7 @@ In the `render_template` function, pass a keyword argument of `employer=employer
167167

168168
## 4.4 - All Employer Jobs
169169

170-
@pytest.mark.app-all-employer-jobs On the employer details page we want to display all of the employers jobs. In the `employer` function in `app.py` below the `employer` variable, add a call to the `query_db` function and assign the results to a variable called `jobs`. Pass the function two arguments:
170+
@pytest.mark.app-all-employer-jobs On the employer details page, we want to display all of the employers' jobs. In the `employer` function in `app.py` below the `employer` variable, add a call to the `query_db` function and assign the results to a variable called `jobs`. Pass the function two arguments:
171171
- SQL Query: `'SELECT job.id, job.title, job.description, job.salary FROM job JOIN employer ON employer.id = job.employer_id WHERE employer.id = ?'`
172172
- List Literal: [employer_id]
173173

@@ -182,7 +182,7 @@ In the `render_template` function, add another keyword argument of `jobs=jobs`
182182

183183
## 4.6 -Display All Jobs
184184

185-
@pytest.mark.display-all-jobs Open the file `templates/index.html` above the `{% endblock %}` add a `<div>` with two classes `columns` and `is-multiline`. In the div add a `for in` loop that loops through all jobs. Use the `{% %}` template syntax, don't forget about ending the `for` loop.. In the `for` loop add a `<div>` with two classes `column` and `is-half`. Too this `<div>` add the following template code:
185+
@pytest.mark.display-all-jobs Open the file `templates/index.html` above the `{% endblock %}` add a `<div>` with two classes `columns` and `is-multiline`. In the div add a `for in` loop that loops through all jobs. Use the `{% %}` template syntax, don't forget about ending the `for` loop. In the `for` loop add a `<div>` with two classes `column` and `is-half`. Too this `<div>` add the following template code:
186186

187187
```
188188
{% with job=job %}
@@ -211,7 +211,7 @@ In the `render_template` function, add another keyword argument of `jobs=jobs`
211211

212212
## 4.9 -Display All Employer Jobs
213213

214-
@pytest.mark.display-all-employer-jobs Open the file `templates/employer.html` below the jobs `<h2>` add a `<div>` with two classes `columns` and `is-multiline`. In the div add a `for in` loop that loops through all jobs. Use the `{% %}` template syntax, don't forget about ending the `for` loop.. In the `for` loop add a `<div>` with two classes `column` and `is-half`. To the `<div>` add the following template code:
214+
@pytest.mark.display-all-employer-jobs Open the file `templates/employer.html` below the jobs `<h2>` add a `<div>` with two classes `columns` and `is-multiline`. In the div add a `for in` loop that loops through all jobs. Use the `{% %}` template syntax, don't forget about ending the `for` loop. In the `for` loop add a `<div>` with two classes `column` and `is-half`. To the `<div>` add the following template code:
215215

216216
```
217217
{% with job=job %}
@@ -237,7 +237,7 @@ In the body of the function return the render_template function passing in `revi
237237
238238
@pytest.mark.app-review-check-for-error Still in the review function below the value checks add an `if` statement that checks if `error` is `None`. If there are no errors we are going to add the form values to the database. To do this we need to connect to the database and commit some changes. Follow these steps:
239239
- Set a `db` variable to a call to `get_db()`
240-
- `execute` the following SQL statment: `'INSERT INTO review (review, rating, title, date, status, employer_id) VALUES (?, ?, ?, ?, ?, ?)'` passing the values: `(review, rating, title, date, status, employer_id)`
240+
- `execute` the following SQL statement: `'INSERT INTO review (review, rating, title, date, status, employer_id) VALUES (?, ?, ?, ?, ?, ?)'` passing the values: `(review, rating, title, date, status, employer_id)`
241241
- `commit` the changes to the database.
242242
- return a redirect taking the user back to the employer page. **Hint: use `redirect()` and `url_for()` (pass keyword argument of `employer_id=employer_id`) both of which need to be imported from flask.**
243243
@@ -249,7 +249,7 @@ If there are errors (`else` statement) `flash` the error. **Hint: `else` stateme
249249
250250
## 5.6 - Individual Employer Reviews
251251
252-
@pytest.mark.app-individual-employer-reviews Now that employer reviews can be created, lets display them on the individual employer pages. Switch back to `app.py` and find the `employer` function below the jobs query add an new query to get all review for the employer. Make a call to `query_db` and assign tne return value to `reviews`. Pass in the arguments:
252+
@pytest.mark.app-individual-employer-reviews Now that employer reviews can be created, let's display them on the individual employer pages. Switch back to `app.py` and find the `employer` function below the jobs query add a new query to get all review for the employer. Make a call to `query_db` and assign the return value to `reviews`. Pass in the arguments:
253253
- SQL Query: 'SELECT review, rating, title, date, status FROM review JOIN employer ON employer.id = review.employer_id WHERE employer.id = ?'
254254
- List Literal: [employer_id]
255255
@@ -269,7 +269,7 @@ In the `content <div>` add a paragraph tag. In the paragraph display the details
269269
- `date`
270270
- `review`
271271
272-
For the `Create Review` button to work add an `href` that points to the individual employer page.
272+
For the `Create Review` button to work, add an `href` that points to the individual employer page.
273273
274274
# Module 06 - Add Jobs
275275

0 commit comments

Comments
 (0)