📺 Develpreneur YouTube Episode

Video + transcript

Learn Python And Django Day 45

2021-04-01 •Youtube

Detailed Notes

Part II of the creation of reports. This focuses on the dynamic display of parameters.

You can view source for today and all prior days by reviewing the tag Day 45 at this GitHub: https://github.com/robbroadhead/develpreneur-pythontutorial

Transcript Text
[Music]
welcome back
we are continuing to plow through
working on our reports
and we're going to do is we're going to
actually build a sort of like a dynamic
report page
and so we've started down this path a
little bit and now we're going to
continue it so if we go to
our uh where to go reports page
now we have our selector and
right now we're just displaying the
report id but instead
what i want to do is i want to
fill out the reports so i'm going to do
i'm going to actually call this i'm
going to send an id
and i'm going to get say display
report parameters
and what that's going to do uh so let's
see blah blah blah that needs to be
id so i'm going to do display
port parameters id
i'm going to put this on top of it just
because
so now it's going to call this and it's
going to
just open up the parameters section
there
and then return so but what we need to
do is here i'm going to get
let's see this will be rpt parms we're
going to call it that i'm going to give
it an id for report
it's going to get it's going to set this
time however
our element is actually going to be
our parameters
actually let's just pull that whole
piece out
i'm just going to do all of it here so
what it's going to do is it's going to
get that
element we're going to do the display
blocks going to be the last thing we do
and then what we want to do is
is we want to take the response
and set it to that so that was uh
element
dot because we're going to actually
build the whole
thing here
so now what we need to do is we're going
to have to actually get the response
that we get back
from our ajax call so we can actually do
something with this
uh which did we do that before
uh where was that that was it oh we
didn't before because we were just doing
a fire and forget this time
we're going to tweak it and we're going
to actually deal with our response
three two one now what we have to do
here is we have to actually
uh we're gonna have to set some stuff up
here so this is a little bit
uh different from what we've seen in the
past we're gonna do an on
uh ready state change
and so this means um basically when we
when this thing comes when some sort of
response comes back from this we're
going to be working with it
and so what we want to do is we want it
to be equal to a function
and in that function because we're going
to do some we're going to
do stuff and so if this
dot ready state
equals four and
this.status
equals 200. so basically if this thing
completes if we get a return
we're going to do something and we're
gonna do the result
that we get back is the
response text and then
uh actually we're gonna have to within
this whoops i gotta do that right
and then what we need to do is we're
going to have to actually do the update
here so it's going to be since we don't
have this within
we're actually going to have to do this
here as well
actually yes let's just move all of this
in here
so we're only going to deal with this
once we get back
a response and we're gonna have to build
this out
so it's gonna take us probably again a
couple of
uh episodes get through this because
first okay so let's see so we're gonna
come through
i'm gonna call report parms i'm gonna
give it
uh that oh no we want it to be equal to
result
and then display
uh get element by d okay so now we need
to go to
what we're calling which we called rpt
params and we're going to send it an id
so let's set that up
i called it that so let's see i've got
one here i'm just going to steal this
just to make it a little easier
and that's going to be my here
so this is going to be i'm going to call
it report parameters
and so i'm going to need a report
parameters over on this side
on my views
and i'm going to do something
let's just do this
steal this guy
parameters he's going to have an id
and the response i'm going to send back
is going to be the parms
and farms equals we're going to start
with um
we'll do it this way yeah it's not going
to be an h1 i'll be in h4
um let's see we could say
no parameters available
and then otherwise we're going to come
in we're just going to hard code this
right now we could do something a little
more complicated but we're going to keep
it
essentially hard coded in our report
parameters
and so we're just going to do if id
equals 1. we're going to do something
if id equals 2 it's going to be
something else
and if i d3 it's going to be something
else and then
in each of these because we look at our
reports
each of these it's by status by roadmap
or by timeline so each of these we're
going to actually have
you're going to select a status a
roadmap or a timeline so each of these
is going to start with
a selector
and we're going to do his name is going
to be equal
to rpt parms
parm1 so we're going to start that so
each one of these
this would be eventually we could have
multiple parameters
and then uh
here this is going to be
in the select
and then we're going to create some
options so we're going to do this for
each of these actually
and then we're going to create some
options and the options are going to be
based on something so
something is good so first we're going
to do is let's like look at
what we got we've got uh timeline
roadmap at
status so let's uh note
timeline roadmap status whoops go over
here
and then this one's going to be
timeline
roadmap
status
and so this actually becomes pretty easy
because our options is going to be
equal to timeline
dot objects.all
as we've seen a couple places down here
like here we're gonna do essentially the
same thing
except see where we did it
here see i'm just going to take that and
instead it's going to be
timeline it's going to be roadmap
and it's going to be a status
which we call lkp status okay
now what we can do with each of these we
could build it here and we're going to
we could also build it actually on the
other side
but it's a little easier just because
where we're at we're going to do this so
we're going to do for opt and ops
and then each of these is going to build
a select i'm sorry an option
so it's going to be option
and then actually what we can do is
we're gonna do this in a one-liner
and we're gonna do let's see
sorry id id equals and we're going to
send it
we're going to give it the
option.id and here
we're going to give it the option dot
all right we just do option and it's
going to probably pick up to string
for us so let's try this
so you see we could actually do stuff a
little uh let's see option id yeah so we
should be able to get that let's see how
this works out
i think let's see in there got that got
that got that
why are you complaining about timeline
time frame i'm sorry
and that was going to get us our
response we're going to send our spots
back
so first let's just test this so if we
send it
here
uh what did we call that
go to url that was rpt parms
so let's just steal that real quick
so if we do uh one
oh because it doesn't like it it's an id
versus so let's uh that's going to
actually be
string
and actually we can take that with each
of these we could actually
in this case we could simplify it but
i'm not going to because we may
eventually have different params
uh let's see so time frame
to string
so we do need that so we're going to say
um here
i think we can do op dot name for each
of them
except for well we may be able to let's
see did i get that i mean we're
sort of doing quick okay so now that's
if i do it for that one i'm going to get
this little selector
if i get this one okay so there's
unbound local
oh i managed to lose my
ops there
that one sets this one was
look up status this one was roadmap
okay
so that's all my road maps
and there we go okay so
what i want to do is i'm going to go
ahead and with each of these i'm going
to actually do
a label basically
and it's going to be um
select timeline
select road map
select status
so now that's what i'm going to get back
so now what i can do is
uh let's see well did i get that done
let's go check real quick
if i did my reports
i can't remember if i had this set up
right so if i do my roadmap oh there we
go
okay so now what i'm doing is i'm going
to give myself
the ability to select parameters based
on a report
and then i'm going to come back next
time we're going to actually generate a
report so with each of these
actually what i'm going to do is
because i'm going to need this i'm going
to have a button
i'm actually going to steal this one
because i don't even need the that guy
anymore
and within the parameters
i'm gonna do um i'm gonna do it like
this i'm gonna do a row here
well let's do it this way
i do a row here oh because i'm changing
the inner html
so what i want to do is
that div is
i'm gonna have a button and i'm gonna
have a row
here
oops i just totally did something weird
on that
but now that's oh so i'm going to have
to change around a little bit because
of that because i'm doing the inner html
of this parameters i'm going to have to
actually change that up so we're going
to tweak this a little bit next time so
let's do our button for now
we're going to put it here this is going
to be
uh
run report
and he's going to be run report and
we're going to give it probably an id or
may not even have to so that'll be what
we're going to pick up next time around
so next time around we will run a report
for now
uh we're getting there and you're gonna
see here
i get my parameters as needed and we'll
clean this up a little bit and generate
our reports
next time around so until then have
yourself a great day
a great week and we will talk to you
next time
you
Transcript Segments
0.63

[Music]

26.32

welcome back

27.519

we are continuing to plow through

29.679

working on our reports

31.439

and we're going to do is we're going to

32.64

actually build a sort of like a dynamic

35.6

report page

36.559

and so we've started down this path a

38.239

little bit and now we're going to

40.399

continue it so if we go to

42.84

our uh where to go reports page

47.76

now we have our selector and

50.96

right now we're just displaying the

52.879

report id but instead

55.52

what i want to do is i want to

59.6

fill out the reports so i'm going to do

64.08

i'm going to actually call this i'm

65.6

going to send an id

67.84

and i'm going to get say display

72.479

report parameters

76.799

and what that's going to do uh so let's

79.04

see blah blah blah that needs to be

80.96

id so i'm going to do display

84.96

port parameters id

89.36

i'm going to put this on top of it just

91.2

because

94.88

so now it's going to call this and it's

98.079

going to

98.96

just open up the parameters section

101.439

there

102.799

and then return so but what we need to

104.64

do is here i'm going to get

109.68

let's see this will be rpt parms we're

112.96

going to call it that i'm going to give

114.399

it an id for report

116.64

it's going to get it's going to set this

118.96

time however

120.159

our element is actually going to be

125.119

our parameters

128.319

actually let's just pull that whole

130

piece out

133.599

i'm just going to do all of it here so

135.12

what it's going to do is it's going to

136.879

get that

137.92

element we're going to do the display

140.16

blocks going to be the last thing we do

144.4

and then what we want to do is

152

is we want to take the response

155.68

and set it to that so that was uh

158

element

160.08

dot because we're going to actually

161.599

build the whole

165.28

thing here

168.879

so now what we need to do is we're going

170.239

to have to actually get the response

172.319

that we get back

173.2

from our ajax call so we can actually do

176.4

something with this

177.68

uh which did we do that before

181.76

uh where was that that was it oh we

183.519

didn't before because we were just doing

185.04

a fire and forget this time

186.56

we're going to tweak it and we're going

187.84

to actually deal with our response

225.519

three two one now what we have to do

229.2

here is we have to actually

230.56

uh we're gonna have to set some stuff up

232.4

here so this is a little bit

233.76

uh different from what we've seen in the

236.159

past we're gonna do an on

237.519

uh ready state change

241.84

and so this means um basically when we

245.68

when this thing comes when some sort of

247.28

response comes back from this we're

248.64

going to be working with it

250.319

and so what we want to do is we want it

251.68

to be equal to a function

255.439

and in that function because we're going

257.44

to do some we're going to

258.88

do stuff and so if this

263.44

dot ready state

267.199

equals four and

271.96

this.status

274.8

equals 200. so basically if this thing

277.44

completes if we get a return

279.12

we're going to do something and we're

281.12

gonna do the result

282.4

that we get back is the

285.44

response text and then

288.479

uh actually we're gonna have to within

290.479

this whoops i gotta do that right

296.16

and then what we need to do is we're

297.28

going to have to actually do the update

299.52

here so it's going to be since we don't

301.52

have this within

303.68

we're actually going to have to do this

305.6

here as well

311.84

actually yes let's just move all of this

315.28

in here

317.12

so we're only going to deal with this

318.88

once we get back

321.759

a response and we're gonna have to build

324.16

this out

324.8

so it's gonna take us probably again a

327.12

couple of

327.919

uh episodes get through this because

330.24

first okay so let's see so we're gonna

331.759

come through

333.12

i'm gonna call report parms i'm gonna

334.96

give it

337.199

uh that oh no we want it to be equal to

340.88

result

343.759

and then display

346.8

uh get element by d okay so now we need

349.039

to go to

349.919

what we're calling which we called rpt

352.8

params and we're going to send it an id

354.72

so let's set that up

358.56

i called it that so let's see i've got

361.12

one here i'm just going to steal this

362.72

just to make it a little easier

366.8

and that's going to be my here

371.199

so this is going to be i'm going to call

374.4

it report parameters

379.28

and so i'm going to need a report

380.72

parameters over on this side

383.44

on my views

387.84

and i'm going to do something

393.12

let's just do this

396.8

steal this guy

400

parameters he's going to have an id

407.6

and the response i'm going to send back

410.08

is going to be the parms

415.919

and farms equals we're going to start

418.479

with um

422.88

we'll do it this way yeah it's not going

426.08

to be an h1 i'll be in h4

431.84

um let's see we could say

434.96

no parameters available

443.36

and then otherwise we're going to come

444.479

in we're just going to hard code this

445.919

right now we could do something a little

447.28

more complicated but we're going to keep

449.199

it

449.44

essentially hard coded in our report

451.199

parameters

452.96

and so we're just going to do if id

456.8

equals 1. we're going to do something

461.28

if id equals 2 it's going to be

463.12

something else

464.879

and if i d3 it's going to be something

466.8

else and then

469.28

in each of these because we look at our

471.52

reports

473.759

each of these it's by status by roadmap

475.759

or by timeline so each of these we're

477.28

going to actually have

479.28

you're going to select a status a

480.479

roadmap or a timeline so each of these

482.08

is going to start with

484.96

a selector

488.16

and we're going to do his name is going

491.12

to be equal

491.919

to rpt parms

495.44

parm1 so we're going to start that so

498.16

each one of these

499.84

this would be eventually we could have

501.039

multiple parameters

504.24

and then uh

508.08

here this is going to be

511.36

in the select

518.399

and then we're going to create some

519.36

options so we're going to do this for

521.76

each of these actually

526.48

and then we're going to create some

527.76

options and the options are going to be

530.32

based on something so

534.08

something is good so first we're going

535.68

to do is let's like look at

538.08

what we got we've got uh timeline

540.56

roadmap at

541.36

status so let's uh note

544.399

timeline roadmap status whoops go over

547.279

here

551.12

and then this one's going to be

554.48

timeline

560.839

roadmap

565.44

status

573.2

and so this actually becomes pretty easy

575.12

because our options is going to be

577.04

equal to timeline

580.8

dot objects.all

587.12

as we've seen a couple places down here

592.48

