1
1

00:00:01,010  -->  00:00:02,410
<v Instructor>Hi and welcome back.</v>
2

2

00:00:02,410  -->  00:00:06,930
In this video we're going to be giving our alerts names.
3

3

00:00:06,930  -->  00:00:10,360
Here's why, when a user creates an alert,
4

4

00:00:10,360  -->  00:00:14,773
they give us the item URL and a price limit.
5

5

00:00:15,900  -->  00:00:20,490
Then we store item ID and price limit in the alert itself.
6

6

00:00:20,490  -->  00:00:22,230
What happens when the user comes back and
7

7

00:00:22,230  -->  00:00:24,130
they want to look at all their alerts.
8

8

00:00:25,000  -->  00:00:30,000
We can show them the item ID, we can show them the item URL,
9

9

00:00:30,000  -->  00:00:33,273
we can show them the price limit and that's about it.
10

10

00:00:34,260  -->  00:00:36,630
There is no way for the user to give the alert
11

11

00:00:36,630  -->  00:00:39,170
something that's meaningful to them,
12

12

00:00:39,170  -->  00:00:40,310
something that they can look back
13

13

00:00:40,310  -->  00:00:42,390
and say, oh yeah, this was an alert time set up
14

14

00:00:42,390  -->  00:00:44,663
for this ipad that I'm interested in.
15

15

00:00:46,330  -->  00:00:47,660
So we're gonna change that,
16

16

00:00:47,660  -->  00:00:50,710
we're gonna allow users to give their alerts names,
17

17

00:00:50,710  -->  00:00:54,000
so that they can come back and more easily see them.
18

18

00:00:54,000  -->  00:00:55,920
It's gonna be really easy especially now
19

19

00:00:55,920  -->  00:00:57,530
that we're using Dataclasses.
20

20

00:00:57,530  -->  00:00:59,860
The first thing is to tell the Dataclass to accept
21

21

00:00:59,860  -->  00:01:02,810
a new property, name is string.
22

22

00:01:02,810  -->  00:01:05,493
And I'm gonna put that in front of item ID.
23

23

00:01:07,250  -->  00:01:08,580
Okay, that's the first change
24

24

00:01:08,580  -->  00:01:10,510
and that's all the changes we have to make
25

25

00:01:10,510  -->  00:01:13,670
in order to modify the init method, wrapper methods
26

26

00:01:13,670  -->  00:01:15,203
and all the other stuff.
27

27

00:01:16,520  -->  00:01:19,780
We're gonna go over to the alert index,
28

28

00:01:19,780  -->  00:01:24,140
and now instead of showing just the alert text in header,
29

29

00:01:24,140  -->  00:01:27,080
we're gonna show alert name.
30

30

00:01:27,080  -->  00:01:28,670
Make sure that that's around,
31

31

00:01:28,670  -->  00:01:30,860
has these curly braces around it.
32

32

00:01:30,860  -->  00:01:33,450
And now, every alert is going to have the name
33

33

00:01:33,450  -->  00:01:37,343
that was given to it here on top of the item URL.
34

34

00:01:38,780  -->  00:01:41,840
When we create a new alert we'll also need to ask
35

35

00:01:41,840  -->  00:01:44,030
the user for the name.
36

36

00:01:44,030  -->  00:01:46,740
So we're gonna do that in front of item URL.
37

37

00:01:46,740  -->  00:01:49,763
We're gonna say div class form group.
38

38

00:01:53,090  -->  00:01:54,670
And in here we're gonna put a label
39

39

00:01:54,670  -->  00:01:56,803
and an input for the name.
40

40

00:02:05,090  -->  00:02:07,230
Something like that, just a simple input text
41

41

00:02:07,230  -->  00:02:08,610
with the class form control
42

42

00:02:08,610  -->  00:02:10,480
because bootstrap is gonna use that.
43

43

00:02:10,480  -->  00:02:13,900
The ID and the name are going to both be named,
44

44

00:02:13,900  -->  00:02:16,380
and there's gonna be a placeholder there so that user knows
45

45

00:02:16,380  -->  00:02:18,810
that they can type something meaningful to them,
46

46

00:02:18,810  -->  00:02:21,263
and not to us.
47

47

00:02:22,130  -->  00:02:24,890
Finally in the alert view we also have
48

48

00:02:24,890  -->  00:02:27,690
to take in the alert name.
49

49

00:02:27,690  -->  00:02:32,690
So we're gonna say that alert name is request.form name.
50

50

00:02:32,880  -->  00:02:35,080
And then we're gonna pass it into the alert.
51

51

00:02:38,700  -->  00:02:40,440
That's it, that's everything we need to do
52

52

00:02:40,440  -->  00:02:43,543
in order to add alert names into an application.
53

53

00:02:44,870  -->  00:02:47,490
They are now being used in the index.
54

54

00:02:47,490  -->  00:02:49,720
We're taking them in the form,
55

55

00:02:49,720  -->  00:02:52,120
we're using them when we create a new alert,
56

56

00:02:52,120  -->  00:02:54,343
and they are saved in here.
57

57

00:02:55,180  -->  00:02:57,410
Of course actually something else that we need to do
58

58

00:02:57,410  -->  00:02:59,493
is we just save it in here.
59

59

00:03:00,530  -->  00:03:02,060
Forgot, I got a bit excited there.
60

60

00:03:02,060  -->  00:03:03,960
And but we do need to save it into the Json method,
61

61

00:03:03,960  -->  00:03:07,550
so that it actually goes and get saved into the database
62

62

00:03:07,550  -->  00:03:09,723
and then it comes back to us as well.
63

63

00:03:11,270  -->  00:03:14,760
The order of these Json fields by the way doesn't matter
64

64

00:03:14,760  -->  00:03:16,823
because they get passed in as,
65

65

00:03:18,970  -->  00:03:21,600
they get passed as named arguments.
66

66

00:03:21,600  -->  00:03:23,630
So the order of those doesn't matter,
67

67

00:03:23,630  -->  00:03:26,310
it doesn't keep the order anyway.
68

68

00:03:26,310  -->  00:03:28,440
So yeah, you can put it whatever you want
69

69

00:03:28,440  -->  00:03:31,400
but I like to keep things more or less in sync
70

70

00:03:31,400  -->  00:03:33,140
and so I'm gonna put it up there.
71

71

00:03:33,140  -->  00:03:35,040
I'm actually also gonna move this one.
72

72

00:03:38,120  -->  00:03:41,970
Like that, just so it's at the same order as these fields.
73

73

00:03:41,970  -->  00:03:44,330
I do like keeping the ID up in front.
74

74

00:03:44,330  -->  00:03:45,570
That's just personal preference
75

75

00:03:45,570  -->  00:03:47,130
because it's not on the school.
76

76

00:03:47,130  -->  00:03:50,460
And so it's up to you where you want to put it of course.
77

77

00:03:50,460  -->  00:03:51,620
That's everything for this video though
78

78

00:03:51,620  -->  00:03:53,860
we have added names to our alerts
79

79

00:03:53,860  -->  00:03:56,980
and you're starting to see how easy it can be to add more
80

80

00:03:56,980  -->  00:03:58,570
things into our app.
81

81

00:03:58,570  -->  00:04:00,370
As long as we take in the data,
82

82

00:04:00,370  -->  00:04:04,040
we use the data and then we show it back to our users,
83

83

00:04:04,040  -->  00:04:06,030
that's really all the changes we have to make
84

84

00:04:06,030  -->  00:04:08,640
in order to add something new.
85

85

00:04:08,640  -->  00:04:10,090
Thanks for joining me in this video,
86

86

00:04:10,090  -->  00:04:11,540
I'll see you in the next one.
