Commit 12679ae4 authored by Amyll Angelin's avatar Amyll Angelin

Everything Works Now

o homepage
o default profile
o edit profile
o add keys
o add week item
o edit week item
o delete week item
o add daily item
o edit daily item
o back home

x mark as done
x code not proofread
x profile picture
parent f98aef07
Pipeline #1853 failed with stages
...@@ -33,13 +33,15 @@ urlpatterns = [ ...@@ -33,13 +33,15 @@ urlpatterns = [
path('this_week/', views.week_view, name='this_week'), path('this_week/', views.week_view, name='this_week'),
path('this_week/add_week/', views.add_week_view, name='this_week_add'), path('this_week/add_week/', views.add_week_view, name='this_week_add'),
path('this_week/edit_week/)', views.edit_week_view, name='this_week_edit'), path('this_week/edit_week/<int:pk>/', views.edit_week_view, name='this_week_edit_pk'),
path('this_week/delete_week/', views.delete_week_view, name='this_week_delete'),
path('this_week/delete_week/<int:pk>/', views.delete_week_view, name='this_week_delete_pk'), path('this_week/delete_week/<int:pk>/', views.delete_week_view, name='this_week_delete_pk'),
path('this_week/mark_week/<int:pk>/', views.delete_week_view, name='this_week_mark_pk'),
path('today/', views.today_view, name='today'), path('today/', views.today_view, name='today'),
path('today/add_today/', views.add_today_view, name='today_add'), path('today/add_today/', views.add_today_view, name='today_add'),
path('today/edit_today/)', views.edit_today_view, name='today_edit'), path('today/edit_today/<int:pk>/', views.edit_today_view, name='today_edit_pk'),
path('today/delete_today/', views.delete_today_view, name='today_delete'),
path('today/delete_today/<int:pk>/', views.delete_today_view, name='today_delete_pk'), path('today/delete_today/<int:pk>/', views.delete_today_view, name='today_delete_pk'),
path('today/mark_today/<int:pk>/', views.mark_week_view, name='this_week_mark_pk'),
] ]
from django import forms from django import forms
from .models import User, Nickname, Bio, Key, Week, Today from .models import User, Nickname, Bio, Key, Week, Today
class UserForm(forms.ModelForm): class UserForm(forms.ModelForm):
......
...@@ -41,12 +41,16 @@ def edit_nickname_view(request, *args, **kwargs): ...@@ -41,12 +41,16 @@ def edit_nickname_view(request, *args, **kwargs):
form=NicknameForm(request.POST or None) form=NicknameForm(request.POST or None)
if form.is_valid(): if form.is_valid():
form.save() form.save()
return redirect("/profile")
return render(request, "edit_nickname.html", {"form": form}) return render(request, "edit_nickname.html", {"form": form})
task = Week.objects.get(pk=pk)
def edit_bio_view(request, *args, **kwargs): def edit_bio_view(request, *args, **kwargs):
form=BioForm(request.POST or None) form=BioForm(request.POST or None)
if form.is_valid(): if form.is_valid():
form.save() form.save()
return redirect("/profile")
return render(request, "edit_bio.html", {"form": form}) return render(request, "edit_bio.html", {"form": form})
...@@ -75,11 +79,16 @@ def add_week_view(request, *args, **kwargs): ...@@ -75,11 +79,16 @@ def add_week_view(request, *args, **kwargs):
form.save() form.save()
return render(request, "add_week.html", {"form": form}) return render(request, "add_week.html", {"form": form})
def edit_week_view(request, *args, **kwargs): def edit_week_view(request, pk):
form=WeekForm(request.POST) task = Week.objects.get(pk=pk)
form=WeekForm(request.POST or None, instance=task)
if request.method == "POST":
if form.is_valid(): if form.is_valid():
form.save() form.save()
return render(request, "edit_week.html", {"form": form}) return redirect("/this_week")
return render(request, "edit_week.html", {"form" : form} )
def delete_week_view(request, pk): def delete_week_view(request, pk):
task = Week.objects.get(pk=pk) task = Week.objects.get(pk=pk)
...@@ -89,6 +98,9 @@ def delete_week_view(request, pk): ...@@ -89,6 +98,9 @@ def delete_week_view(request, pk):
return redirect("/this_week") return redirect("/this_week")
return render(request, "delete_week.html", {"task": task} ) return render(request, "delete_week.html", {"task": task} )
def mark_week_view(request, pk):
return render(request, "delete_week.html", {"task": task} )
def today_view(request, *args, **kwargs): def today_view(request, *args, **kwargs):
...@@ -103,16 +115,25 @@ def add_today_view(request, *args, **kwargs): ...@@ -103,16 +115,25 @@ def add_today_view(request, *args, **kwargs):
form.save() form.save()
return render(request, "add_today.html", {"form": form}) return render(request, "add_today.html", {"form": form})
def edit_today_view(request, *args, **kwargs): def edit_today_view(request, pk):
form=TodayForm(request.POST) task = Today.objects.get(pk=pk)
form=TodayForm(request.POST or None, instance=task)
if request.method == "POST":
if form.is_valid(): if form.is_valid():
form.save() form.save()
return render(request, "edit_today.html", {"form": form}) return redirect("/today")
return render(request, "edit_today.html", {"form" : form} )
def delete_today_view(request, *args, **kwargs): def delete_today_view(request, pk):
task = Today.objects.get(pk=pk) task = Today.objects.get(pk=pk)
if request.method == "POST": if request.method == "POST":
task.delete() task.delete()
return redirect("/today") return redirect("/today")
return render(request, "delete_today.html", {"task": task} ) return render(request, "delete_today.html", {"task": task} )
def mark_today_view(request, pk):
return render(request, "delete_today.html", {"task": task} )
\ No newline at end of file
<html>
<head>
<title> This Week </title>
</head>
<body>
<center>
<h1>Delete Task</h1>
<form method ="POST"> {% csrf_token %}
Are you sure you would like to delete the {{task}}? <br> <br>
<a href="{% url 'today' % pk=task.pk()}"><input button type="submit" value="Yes"></a> </input> </form>
<a href="{% url 'today' %}"><button> No </button></a> <br> <br>
<br>
<a href="http://127.0.0.1:8000/home/"><button> Home </button></a>
<a href="http://127.0.0.1:8000/profile/"><button> Profile </button></a>
<a href="http://127.0.0.1:8000/key/"><button> Key </button></a>
<a href="http://127.0.0.1:8000/this_week/"><button> This Week </button></a>
<a href="http://127.0.0.1:8000/today/"><button> Today </button></a></center>
</center>
</body>
<html>
\ No newline at end of file
<html> <html>
<head> <head>
<title> This Week </title> <title> Today </title>
</head> </head>
<body> <body>
<center> <center>
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
<h3>03.01.MON - 03.07.SUN</h3> <h3>03.01.MON - 03.07.SUN</h3>
{% for week in WeekList %} {% for week in WeekList %}
<li> {{week}} </li> <li> {{week}} </li>
<br><a href="http://127.0.0.1:8000/this_week/edit_week"><button>Edit</button></a> <br><a href="{% url 'this_week_edit_pk' pk=week.pk %}"><button>Edit</button></a>
<a href="{% url 'this_week_delete_pk' pk=week.pk %}"><button>Delete</button></a> <a href="{% url 'this_week_delete_pk' pk=week.pk %}"><button>Delete</button></a>
<a href="http://127.0.0.1:8000/this_week/mark_week"><button>Mark as Done </button></a> <br> <br> <a href="http://127.0.0.1:8000/this_week/mark_week"><button>Mark as Done </button></a> <br> <br>
{% endfor %} {% endfor %}
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
<h3>03.01.MON - 03.07.SUN</h3> <h3>03.01.MON - 03.07.SUN</h3>
{% for today in TodayList %} {% for today in TodayList %}
<li> {{today}} </li> <li> {{today}} </li>
<br><a href="http://127.0.0.1:8000/today/edit_today"><button>Edit</button></a> <br><a href="{% url 'today_edit_pk' pk=today.pk %}"><button>Edit</button></a>
<a href="{% url 'today_delete_pk' pk=today.pk %}"><button>Delete</button></a> <a href="{% url 'today_delete_pk' pk=today.pk %}"><button>Delete</button></a>
<a href="http://127.0.0.1:8000/this_week/mark_today"><button>Mark as Done </button></a> <br> <br> <a href="http://127.0.0.1:8000/this_week/mark_today"><button>Mark as Done </button></a> <br> <br>
{% endfor %} {% endfor %}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment