Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
esguerra_lab1
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
James Esguerra
esguerra_lab1
Commits
0e58a149
Commit
0e58a149
authored
Apr 08, 2021
by
James Esguerra
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added "Mark as done" button to today view
parent
61f8a525
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
23 deletions
+14
-23
views.cpython-38.pyc
pages/__pycache__/views.cpython-38.pyc
+0
-0
views.py
pages/views.py
+9
-19
today.html
templates/today.html
+5
-4
No files found.
pages/__pycache__/views.cpython-38.pyc
View file @
0e58a149
No preview for this file type
pages/views.py
View file @
0e58a149
...
@@ -27,7 +27,7 @@ def ShowHome(request):
...
@@ -27,7 +27,7 @@ def ShowHome(request):
def
ShowProfile
(
request
):
def
ShowProfile
(
request
):
form
=
UserForm
()
form
=
UserForm
()
if
User
.
objects
.
count
()
==
0
:
if
User
.
objects
.
count
()
==
0
:
user
=
User
(
user
=
User
(
#creates the default model instance for the User Model
nickname
=
'Your nickname'
,
nickname
=
'Your nickname'
,
bio
=
'A short description about yourself.'
,
bio
=
'A short description about yourself.'
,
profile_photo
=
'default.jpg'
profile_photo
=
'default.jpg'
...
@@ -46,33 +46,28 @@ def ShowProfile(request):
...
@@ -46,33 +46,28 @@ def ShowProfile(request):
if
form
.
is_valid
():
if
form
.
is_valid
():
form
.
save
()
form
.
save
()
return
redirect
(
'profile'
)
return
redirect
(
'profile'
)
return
render
(
request
,
'profile.html'
,
context
)
return
render
(
request
,
'profile.html'
,
context
)
def
ShowEditNickname
(
request
):
def
ShowEditNickname
(
request
):
user
=
User
.
objects
.
get
(
pk
=
1
)
user
=
User
.
objects
.
get
(
pk
=
1
)
form
=
NicknameForm
(
instance
=
user
)
form
=
NicknameForm
(
instance
=
user
)
if
request
.
method
==
'POST'
:
if
request
.
method
==
'POST'
:
form
=
NicknameForm
(
request
.
POST
,
instance
=
user
)
form
=
NicknameForm
(
request
.
POST
,
instance
=
user
)
if
form
.
is_valid
():
if
form
.
is_valid
():
form
.
save
()
form
.
save
()
return
redirect
(
'profile'
)
return
redirect
(
'profile'
)
return
render
(
request
,
'edit_nickname.html'
,
{
'form'
:
form
})
return
render
(
request
,
'edit_nickname.html'
,
{
'form'
:
form
})
def
ShowEditBio
(
request
):
def
ShowEditBio
(
request
):
user
=
User
.
objects
.
get
(
pk
=
1
)
user
=
User
.
objects
.
get
(
pk
=
1
)
form
=
BioForm
(
instance
=
user
)
form
=
BioForm
(
instance
=
user
)
if
request
.
method
==
'POST'
:
if
request
.
method
==
'POST'
:
form
=
BioForm
(
request
.
POST
,
instance
=
user
)
form
=
BioForm
(
request
.
POST
,
instance
=
user
)
if
form
.
is_valid
():
if
form
.
is_valid
():
form
.
save
()
form
.
save
()
return
redirect
(
'profile'
)
return
redirect
(
'profile'
)
return
render
(
request
,
'edit_bio.html'
,
{
'form'
:
form
})
return
render
(
request
,
'edit_bio.html'
,
{
'form'
:
form
})
...
@@ -88,22 +83,18 @@ def ShowAddKey(request):
...
@@ -88,22 +83,18 @@ def ShowAddKey(request):
if
form
.
is_valid
():
if
form
.
is_valid
():
form
.
save
()
form
.
save
()
return
redirect
(
'key'
)
return
redirect
(
'key'
)
return
render
(
request
,
'add_key.html'
,
{
'form'
:
form
})
return
render
(
request
,
'add_key.html'
,
{
'form'
:
form
})
def
ShowThisWeek
(
request
):
def
ShowThisWeek
(
request
):
item_list
=
list
(
ItemsThisWeek
.
objects
.
all
())
item_list
=
list
(
ItemsThisWeek
.
objects
.
all
())
if
request
.
method
==
'POST'
:
if
request
.
method
==
'POST'
:
for
i
in
request
.
POST
.
keys
():
for
i
in
request
.
POST
.
keys
():
name
=
i
name
=
i
# i is equal to the 'name' from request.POST
for
item
in
item_list
:
for
item
in
item_list
:
if
str
(
item
.
id
)
==
name
:
if
str
(
item
.
id
)
==
name
:
item
.
key_type
.
key_name
=
'Task done'
item
.
key_type
.
key_name
=
'Task done'
break
break
return
render
(
request
,
'this_week.html'
,
{
'item_list'
:
item_list
})
return
render
(
request
,
'this_week.html'
,
{
'item_list'
:
item_list
})
...
@@ -114,20 +105,17 @@ def ShowAddItemTW(request):
...
@@ -114,20 +105,17 @@ def ShowAddItemTW(request):
if
form
.
is_valid
():
if
form
.
is_valid
():
form
.
save
()
form
.
save
()
return
redirect
(
'this_week'
)
return
redirect
(
'this_week'
)
return
render
(
request
,
'add_itemTW.html'
,
{
'form'
:
form
})
return
render
(
request
,
'add_itemTW.html'
,
{
'form'
:
form
})
def
ShowEditItemTW
(
request
,
pk
):
def
ShowEditItemTW
(
request
,
pk
):
item
=
ItemsThisWeek
.
objects
.
get
(
id
=
pk
)
item
=
ItemsThisWeek
.
objects
.
get
(
id
=
pk
)
form
=
ItemsThisWeekForm
(
instance
=
item
)
form
=
ItemsThisWeekForm
(
instance
=
item
)
if
request
.
method
==
'POST'
:
if
request
.
method
==
'POST'
:
form
=
ItemsThisWeekForm
(
request
.
POST
,
instance
=
item
)
form
=
ItemsThisWeekForm
(
request
.
POST
,
instance
=
item
)
if
form
.
is_valid
():
if
form
.
is_valid
():
form
.
save
()
form
.
save
()
return
redirect
(
'this_week'
)
return
redirect
(
'this_week'
)
return
render
(
request
,
'edit_itemTW.html'
,
{
'form'
:
form
})
return
render
(
request
,
'edit_itemTW.html'
,
{
'form'
:
form
})
...
@@ -136,12 +124,18 @@ def ShowDeleteItemTW(request, pk):
...
@@ -136,12 +124,18 @@ def ShowDeleteItemTW(request, pk):
item
=
ItemsThisWeek
.
objects
.
get
(
id
=
pk
)
item
=
ItemsThisWeek
.
objects
.
get
(
id
=
pk
)
item
.
delete
()
item
.
delete
()
return
redirect
(
'this_week'
)
return
redirect
(
'this_week'
)
return
render
(
request
,
'delete_itemTW.html'
)
return
render
(
request
,
'delete_itemTW.html'
)
def
ShowToday
(
request
):
def
ShowToday
(
request
):
item_list
=
list
(
ItemsToday
.
objects
.
all
())
item_list
=
list
(
ItemsToday
.
objects
.
all
())
if
request
.
method
==
'POST'
:
for
i
in
request
.
POST
.
keys
():
name
=
i
# i is equal to the 'name' from request.POST
for
item
in
item_list
:
if
str
(
item
.
id
)
==
name
:
item
.
key_type
.
key_name
=
'Task done'
break
return
render
(
request
,
'today.html'
,
{
'item_list'
:
item_list
})
return
render
(
request
,
'today.html'
,
{
'item_list'
:
item_list
})
...
@@ -152,20 +146,17 @@ def ShowAddItemT(request):
...
@@ -152,20 +146,17 @@ def ShowAddItemT(request):
if
form
.
is_valid
():
if
form
.
is_valid
():
form
.
save
()
form
.
save
()
return
redirect
(
'today'
)
return
redirect
(
'today'
)
return
render
(
request
,
'add_itemT.html'
,
{
'form'
:
form
})
return
render
(
request
,
'add_itemT.html'
,
{
'form'
:
form
})
def
ShowEditItemT
(
request
,
pk
):
def
ShowEditItemT
(
request
,
pk
):
item
=
ItemsToday
.
objects
.
get
(
id
=
pk
)
item
=
ItemsToday
.
objects
.
get
(
id
=
pk
)
form
=
ItemsTodayForm
(
instance
=
item
)
form
=
ItemsTodayForm
(
instance
=
item
)
if
request
.
method
==
'POST'
:
if
request
.
method
==
'POST'
:
form
=
ItemsTodayForm
(
request
.
POST
,
instance
=
item
)
form
=
ItemsTodayForm
(
request
.
POST
,
instance
=
item
)
if
form
.
is_valid
():
if
form
.
is_valid
():
form
.
save
()
form
.
save
()
return
redirect
(
'today'
)
return
redirect
(
'today'
)
return
render
(
request
,
'edit_itemT.html'
,
{
'form'
:
form
})
return
render
(
request
,
'edit_itemT.html'
,
{
'form'
:
form
})
...
@@ -174,5 +165,4 @@ def ShowDeleteItemT(request, pk):
...
@@ -174,5 +165,4 @@ def ShowDeleteItemT(request, pk):
item
=
ItemsToday
.
objects
.
get
(
id
=
pk
)
item
=
ItemsToday
.
objects
.
get
(
id
=
pk
)
item
.
delete
()
item
.
delete
()
return
redirect
(
'today'
)
return
redirect
(
'today'
)
return
render
(
request
,
'delete_itemT.html'
)
return
render
(
request
,
'delete_itemT.html'
)
templates/today.html
View file @
0e58a149
...
@@ -11,16 +11,17 @@
...
@@ -11,16 +11,17 @@
<h2>
04.14.WED
</h2>
<h2>
04.14.WED
</h2>
<br>
<br>
{% for item in item_list %}
{% for item in item_list %}
<
p
>
<
form
method=
'POST'
>
<b>
{{ item.key_type }}:
</b>
{{ item.details }}
<b>
{{ item.key_type }}:
</b>
{{ item.details }}
<a
href=
'{% url '
edit_itemT
'
item
.
pk
%}'
><button
type=
'button'
>
Edit
</button></a>
<a
href=
'{% url '
edit_itemT
'
item
.
pk
%}'
><button
type=
'button'
>
Edit
</button></a>
<a
href=
'{% url '
delete_itemT
'
item
.
pk
%}'
><button
type=
'button'
>
Delete
</button></a>
<a
href=
'{% url '
delete_itemT
'
item
.
pk
%}'
><button
type=
'button'
>
Delete
</button></a>
{% if item.key_type.key_name == 'Task' %}
{% if item.key_type.key_name == 'Task' %}
<input
type=
'submit'
name=
'Submit'
method=
'POST'
value=
'Mark as done'
>
{% csrf_token %}
<input
type=
'submit'
name=
'{{ item.id }}'
value=
'Mark as done'
/>
{% endif %}
{% endif %}
<
p
>
<
/form
>
{% endfor %}
{% endfor %}
<a
href=
'{% url '
add_itemT
'
%}'
><button
type=
'button'
>
Add Item
</button></a>
<a
href=
'{% url '
add_itemT
'
%}'
><button
type=
'button'
>
Add Item
</button></a>
</div>
</div>
{% endblock %}
{% endblock %}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment