Detailed Notes
Part I of adding reports and working on dynamic data generation.
You can view source for today and all prior days by reviewing the tag Day 44 at this GitHub https://github.com/robbroadhead/develpreneur-pythontutorial
Transcript Text
[Music] well hello and welcome back we're continuing looking at django and python and this time we're going to do a little bit of uh dynamic adjustment to our some of our buttons and display we're actually working our way up to reports and one of the first things i want to do is handle this little challenge here is that we've got tasks that are complete and we still have a complete button there which makes them you know very redundant so what we want to do in that case is we want to basically remove that complete button we're only going to have it if they are not complete now we want to go back into that so this is our task list so what we're going to do is we're going to go into our task list page and it's actually going to be a pretty simple change so we're going to come in here and instead of complete we're just going to wrap that button and what we're going to do is we're actually going to do a we're either going to just because of the way it's set up we're going to say that if it's not uh if there's no button we're just gonna do a space uh just to make sure that it knows that yes we do have something there and then all we need to do is we're gonna come in here and it's a very simple kind of uh equation we're just gonna say if task dot and the thing that matters is status and if it is not equal to i believe we called it complete with a capital c yep if it's not equal to complete then we're going to have the complete button otherwise we're going to space so if we save that and rerun this now what we saw here is that the uh the status is not coming out the way we want it to and the problem here is because this status is actually going to be a a status object a status instance so instead what we have to do is we have to take a look at our status and we want to do name uh we could do short name but we'll do name for now uh let's see wait where do we go oh let's flip over here to task list back over here and we want status.name it's something can be tricky in the django world because you have things that look pretty straightforward because here we're not actually doing the name we could but here it's because it is an instance it's going to behind the scenes use the tostring which we're going to see if we look at our models it's probably just yep it's just the name so it's actually using that as so we can directly um we can direct we can directly call a value as we do here or we can basically say hey i want you to display it and it's going to do the string so that that can sort of confuse things a little bit but now if we run it then we're gonna see that now everything disappeared now note that this is based on the name so we could uh change this to i think we called it short name without an underscore and i think we called that comp i think of comp for the complete ones and so now we can also do it yep same thing i said we can do it based on the short values which we have talked about when we were comparing for views i remember i think we did that somewhere around here we did a find oh sorry how to find a filter and oh i can't find where we did it by short oh yeah we did it up here we did it like here we did short names to for the get uh to make sure that we're using sort of our our own id and so we're going to use that here in this filter as well so now do some basic you know cleaning up here of this list now the next step i want to get into is actually starting to work on although this is effectively a report i want to actually get into building a report of some sort for it all we're going to do is we're just going to steal our about so we're gonna go back because we don't really need that so we're gonna go back to that was internal and about is now gonna be i'm gonna call this reports and we're gonna change over so we're going to have a reports url which means we need a reports url and we can get rid of our about completely so we're going to get rid of that about page i'm going to do a reports page so now if we go into our view pound page is going to be reports page and we're gonna do all that instead of about pages we can now get rid of we are going to do this reports page and we're going to move that we're going to roughly base it off of task list so let's just duplicate that and rename that to reports page and our reports page is going oh if i can open it there we go let's see so we're probably not gonna worry about completing a task we've got a title so let's go back over to our view here and we want a reports page so we wanted to do there's going to be a title it's gonna be title and we're gonna call that uh let's see where did we do i don't think we did them as yeah so here we just did them as a straight string so we're gonna come back up here reports page said our title this is going to be uh we're just going to call it reports now we'll call reports home we'll do that for now let's go back to our report uh let's and let's kill off a couple of these windows okay so we go back to our ports page and now let's keep it very simple if we look here so we've changed over reports of good reports supports home and it's not doing anything right now because we didn't send it any data that's useful so what we want to do is the first thing we're going to do is we're going to have a task or i'm sorry report selector and we're going to do this as a let's see how we want to do this so that's like uh so reports home is a one let's just do a little uh we'll do it like an h yeah no we're just gonna do bold we'll actually make it strong not string but strong and this is going to be report and we're going to make a list and we're gonna have some options here and this is gonna be a select now what we're gonna do for now is we're gonna keep it simple we're gonna actually hard code our various report options and we'll just have them like numbered but then we can come back later and we can make it database driven if we would like and we may take care of that in this app let's see if we want to do it so let's see the first one we're going to do will be tasks by timeline and then we want to do tasks by roadmap and then we want to do let's just do completed tasks or let's do tasks by status and so each of these is going to tweak stuff a little bit now we can do this a couple different ways uh we can either and we're going to talk about this you know start implementing this on the other side in a next session uh but right now oops reports yeah okay that one's good um right now we've got reports and it's not sending any kind of parameters now what we can do is we could turn around and give it a type we can give it some parameters because each report is probably going to have a parameter so we're going to have to think through that a little bit how we want to do it we can either have a home page like we have here where we select and this is there's two different ways you can do it but basically here you come in you select report and then maybe have it pull data and provide some parameters and then pull data like do an update or you have a home and then each report has its own page with parameters now what we want to do is we want to make it a little simpler so what we're going to have is we're going to have uh here let's see we want to make this a div so we can actually do this in a couple sections so at the top well we're gonna have our and let's put like a break there just because and this needs to be we need to give this an id so this is going to be the id is going to be uh report type because we're going to do some javascript in this thing to make it uh useful and then let's make this a um and then we're going to come in and have another set well we're going to have another row and this one's going to be id equals let's just call him reports selector we're going to have another row which is going to be parameters and then we're going to have down here we're going to have results and let's see that's going to end let's see results it's going to be our if tasks blah blah blah blah blah then we're going to come back here and then we'll end that out so we've got three sections and what we want to do is here we're going to start out with parameters going to be blank so we can do uh class i'm sorry let's just be style uh display none and then we're going to uh let's just call this we're just going to put one here right now which will be uh we're just going to do this as some parameters for now so that we can see it so we come in here we're going to look then we get our ability to select reports but there's no parameters right now because that's hidden now what we want to do is we're going to actually display parameters based on what our selection is so we are going to have a script and we're gonna call this uh let's see i don't know if i've got something that's based on a selector real quick i think i did so let me try if i look at like time frame and if we because i want to see if i can steal one well maybe not yeah because i'm just making that call well i'm actually going to use this a little bit so let's just start from that let's go back to that even though i didn't think i was going to use it i'm going to use it so i'm not going to call it complete test though i'm going to steal this and right now oh this one's going to be a little see well let's do this let me replicate that because i'm actually going to steal that code not in this episode but in the next session we're going to talk about this so first i'm going to do is i want to do select report and it's going to be by an id and then here let's do on change equals oh and actually i don't need well i can probably do this let's see if i just do id as no i don't want to do that i'm going to do it this way i'm not going to pass an id i'm just going to grab the here so i want to grab the id and that's going to be equal to my reports selector and so now that i've got my oops that's my selector and then id we'll do a var here id equals uh selector dot value i think we can get that actually we want uh i think it's called selected value i gotta double check that one okay this actually i mean it's a value and let's just do this so i'm gonna do actually i've done this before some extent so the element is going to be uh parameters and i'm just going to display them for right now because i'm going to make some display equals here equals block so i'm going to go display it and let's see let's do uh element dot inner html equals uh id so we're just gonna sort of mess with this a little bit right now because we're going to be running short on time on this one so we're going to spill into this in the next episode so first let's do this now if i do a change it's not triggering anything so we're going to take a look at that select report so it's not defined well let's say select repo oh because i have a typo and now if i run it there we go oh it's showing the id it's not showing the value so i don't want that in parameter in parentheses i'm not i'm sorry in quotes so do that and now oh it's not getting the value so it's not getting the id right so i'm going to come back to this uh selector.value so i'm gonna have to correct this one for some reason it's not picking that up let's see so here actually is my problem is i need uh say selector dot selected selected index dot value let's see if that works out oh sorry it's dot options and then if i take that and do this then now we'll have oh it's still not doing it doesn't like that uh ah here's my problem it's not these report sector text report type is what i want to work off of so it helps get the right type write names so now if i do this so now i've got my report ids coming in and so that's what wraps up this time i took a little longer than i had expected uh so we're going to do is next episode we're going to start actually we're going to generate one of these reports and talk a little bit about how to do that so that being said let's get to it so have yourself a great day a great week and we will talk to you next time you
Transcript Segments
[Music]
well hello
and welcome back we're continuing
looking at django and python
and this time we're going to do a little
bit of uh
dynamic adjustment to our some of our
buttons and display
we're actually working our way up to
reports and one of the first things i
want to do
is handle this little challenge here is
that we've got
tasks that are complete and we still
have a complete button there which
makes them you know very redundant so
what we want to do in that case
is we want to basically remove that
complete button we're only going to have
it
if they are not complete now we want to
go back into that so this is our
task list so what we're going to do is
we're going to go into
our task list page and it's actually
going to be a pretty simple change so
we're going to come in here
and instead of complete
we're just going to wrap that button
and what we're going to do is we're
actually going to do a
we're either going to just because of
the way it's set up
we're going to say that if it's not
uh if there's no button we're just gonna
do a space
uh just to make sure that it knows that
yes we do have something there
and then all we need to do is we're
gonna come in here and it's a very
simple kind of
uh equation we're just gonna say if task
dot
and the thing that matters is status
and if it is not equal to
i believe we called it complete with a
capital c yep if it's not equal to
complete
then we're going to have the complete
button otherwise we're going to space
so if we save that and rerun this
now what we saw here is that the uh the
status
is not coming out the way we want it to
and the problem here is because this
status
is actually going to be a
a status object a status instance so
instead what we have to do is we have to
take a look at our
status and we want to do name
uh we could do short name but we'll do
name for now
uh let's see wait where do we go oh
let's flip over here
to task list back over here
and we want status.name it's something
can be tricky in the django world
because you have things that look pretty
straightforward because here we're not
actually doing the name we could
but here it's because it is an instance
it's going to behind the scenes use the
tostring
which we're going to see if we look at
our models
it's probably just yep it's just the
name
so it's actually using that as so we can
directly
um we can direct we can directly call a
value as we do here
or we can basically say hey i want you
to display it and it's going to do the
string so that
that can sort of confuse things a little
bit but now if we run it
then we're gonna see that now everything
disappeared now note that this
is based on the name so we could uh
change this to i think we called it
short name
without an underscore
and i think we called that comp
i think of comp for the complete ones
and so now we can also do it yep same
thing
i said we can do it based on the short
values which we have talked about
when we were comparing for views i
remember i think we did that
somewhere around here we did a find
oh sorry how to find a filter
and
oh i can't find where we did it by short
oh yeah we did it up here we did it
like here we did short names to for the
get
uh to make sure that we're using sort of
our our own id and so we're going to use
that here
in this filter as well so now do some
basic you know cleaning up here of this
list
now the next step i want to get into is
actually starting to work on
although this is effectively a report i
want to actually get into
building a report of some sort for it
all we're going to do is we're just
going to steal our about so we're gonna
go back because we don't really need
that
so we're gonna go back to that was
internal
and about is now gonna be i'm gonna call
this reports
and we're gonna change over so we're
going to have a reports url
which means we need a reports url and we
can get rid of our about
completely so we're going to get rid of
that about page
i'm going to do a reports page
so now if we go into our view
pound page is going to be reports page
and we're gonna do all that instead of
about pages we can now
get rid of
we are going to
do this reports page
and we're going to move that we're going
to roughly base it off of task list so
let's just duplicate
that
and rename that to reports page
and our reports page is going oh if i
can open it there we go
let's see so we're probably not gonna
worry about
completing a task
we've got a title so let's go back over
to our view here
and we want a reports page
so we wanted to do there's going to be a
title
it's gonna be title and we're gonna call
that
uh let's see where did we do i don't
think we did them as
yeah so here we just did them as a
straight string so we're gonna come back
up here
reports page said our title this is
going to be
uh we're just going to call it reports
now we'll call reports home we'll do
that for now
let's go back to our report uh let's
and let's kill off a couple of these
windows
okay so we go back to our ports page and
now
let's keep it very simple
if we look here so we've changed over
reports of good reports
supports home and it's not doing
anything right now because we didn't
send it any
data that's useful so what we want to do
is the first thing we're going to do is
we're going to have a
task or i'm sorry report selector
and we're going to do this as a
let's see how we want to do this so
that's like uh
so reports home is a one let's just do a
little
uh we'll do it like an h yeah no we're
just gonna do bold
we'll actually make it strong not string
but strong
and this is going to be
report and we're going to make a list
and we're gonna have some options here
and this is gonna be a select
now what we're gonna do for now is we're
gonna keep it simple we're gonna
actually hard code our
various report options
and we'll just have them like numbered
but then we can come back later and we
can make it database driven if we would
like
and we may take care of that in this app
let's see if we want to do it so let's
see the first one we're going to do
will be tasks by
timeline
and then we want to do tasks by roadmap
and then we want to do let's just do
completed
tasks or let's do tasks by status
and so each of these is going to tweak
stuff a little bit
now we can do this a couple different
ways uh we can either
and we're going to talk about this you
know start implementing this on the
other side in a
next session uh but right now oops
reports yeah okay that one's good um
right now we've got reports and it's not
sending
any kind of parameters now what we can
do
is we could turn around and give it a
type
we can give it some parameters because
each report is probably going to have a
parameter
so we're going to have to think through
that a little bit how we want to do it
we can either have a
home page like we have here where we
select
and this is there's two different ways
you can do it but basically here you
come in you select report
and then maybe have it pull data and
provide some parameters and then pull
data like do an update
or you have a home and then each report
has its own page with
parameters now what we want to do is we
want to make it a little simpler
so what we're going to have is we're
going to have
uh here let's see we want to make this a
div
so we can actually do this in a couple
sections
so at the top well
we're gonna have our
and let's put like a break there just
because
and this needs to be we need to give
this an id so this is going to be
the id is going to be uh report type
because we're going to do some
javascript in this thing
to make it uh useful and then let's make
this
a um and then we're going to come in and
have another set well we're going to
have another row
and this one's going to be id equals
let's just call him reports
selector we're going to have another row
which is going to be
parameters
and then we're going to have down here
we're going to have results
and let's see that's going to end let's
see results it's going to be our if
tasks
blah blah blah blah blah then we're
going to come back here and then we'll
end that out
so we've got three sections and what we
want to do is here
we're going to start out with parameters
going to be blank
so we can do uh class i'm sorry let's
just be style
uh display none
and then we're going to uh let's just
call this
we're just going to put one here right
now which will be
uh we're just going to do this as some
parameters
for now so that we can see it so we come
in here
we're going to look then we get our
ability to
select reports but there's no parameters
right now because that's hidden
now what we want to do is we're going to
actually display parameters based on
what our selection is so we are going to
have a script
and we're gonna call this uh let's see i
don't know if i've got something that's
based on a selector real quick
i think i did so let me try if i look at
like time frame
and if we
because i want to see if i can steal one
well maybe not
yeah because i'm just making that call
well i'm actually going to use this a
little bit so let's just start from that
let's go back to that even though i
didn't think i was going to use it i'm
going to use it
so i'm not going to call it complete
test though i'm going to
steal this and right now oh this one's
going to be a little
see well let's do this
let me replicate that because i'm
actually going to steal that code not in
this episode but in the next
session we're going to talk about this
so first i'm going to do is i want to do
select report and it's going to be by an
id
and then here
let's do on change
equals
oh and actually i don't need
well i can probably do this let's see if
i just do id as
no i don't want to do that i'm going to
do it this way i'm not going to pass an
id
i'm just going to grab the
here
so i want to grab the id
and that's going to be equal to my
reports
selector
and so now that i've got my oops that's
my
selector and then id
we'll do a var here id equals uh
selector dot
value i think we can get that actually
we want uh i think it's called selected
value i gotta double check that one okay
this actually
i mean it's a value
and let's just do this so i'm gonna do
actually i've done this before some
extent so the element is going to be
uh parameters
and i'm just going to display them for
right now because i'm going to make some
display equals
here equals block so i'm going to go
display it
and let's see
let's do uh element
dot inner html
equals uh id
so we're just gonna sort of mess with
this a little bit right now because
we're going to be
running short on time on this one so
we're going to spill into this in the
next episode so first
let's do this now if i do a change
it's not triggering anything so we're
going to take a look at that
select report so it's not defined well
let's say select repo
oh because i have a typo
and now if i run it there we go oh it's
showing the id
it's not showing the value
so i don't want that in parameter in
parentheses i'm not i'm sorry in quotes
so do that and now
oh it's not getting the value so it's
not getting the id right so i'm going to
come back to this
uh selector.value so i'm gonna have to
correct this one for some reason it's
not
picking that up let's see so here
actually is my problem
is i need uh say selector
dot selected selected index
dot value let's see if that works out oh
sorry it's dot options
and then if i take that and do this then
now
we'll have oh it's still not doing it
doesn't like that uh
ah here's my problem it's not these
report sector text report type
is what i want to work off of
so it helps get the right type write
names so now
if i do this so now i've got my report
ids coming in and so
that's what wraps up this time i took a
little longer than i had expected
uh so we're going to do is next episode
we're going to start actually we're
going to generate one of these reports
and talk a little bit about how
to do that so that being said let's get
to it so
have yourself a great day a great week
and we will talk to you
next time
you