Commit cf6e3aa2 authored by nikkastra's avatar nikkastra

final

ayaw ko nang tapusin. masyado nang bullshit. literal na ni-recycle ko lang code ko para sa isang part tapos ayaw gumana?
parent 005385ee
......@@ -31,6 +31,7 @@ class Task(forms.ModelForm):
fields = ['key', 'task']
class EditTask(forms.Form):
edittask = forms.CharField(label='', max_length=100, required=False)
\ No newline at end of file
class Today(forms.ModelForm):
class Meta:
model = Today
fields = ['key', 'task']
\ No newline at end of file
# Generated by Django 3.1.7 on 2021-04-10 07:20
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('bulletjournal', '0005_auto_20210409_2301'),
]
operations = [
migrations.CreateModel(
name='Today',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('task', models.CharField(max_length=100)),
('key', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='bulletjournal.key')),
('name', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='bulletjournal.name')),
],
),
]
# Generated by Django 3.1.7 on 2021-04-10 07:51
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('bulletjournal', '0006_today'),
]
operations = [
migrations.RenameField(
model_name='today',
old_name='key',
new_name='keys',
),
]
# Generated by Django 3.1.7 on 2021-04-10 07:56
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('bulletjournal', '0007_auto_20210410_1551'),
]
operations = [
migrations.RenameField(
model_name='today',
old_name='keys',
new_name='key',
),
]
from django.db import models
from django.urls import reverse
class Name(models.Model):
name = models.CharField(max_length=100, unique=True, default="test")
......@@ -11,7 +11,7 @@ class Name(models.Model):
return '{} {} {}'.format(self.name, self.nickname, self.bio)
def get_absolute_url(self):
return reverse('name_detail', args=[str(self.pk)])
return reverse('name_detail', args=[str(self.id)])
@property
def is_tutorial(self):
......@@ -32,4 +32,19 @@ class Tasks(models.Model):
task = models.CharField(max_length=100)
def __str__(self):
return '{}: {}'.format(self.key, self.task)
\ No newline at end of file
return '{}: {}'.format(self.key, self.task)
def get_absolute_url(self):
return reverse('task_detail', args=[str(self.id)])
class Today(models.Model):
name = models.ForeignKey(Name, on_delete=models.CASCADE)
key = models.ForeignKey(Key, on_delete=models.CASCADE)
task = models.CharField(max_length=100)
def __str__(self):
return '{}: {}'.format(self.key, self.task)
def get_absolute_url(self):
return reverse('today_detail', args=[str(self.id)])
\ No newline at end of file
......@@ -8,8 +8,11 @@ urlpatterns = [
path('home', home, name = 'home'),
path('profile', profile, name = 'profile'),
path('key', key, name = 'key'),
path('this_week', thisweek, name = 'thisweek'),
path('today', today, name = 'today'),
path('names', NameListView.as_view(), name = 'name_list'),
path('name/<int:pk>', NameDetailView.as_view(), name = 'name_detail')
path('thisweek', TaskListView.as_view(), name = 'thisweek'),
path('addtask', thisweek, name = 'addtask'),
path('addtoday', today, name = 'addtoday'),
path('today', TodayListView.as_view(), name = 'today'),
path('delete', delete_task, name = 'delete'),
path('task/<int:pk>', TaskDetailView.as_view(), name = 'task_detail'),
path('today/<int:pk>', TodayDetailView.as_view(), name = 'today_detail')
]
\ No newline at end of file
......@@ -3,6 +3,9 @@ from django.http import HttpResponse
from django.views import View
from django.views.generic.list import ListView
from django.views.generic.detail import DetailView
from django.views.generic.edit import *
from django.urls import *
from django.shortcuts import redirect
from .forms import *
from .models import *
......@@ -17,8 +20,22 @@ class NameListView(ListView):
model = Name
class NameDetailView(DetailView):
model = Name
class TaskDetailView(DetailView):
model = Tasks
class TaskListView(ListView):
model = Tasks
template_name = 'thisweek.html'
class TodayListView(ListView):
model = Today
template_name = 'today.html'
class TodayDetailView(DetailView):
model = Today
class HomePageView(View):
......@@ -109,40 +126,34 @@ def key(request):
def thisweek(request):
this_dict = {}
new_task = ''
if request.method == 'POST':
form1 = Task(request.POST)
form2 = EditTask(request.POST)
if form1.is_valid() or form2.is_valid():
x = ''
for y in request.POST:
x = y
if x == 'task':
new_task = Tasks(name=Name.objects.get(name=name_dict['name']), key=form1.cleaned_data['key'], task=form1.cleaned_data['task'])
new_task.save()
the_tasks = [str(x) for x in Tasks.objects.all()]
this_dict['form1'] = form1
this_dict['form2'] = form2
this_dict['the_tasks'] = the_tasks
return render(request, 'thisweek.html', this_dict)
elif x == 'edittask':
new_task.task = request.POST['edittask']
new_task.save()
the_tasks = [str(x) for x in Tasks.objects.all()]
this_dict['form1'] = form1
this_dict['form2'] = form2
this_dict['the_tasks'] = the_tasks
return render(request, 'thisweek.html', this_dict)
form = Task(request.POST)
if form.is_valid():
new_task = Tasks(name=Name.objects.get(name=name_dict['name']), key=form.cleaned_data['key'], task=form.cleaned_data['task'])
new_task.save()
return redirect('thisweek')
else:
form1 = Task()
form2 = EditTask()
the_tasks = [str(x) for x in Tasks.objects.all()]
this_dict['form1'] = form1
this_dict['form2'] = form2
this_dict['the_tasks'] = the_tasks
return render(request, 'thisweek.html', this_dict)
form = Task()
return render(request, 'addtask.html', {'form': form})
def delete_task(request):
if request.method == 'POST':
form = Task(request.POST)
if form.is_valid():
the_task.delete()
return redirect('thisweek')
else:
form = Task()
return render(request, 'task_detail', {'form': form})
def today(request):
return render(request, 'today.html')
\ No newline at end of file
if request.method == 'POST':
form = Today(request.POST)
if form.is_valid():
new_task = Today(name=Name.objects.get(name=name_dict['name']), key=form.cleaned_data['key'], task=form.cleaned_data['task'])
new_task.save()
return redirect('today')
else:
form = Today()
return render(request, 'addtoday.html', {'form': form})
\ No newline at end of file
{% extends 'thisweek.html' %}
{% block title %}Add Task{% endblock %}
{% block content %}
<form action='{% url "addtask" %}' method='post'>
{% csrf_token %}
{{form.as_p}}
<input type='submit' value='Add'>
</form>
{% endblock %}
\ No newline at end of file
{% extends 'today.html' %}
{% block title %}Add Today{% endblock %}
{% block content %}
<form action='{% url "addtoday" %}' method='post'>
{% csrf_token %}
{{ form.as_p }}
<input type='submit' value='Add'>
</form>
{% endblock %}
\ No newline at end of file
{% extends 'base.html' %}
{% block title %}{{ name.name }}{% endblock %}
{% block content %}
<h1>{{ object.name }}</h1>
<p>kung ano man to</p>
{% endblock %}
\ No newline at end of file
......@@ -4,9 +4,9 @@
{% block content %}
<ul>
{% if object_list %}
{% for name in object_list %}
{% for Name in object_list %}
<li>
<a href="{{Name.get_absolute_url}}">{{Name.name}}</a>
<a href="{{Name.get_absolute_url}}"> {{Name.name}}</a>
</li>
{% endfor %}
{% else %}
......
{% extends 'base.html' %}
{% block title %}{{ object.task }}{% endblock %}
{% block content %}
<h1>{{ object.key }} : {{ object.task }}</h1>
<p> sigurado ka? </p>
<form action="{% url 'update' %}?the_task=object" method="post">
<input id='tago' type="submit" value="Yes">
</form>
<a href = "{% url 'thisweek' %}"><button type=button> No </button></a>
{% endblock %}
\ No newline at end of file
{% extends 'thisweek.html' %}
{% block title %}Add Task{% endblock %}
{% block content %}
<form action='{% url "addtask" %}' method='post'>
{% csrf_token %}
{{form.as_p}}
<input type='submit' value='Add'>
</form>
{% endblock %}
\ No newline at end of file
{% extends 'base.html' %}
{% load static %}
{% block title %} This Week {% endblock %}
{% block styles %}
<link rel="stylesheet" href="{% static 'css/styles.css' %}" type='text/css'>
{% endblock %}
{% block content %}
<h1> This Week </h1>
<p> 03.29.MON - 04.04.SUN </p>
<ul>
{% if object_list %}
{% for Tasks in object_list %}
<li>
{{Tasks.key.key}} : {{Tasks.task}}
<button type='button' onclick='document.getElementById("edit").open="open"'> Edit </button>
<button type='button' onclick='document.getElementById("delete").open="open"'> Delete </button>
{% if Tasks.key.key == "Task" %}
<button type='button' onclick='document.getElementById("mark").open="open"'> Mark as Done </button>
{% endif %}
</li>
{% endfor %}
{% endif %}
</ul>
<a href ="{% url 'addtask' %}"><button type='button'>Add Item</button></a>
<dialog id="edit">
<form action='{% url "thisweek" %}' method='post'>
{% csrf_token %}
{{form2}}
<input type="Submit" value="Update">
</form>
</dialog>
<dialog id="delete">
<form action='{% url "thisweek" %}' method='post'>
{% csrf_token %}
{{form}}
<input type="Submit" value="Add Task">
</form>
</dialog>
{% endblock %}
\ No newline at end of file
{% extends 'base.html' %}
{% block title %}{{ object.task }}{% endblock %}
{% block content %}
<h1>{{ object.key }} : {{ object.task }}</h1>
<p> sigurado ka? </p>
<form action="{% url 'update' %}?the_task=object" method="post">
<input id='tago' type="submit" value="Yes">
</form>
<a href = "{% url 'today' %}"><button type=button> No </button></a>
{% endblock %}
\ No newline at end of file
{% extends 'base.html' %}
{% block title %}{{ object.task }}{% endblock %}
{% block content %}
<h1>{{ object.key }} : {{ object.task }}</h1>
<p> sigurado ka? </p>
<form action="{% url 'update' %}?the_task=object" method="post">
<input id='tago' type="submit" value="Yes">
</form>
<a href = "{% url 'thisweek' %}"><button type=button> No </button></a>
{% endblock %}
\ No newline at end of file
{% extends 'base.html' %}
{% load static %}
{% block title %} Keys {% endblock %}
{% block title %} This Week {% endblock %}
{% block styles %}
<link rel="stylesheet" href="{% static 'css/styles.css' %}" type='text/css'>
{% endblock %}
......@@ -10,37 +10,24 @@
<h1> This Week </h1>
<p> 03.29.MON - 04.04.SUN </p>
<ul>
{% if the_tasks %}
{% for x in the_tasks %}
{{forloop.counter}}
<li>
{{x}}
<button type='button' onclick='document.getElementById("edit").open="open"'>Edit</button>
<button type='button' onclick='document.getElementById("delete").open="open"'>Delete</button>
</li>
{% if object_list %}
{% for Tasks in object_list %}
{% if Tasks.key.key == "Task" %}
<li>
<span id="{{forloop.counter}}">{{Tasks.key.key}} : {{Tasks.task}} </span>
<a href="{{Tasks.get_absolute_url}}"><button type='button'> Edit </button></a>
<a href="{{Tasks.get_absolute_url}}"><button type='button'> Delete </button></a>
<button type='button' onclick='document.getElementById("{{forloop.counter}}").innerHTML="Task Done"'> Mark as Done </button>
</li>
{% else %}
<li>
{{Tasks.key.key}} : {{Tasks.task}}
<a href="{{Tasks.get_absolute_url}}"><button type='button'> Edit </button></a>
<a href="{{Tasks.get_absolute_url}}"><button type='button'> Delete </button></a>
</li>
{% endif %}
{% endfor %}
{% endif %}
</ul>
<button type='button' onclick='document.getElementById("add").open="open"'>Add Item</button>
<dialog id="add">
<form action='{% url "thisweek" %}' method='post'>
{% csrf_token %}
{{form1}}
<input type="Submit" value="Add Task">
</form>
</dialog>
<dialog id="edit">
<form action='{% url "thisweek" %}' method='post'>
{% csrf_token %}
{{form2}}
<input type="Submit" value="Update">
</form>
</dialog>
<dialog id="delete">
<form action='{% url "thisweek" %}' method='post'>
{% csrf_token %}
{{form}}
<input type="Submit" value="Add Task">
</form>
</dialog>
<a href ="{% url 'addtask' %}"><button type='button'>Add Item</button></a>
{% endblock %}
\ No newline at end of file
{% extends 'base.html' %}
{% load static %}
{% block title %} Keys {% endblock %}
{% block title %} Today {% endblock %}
{% block styles %}
<link rel="stylesheet" href="{% static 'css/styles.css' %}" type='text/css'>
{% endblock %}
{% block content %}
<h1> Today </h1>
<p> 03.30.TUES </p>
<p> ● lab 1 bujo </p>
<p> 04.10 SAT </p>
<ul>
{% if object_list %}
{% for Today in object_list %}
{% if Today.key.key == "Task" %}
<li>
<span id="{{forloop.counter}}">{{Today.key.key}} : {{Today.task}} </span>
<a href="{{Today.get_absolute_url}}"><button type='button'> Edit </button></a>
<a href="{{Today.get_absolute_url}}"><button type='button'> Delete </button></a>
<button type='button' onclick='document.getElementById("{{forloop.counter}}").innerHTML="Task Done"'> Mark as Done </button>
</li>
{% else %}
<li>
{{Today.key.key}} : {{Today.task}}
<a href="{{Today.get_absolute_url}}"><button type='button'> Edit </button></a>
<a href="{{Today.get_absolute_url}}"><button type='button'> Delete </button></a>
</li>
{% endif %}
{% endfor %}
{% endif %}
</ul>
<a href ="{% url 'addtoday' %}"><button type='button'>Add Item</button></a>
{% endblock %}
\ No newline at end of file
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