like here we're gonna do essentially the

594

same thing

596.88

except see where we did it

600.72

here see i'm just going to take that and

603.839

instead it's going to be

605.6

timeline it's going to be roadmap

613.36

and it's going to be a status

616.8

which we call lkp status okay

628.72

now what we can do with each of these we

630.32

could build it here and we're going to

631.92

we could also build it actually on the

633.44

other side

634.079

but it's a little easier just because

636.48

where we're at we're going to do this so

639.2

we're going to do for opt and ops

645.12

and then each of these is going to build

649.36

a select i'm sorry an option

656.959

so it's going to be option

662

and then actually what we can do is

663.2

we're gonna do this in a one-liner

668.959

and we're gonna do let's see

672.88

sorry id id equals and we're going to

676.24

send it

679.76

we're going to give it the

684.36

option.id and here

689.6

we're going to give it the option dot

694.88

all right we just do option and it's

696.32

going to probably pick up to string

698.24

for us so let's try this

703.2

so you see we could actually do stuff a

704.959

little uh let's see option id yeah so we

707.12

should be able to get that let's see how

708.16

this works out

710.639

i think let's see in there got that got

713.44

that got that

714.959

why are you complaining about timeline

718.72

time frame i'm sorry

728.079

and that was going to get us our

730.48

response we're going to send our spots

732.16

back

732.88

so first let's just test this so if we

734.88

send it

736.56

here

739.6

uh what did we call that

743.279

go to url that was rpt parms

747.2

so let's just steal that real quick

750.88

so if we do uh one

755.76

oh because it doesn't like it it's an id

758.959

versus so let's uh that's going to

761.44

actually be

762

string

766.079

and actually we can take that with each

767.839

of these we could actually

770.399

in this case we could simplify it but

772.24

i'm not going to because we may

773.279

eventually have different params

776

uh let's see so time frame

780.56

to string

784.32

so we do need that so we're going to say

786.24

um here

787.76

i think we can do op dot name for each

789.68

of them

794.72

except for well we may be able to let's

797.6

see did i get that i mean we're

799.12

sort of doing quick okay so now that's

802.56

if i do it for that one i'm going to get

803.92

this little selector

805.6

if i get this one okay so there's

807.6

unbound local

810.32

oh i managed to lose my

814.32

ops there

817.839

that one sets this one was

822.56

look up status this one was roadmap

828.72

okay

831.839

so that's all my road maps

836.48

and there we go okay so

840.8

what i want to do is i'm going to go

841.839

ahead and with each of these i'm going

843.6

to actually do

844.639

a label basically

847.68

and it's going to be um

851.279

select timeline

858.32

select road map

864.48

select status

869.199

so now that's what i'm going to get back

870.72

so now what i can do is

875.04

uh let's see well did i get that done

877.92

let's go check real quick

879.36

if i did my reports

882.88

i can't remember if i had this set up

884.16

right so if i do my roadmap oh there we

885.92

go

886.32

okay so now what i'm doing is i'm going

889.12

to give myself

890.24

the ability to select parameters based

891.92

on a report

893.6

and then i'm going to come back next

894.959

time we're going to actually generate a

896.48

report so with each of these

899.6

actually what i'm going to do is

902.639

because i'm going to need this i'm going

903.76

to have a button

907.6

i'm actually going to steal this one

908.88

because i don't even need the that guy

910.959

anymore

912.16

and within the parameters

916.959

i'm gonna do um i'm gonna do it like

919.519

this i'm gonna do a row here

921.6

well let's do it this way

925.44

i do a row here oh because i'm changing

928.959

the inner html

930.16

so what i want to do is

935.519

that div is

938.88

i'm gonna have a button and i'm gonna

940.48

have a row

942.079

here

945.279

oops i just totally did something weird

948.079

on that

955.759

but now that's oh so i'm going to have

958.24

to change around a little bit because

960.079

of that because i'm doing the inner html

965.199

of this parameters i'm going to have to

967.44

actually change that up so we're going

968.56

to tweak this a little bit next time so

969.92

let's do our button for now

972.32

we're going to put it here this is going

974.639

to be

975.36

uh

978.48

run report

984.399

and he's going to be run report and

987.04

we're going to give it probably an id or

988.639

may not even have to so that'll be what

990.079

we're going to pick up next time around

991.36

so next time around we will run a report

993.92

for now

994.88

uh we're getting there and you're gonna

998.079

see here

1000.48

i get my parameters as needed and we'll

1003.36

clean this up a little bit and generate

1004.8

our reports

1005.68

next time around so until then have

1008.399

yourself a great day

1009.44

a great week and we will talk to you

1012.079

next time

1028.079

you