1
00:00:01,530 --> 00:00:05,550
So we have the all reservations page working pretty much the way we want it to.

2
00:00:05,610 --> 00:00:08,130
Now we want to do the new reservations page.

3
00:00:08,640 --> 00:00:14,730
And as I suggested earlier, one of the things we have to do is we need to have some means of determining

4
00:00:14,970 --> 00:00:18,560
whether a reservation is new or one we already know about.

5
00:00:18,870 --> 00:00:22,430
And that means we need to add a column to the database and we already know how to do that.

6
00:00:22,440 --> 00:00:23,270
So let's go do it.

7
00:00:23,640 --> 00:00:32,310
I'll go over to my I.D. and I will open my terminal window and clear it and I'll make sure I'm in the

8
00:00:32,310 --> 00:00:33,110
correct directory.

9
00:00:33,270 --> 00:00:33,990
I am.

10
00:00:34,110 --> 00:00:35,940
So let's create a new migration.

11
00:00:36,120 --> 00:00:46,440
So to generate fees add processed, which is what I'll call the column two reservations table, and

12
00:00:46,440 --> 00:00:48,000
that creates two new migrations.

13
00:00:48,010 --> 00:00:54,090
So let's open those up there in our migrations folder, which is right here, and they'll be at the

14
00:00:54,090 --> 00:00:54,500
bottom.

15
00:00:55,470 --> 00:00:57,330
So let's do the down migration first.

16
00:00:58,470 --> 00:01:01,320
And this will, of course, run when we want to reverse migration.

17
00:01:01,320 --> 00:01:07,740
And that's just as simple as drop column and the name of the table reservations and the name of the

18
00:01:07,740 --> 00:01:09,510
column, which I'm going to call processed.

19
00:01:10,800 --> 00:01:11,520
So that's done.

20
00:01:12,450 --> 00:01:14,550
Now, let's open the up migration.

21
00:01:16,620 --> 00:01:18,030
And this is add column.

22
00:01:20,620 --> 00:01:26,350
And again, the table reservations, the column name which will be processed.

23
00:01:28,330 --> 00:01:30,280
The column type will be integer

24
00:01:32,980 --> 00:01:38,130
and then in curly brackets, I'll give it a default of zero.

25
00:01:41,810 --> 00:01:46,490
So now when someone enters a reservation, we don't need to do anything, we don't need to change any

26
00:01:46,490 --> 00:01:53,030
code because it has a default value of zero, and any reservation that has a value of zero in the process

27
00:01:53,030 --> 00:01:55,610
column will by default be a new reservation.

28
00:01:55,850 --> 00:02:00,200
And we should be able to run this migration so to migrate.

29
00:02:01,170 --> 00:02:08,130
And there it is, so we have it all at it now that that's added, we need to actually make the necessary

30
00:02:08,130 --> 00:02:08,940
database queries.

31
00:02:08,940 --> 00:02:10,620
So let's go back to our postgrads.

32
00:02:10,740 --> 00:02:12,510
And as you might guess, this is pretty simple.

33
00:02:12,520 --> 00:02:16,380
I'm just going to copy this existing one for all migration's.

34
00:02:18,490 --> 00:02:23,980
Paste it below it, change its name to all reserve to new reservations.

35
00:02:24,210 --> 00:02:27,510
I think I called it all migration's a moment ago, but you knew what I meant.

36
00:02:28,160 --> 00:02:34,260
So this will be new reservations and I'll call it all new reservations just to make it really clear

37
00:02:34,290 --> 00:02:35,400
what this function does.

38
00:02:36,690 --> 00:02:41,670
And of course, I just need to add a weird clause where processed.

39
00:02:44,100 --> 00:02:50,200
Equals zero, and let's actually change this one as well.

40
00:02:51,150 --> 00:03:00,150
We will add up here just after our updated at will, put our protest and down here, that's after updated

41
00:03:00,150 --> 00:03:02,150
at which is right here.

42
00:03:02,160 --> 00:03:07,920
We'll duplicate this and add processed, which doesn't exist yet, but we'll add it to the model in

43
00:03:07,920 --> 00:03:08,210
a minute.

44
00:03:09,960 --> 00:03:11,130
So let's open our models.

45
00:03:13,180 --> 00:03:14,620
And find reservation.

46
00:03:16,650 --> 00:03:21,310
Which is right here and let's add processed, which will be of type int.

47
00:03:22,100 --> 00:03:28,890
OK, so hopefully that fixed our problem in our postgrads and it did good.

48
00:03:29,520 --> 00:03:37,740
The last thing we need to do here is to copy this entire function, which is right here, all new reservations,

49
00:03:38,880 --> 00:03:45,780
and add that to our test repo, which is under internal repository.

50
00:03:47,980 --> 00:03:58,090
Test repo pay and get rid of all the things we don't want, which is all of this stuff, plus the context,

51
00:03:59,500 --> 00:04:05,790
change its receiver to the correct type and then add this to our repository.

52
00:04:06,910 --> 00:04:13,090
So open the repository, paste it in and do I guess I didn't copy the right thing.

53
00:04:17,320 --> 00:04:20,190
Copy paste there.

54
00:04:21,430 --> 00:04:22,750
So that should compile.

55
00:04:22,780 --> 00:04:25,690
But first, let's add that to our handlers.

56
00:04:25,690 --> 00:04:31,090
Let's take advantage of the one we just created and added to our handlers.

57
00:04:32,950 --> 00:04:36,980
So handlers and we're looking for all new admin, new reservations.

58
00:04:37,010 --> 00:04:37,520
There it is.

59
00:04:37,960 --> 00:04:43,570
So what I can do here is copy all of this and modify it just to save some time.

60
00:04:45,730 --> 00:04:48,520
OK, and I missed Mr. Line.

61
00:04:53,160 --> 00:04:58,860
Paste, I copy and paste skills leave a little to be desired today, I apologize for that.

62
00:04:59,340 --> 00:05:06,990
And we're going to add that to data data and changes to all new reservations.

63
00:05:10,990 --> 00:05:19,960
All right, let's give these things some comments, shows all new reservations in admin tool.

64
00:05:22,710 --> 00:05:24,120
And this one needs a comment.

65
00:05:28,100 --> 00:05:31,760
Shows all reservations in admin tool.

66
00:05:32,920 --> 00:05:36,530
I think I have comments for everything else, looks like I know I must show log.

67
00:05:38,060 --> 00:05:41,270
I just like to keep these things properly formatted.

68
00:05:41,390 --> 00:05:43,440
Shows the login screen.

69
00:05:43,640 --> 00:05:44,150
All right.

70
00:05:44,750 --> 00:05:46,430
So let's run our application.

71
00:05:50,850 --> 00:05:56,310
It compiles perfect, this should still show the same thing because we haven't changed our template,

72
00:05:56,310 --> 00:05:57,220
but it works good.

73
00:05:57,240 --> 00:06:06,690
Let's go back and fix our template and what we can do is copy and paste and then make modifications

74
00:06:06,690 --> 00:06:07,720
as necessary.

75
00:06:08,490 --> 00:06:16,240
So under our templates, first of all, let's go to our all reservations page and copy this script part

76
00:06:16,260 --> 00:06:21,960
for the bottom and then open our new reservations page and paste that in.

77
00:06:22,680 --> 00:06:31,230
And we'll call the table new regs and go back to our old reservations page and copy everything in here.

78
00:06:33,850 --> 00:06:37,600
And back to our new reservations page and paste it in here.

79
00:06:39,040 --> 00:06:47,170
No time to get rid of those carbon tags, I guess, there and we have ID last name.

80
00:06:47,380 --> 00:06:48,550
Everything is the same.

81
00:06:48,850 --> 00:06:52,550
We'll change this to new in the link so we know where we're coming from.

82
00:06:53,230 --> 00:06:59,290
So in the other one, we had admin reservations, all ID, now we'll have admin reservations, new ID,

83
00:06:59,290 --> 00:07:00,760
just so we know where we're coming from.

84
00:07:00,760 --> 00:07:07,320
And that will become apparent why I'm doing that in a lecture or to everything else.

85
00:07:07,840 --> 00:07:11,680
You know, I guess I missed the here the CSFs.

86
00:07:11,680 --> 00:07:14,980
We need that and we'll put that here.

87
00:07:16,300 --> 00:07:20,320
And I should now at this point be able to reload that page and see a table.

88
00:07:20,330 --> 00:07:21,130
Let's find out.

89
00:07:23,070 --> 00:07:24,480
OK, not quite right.

90
00:07:25,140 --> 00:07:25,890
What did I miss?

91
00:07:25,920 --> 00:07:28,710
Oh, yes, I need to change the ID to New Redd's.

92
00:07:30,450 --> 00:07:36,060
That looks better, perfect, so now we have our new reservations display and they're all new because

93
00:07:36,060 --> 00:07:38,760
I've never processed any of them and I just added that column.

94
00:07:38,770 --> 00:07:41,400
So by default, they all have zero for processed.

95
00:07:42,210 --> 00:07:47,850
And if we change something in the database, which we'll do when we get to actually modifying reservations,

96
00:07:47,850 --> 00:07:50,720
which is the next lecture or two, then we should be good to go.

97
00:07:51,240 --> 00:07:52,560
So we have new reservations.

98
00:07:53,040 --> 00:07:57,990
We have all reservations which currently show the same information because all reservations are new

99
00:07:57,990 --> 00:07:58,650
reservations.

100
00:07:58,980 --> 00:08:00,700
But I think we're pretty much ready to go.

101
00:08:01,020 --> 00:08:07,080
So in the next lecture, we'll start working on clicking on a link to a reservation and displaying it

102
00:08:07,260 --> 00:08:08,940
and then processing it as required.

103
00:08:09,090 --> 00:08:11,370
And we'll take care of that in the next lecture or two.
