Commit 645c4ad1 authored by Jose Luis Bautista's avatar Jose Luis Bautista

Added this week functionality

parent cadfeb2b
...@@ -25,8 +25,10 @@ class key(forms.ModelForm): ...@@ -25,8 +25,10 @@ class key(forms.ModelForm):
model = key_model model = key_model
fields = ['keyName','keyDesc'] fields = ['keyName','keyDesc']
class this_week(forms.Form): class this_week(forms.ModelForm):
name = forms.CharField(label='', max_length = 25) class Meta:
model = thisWeek_model
fields = ['keyModel', 'thisWeekDesc']
class today(forms.ModelForm): class today(forms.ModelForm):
class Meta: class Meta:
......
# Generated by Django 3.1.8 on 2021-04-09 05:04
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('BauDB', '0009_auto_20210408_1514'),
]
operations = [
migrations.CreateModel(
name='thisWeek_model',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('thisWeekDesc', models.CharField(max_length=100)),
('keyModel', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='BauDB.key_model')),
],
),
]
# Generated by Django 3.1.8 on 2021-04-09 05:24
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('BauDB', '0010_thisweek_model'),
]
operations = [
migrations.AlterField(
model_name='profile_model',
name='profileBio',
field=models.TextField(),
),
]
...@@ -11,7 +11,7 @@ class key_model(models.Model): ...@@ -11,7 +11,7 @@ class key_model(models.Model):
class profile_model(models.Model): class profile_model(models.Model):
profileName = models.CharField(max_length = 25) profileName = models.CharField(max_length = 25)
profileBio = models.CharField(max_length = 25) profileBio = models.TextField()
profileImage = models.ImageField(upload_to ='images/', null = True) profileImage = models.ImageField(upload_to ='images/', null = True)
class today_model(models.Model): class today_model(models.Model):
...@@ -28,5 +28,15 @@ class today_model(models.Model): ...@@ -28,5 +28,15 @@ class today_model(models.Model):
return reverse('today_done', args = [str(self.id)]) return reverse('today_done', args = [str(self.id)])
# def deltwtask(self): class thisWeek_model(models.Model):
# return reverse('deletetwtask', args=[str(self.id)]) keyModel = models.ForeignKey(key_model, on_delete = models.CASCADE)
thisWeekDesc = models.CharField(max_length=100)
def thisWeek_edit(self):
return reverse('new_thisWeek_update', args = [str(self.id)])
def thisWeek_delete(self):
return reverse('thisWeek_delete', args = [str(self.id)])
def thisWeek_done(self):
return reverse('thisWeek_done', args = [str(self.id)])
\ No newline at end of file
...@@ -27,14 +27,18 @@ urlpatterns = [ ...@@ -27,14 +27,18 @@ urlpatterns = [
path('home/', page_home, name = 'home'), path('home/', page_home, name = 'home'),
path('profile/', ProfileDetailView.as_view(), name = 'profile'), path('profile/', ProfileDetailView.as_view(), name = 'profile'),
path('key/', KeyListView.as_view(), name = 'key'), path('key/', KeyListView.as_view(), name = 'key'),
path('this_week/', page_this_week, name = 'this_week'), path('this_week/', thisWeekListView.as_view(), name = 'this_week'),
path('today/', TodayListView.as_view(), name = 'today'), path('today/', TodayListView.as_view(), name = 'today'),
path('new_key/', new_key, name = 'new_key'), path('new_key/', new_key, name = 'new_key'),
path('new_today/', new_today, name = 'new_today'), path('new_today/', new_today, name = 'new_today'),
path('new_thisWeek/', new_thisWeek, name ='new_thisWeek'),
path('new_name/',ProfileNameView.as_view(), name = 'new_name'), path('new_name/',ProfileNameView.as_view(), name = 'new_name'),
path('new_bio/',ProfileBioView.as_view(), name = 'new_bio'), path('new_bio/',ProfileBioView.as_view(), name = 'new_bio'),
path('new_image/',ProfileImageView.as_view(), name = 'new_image'), path('new_image/',ProfileImageView.as_view(), name = 'new_image'),
path('new_today_update/<int:pk>/',TodayUpdateView.as_view(), name = 'new_today_update'), path('new_today_update/<int:pk>/',TodayUpdateView.as_view(), name = 'new_today_update'),
path('today_delete/<int:pk>/',TodayDeleteView.as_view(), name = 'today_delete'), path('today_delete/<int:pk>/',TodayDeleteView.as_view(), name = 'today_delete'),
path('today_done/<int:pk>/',page_today_done, name = 'today_done'), path('today_done/<int:pk>/',page_today_done, name = 'today_done'),
path('new_thisWeek_update/<int:pk>/',thisWeekUpdateView.as_view(), name = 'new_thisWeek_update'),
path('thisWeek_delete/<int:pk>/',thisWeekDeleteView.as_view(), name = 'thisWeek_delete'),
path('thisWeek_done/<int:pk>/',page_thisWeek_done, name = 'thisWeek_done'),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
...@@ -42,6 +42,15 @@ def new_today(request): ...@@ -42,6 +42,15 @@ def new_today(request):
return redirect('today') return redirect('today')
return render(request,'update.html', {'form' : form}) return render(request,'update.html', {'form' : form})
def new_thisWeek(request):
form = this_week()
if request.method == 'POST':
form = this_week(request.POST)
if form.is_valid():
form.save()
return redirect('this_week')
return render(request,'update.html', {'form' : form})
def new_key(request): def new_key(request):
form = key() form = key()
if request.method == 'POST': if request.method == 'POST':
...@@ -51,13 +60,17 @@ def new_key(request): ...@@ -51,13 +60,17 @@ def new_key(request):
return redirect('key') return redirect('key')
return render(request,'update.html', {'form' : form}) return render(request,'update.html', {'form' : form})
def page_today_done(request,pk): def page_today_done(request,pk):
done = today_model.objects.get(id = pk) done = today_model.objects.get(id = pk)
done.keyModel = key_model.objects.get(id = 30) done.keyModel = key_model.objects.get(id = 30)
done.save() done.save()
return redirect('today') return redirect('today')
def page_thisWeek_done(request,pk):
done = thisWeek_model.objects.get(id = pk)
done.keyModel = key_model.objects.get(id = 30)
done.save()
return redirect('this_week')
def page_today(request): def page_today(request):
...@@ -129,4 +142,23 @@ class TodayDeleteView(DeleteView): ...@@ -129,4 +142,23 @@ class TodayDeleteView(DeleteView):
def get_success_url(self): def get_success_url(self):
return reverse('today') return reverse('today')
################
class thisWeekListView(ListView):
model = thisWeek_model
template_name = 'this_week.html'
class thisWeekUpdateView(UpdateView):
model = thisWeek_model
template_name = 'update.html'
form_class = this_week
def get_success_url(self):
return reverse('this_week')
class thisWeekDeleteView(DeleteView):
model = thisWeek_model
template_name = 'delete2.html'
form_class = this_week
def get_success_url(self):
return reverse('this_week')
<form action = '' method = "POST" enctype="multipart/form-data">
{% csrf_token %}
{{ form }}
<input type="submit" name="submit" id = "submit" value = "Input">
</form>
<a href = "{% url 'this_week' %}"><button>Don't Input</button></a>
\ No newline at end of file
...@@ -8,11 +8,29 @@ ...@@ -8,11 +8,29 @@
<h1> 3.22.MON - 3.28.SUN </h1> <h1> 3.22.MON - 3.28.SUN </h1>
<h3> • Maglinis ng bahay </h3> {% for x in object_list %}
<h3> • Bolpen ni kapatid </h3>
<h3> • Charger wag kalimutan</h3> {% if x.keyModel.keyName == '• Task' %}
<h3> - Mura lugaw dun sa may kanto malapit sa trike station </h3>
<h3> O (26) Date with bebe (whole day) </h3> {{x.keyModel.keyName}} : {{x.thisWeekDesc}} ||
<h3> O (28) Ride with the boys pa MOA (whole day) </h3> <a href = "{{ x.thisWeek_edit }}"><button>Edit</button></a>
<a href = "{{ x.thisWeek_delete }}"><button>Delete</button></a>
<a href = "{{ x.thisWeek_done }}"><button>Mark as Done</button></a>
<br>
{% else %}
{{x.keyModel.keyName}} : {{x.thisWeekDesc}} ||
<a href = "{{ x.thisWeek_edit }}"><button>Edit</button></a>
<a href = "{{ x.thisWeek_delete }}"><button>Delete</button></a>
<br>
{% endif %}
{% endfor %}
<br>
<a href = "{% url 'new_thisWeek' %}"><button>Add Item</button></a>
{% endblock %} {% 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