Commit 2683261d authored by Andrew Justin C. Idquival's avatar Andrew Justin C. Idquival

Merge branch 'calendarv2'

parents 7ad0b235 7c5cbbd5
# Generated by Django 3.2 on 2023-05-12 05:00 # Generated by Django 3.2 on 2023-05-12 05:00
from django.db import migrations, models from django.db import migrations, models
......
# Generated by Django 3.2 on 2023-03-06 13:35 # Generated by Django 3.2 on 2023-05-13 03:22
import datetime import datetime
from django.db import migrations, models from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration): class Migration(migrations.Migration):
dependencies = [ dependencies = [
('widget_calendar', '0001_initial'), ('forum', '0002_reply_post'),
] ]
operations = [ operations = [
migrations.AlterField( migrations.AlterField(
model_name='event', model_name='forumpost',
name='target_datetime', name='pub_datetime',
field=models.DateTimeField(default=datetime.datetime(2023, 3, 6, 21, 35, 57, 125720)), field=models.DateTimeField(default=datetime.datetime(2023, 5, 13, 11, 22, 5, 434143), editable=False),
),
migrations.AlterField(
model_name='reply',
name='post',
field=models.ForeignKey(default=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='replies', to='forum.forumpost'),
), ),
] ]
# Generated by Django 3.2 on 2023-03-06 13:34 # Generated by Django 3.2 on 2023-05-13 03:22
import datetime import datetime
from django.db import migrations, models from django.db import migrations, models
...@@ -10,7 +10,7 @@ class Migration(migrations.Migration): ...@@ -10,7 +10,7 @@ class Migration(migrations.Migration):
initial = True initial = True
dependencies = [ dependencies = [
('assignments', '0002_alter_course_course_code'), ('assignments', '0004_alter_assignment_assignment_name'),
] ]
operations = [ operations = [
...@@ -26,11 +26,11 @@ class Migration(migrations.Migration): ...@@ -26,11 +26,11 @@ class Migration(migrations.Migration):
name='Event', name='Event',
fields=[ fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('target_datetime', models.DateTimeField(default=datetime.datetime(2023, 3, 6, 21, 34, 56, 441115))), ('target_datetime', models.DateTimeField(default=datetime.datetime(2023, 5, 13, 11, 22, 5, 435155))),
('activity', models.CharField(default='', max_length=100)), ('activity', models.CharField(default='', max_length=100)),
('estimated_hours', models.FloatField(default=0)), ('estimated_hours', models.FloatField(default=0)),
('course', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='assignments.course')), ('course', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='assignments.course')),
('location', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='Venue', to='widget_calendar.location')), ('location', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='venues', to='widget_calendar.location')),
], ],
), ),
] ]
# Generated by Django 3.2 on 2023-03-06 13:36
import datetime
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('widget_calendar', '0002_alter_event_target_datetime'),
]
operations = [
migrations.AlterField(
model_name='event',
name='target_datetime',
field=models.DateTimeField(default=datetime.datetime(2023, 3, 6, 21, 36, 3, 571433)),
),
]
# Generated by Django 3.2 on 2023-03-06 13:36
import datetime
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('widget_calendar', '0003_alter_event_target_datetime'),
]
operations = [
migrations.AlterField(
model_name='event',
name='target_datetime',
field=models.DateTimeField(default=datetime.datetime(2023, 3, 6, 21, 36, 8, 203438)),
),
]
# Generated by Django 3.2 on 2023-03-06 13:36
import datetime
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('widget_calendar', '0004_alter_event_target_datetime'),
]
operations = [
migrations.AlterField(
model_name='event',
name='target_datetime',
field=models.DateTimeField(default=datetime.datetime(2023, 3, 6, 21, 36, 15, 496092)),
),
]
# Generated by Django 3.2 on 2023-03-06 13:36
import datetime
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('widget_calendar', '0005_alter_event_target_datetime'),
]
operations = [
migrations.AlterField(
model_name='event',
name='target_datetime',
field=models.DateTimeField(default=datetime.datetime(2023, 3, 6, 21, 36, 18, 142763)),
),
]
# Generated by Django 3.2 on 2023-04-29 07:07
import datetime
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('widget_calendar', '0006_alter_event_target_datetime'),
]
operations = [
migrations.AlterField(
model_name='event',
name='target_datetime',
field=models.DateTimeField(default=datetime.datetime(2023, 4, 29, 15, 7, 16, 727183)),
),
]
# Generated by Django 3.2 on 2023-04-29 09:12
import datetime
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('widget_calendar', '0007_alter_event_target_datetime'),
]
operations = [
migrations.AlterField(
model_name='event',
name='target_datetime',
field=models.DateTimeField(default=datetime.datetime(2023, 4, 29, 17, 12, 10, 865421)),
),
]
from django.db import models from django.db import models
from django.urls import reverse
from datetime import datetime from datetime import datetime
from assignments.models import Course from assignments.models import Course
...@@ -23,8 +23,11 @@ class Event(models.Model): ...@@ -23,8 +23,11 @@ class Event(models.Model):
location = models.ForeignKey( location = models.ForeignKey(
Location, Location,
on_delete=models.CASCADE, on_delete=models.CASCADE,
related_name='Venue' related_name='venues'
) )
def __str__(self): def __str__(self):
return "{} {} {} {}".format(self.target_datetime, self.activity, self.estimated_hours, self.location) return "{} {} {} {}".format(self.target_datetime, self.activity, self.estimated_hours, self.location)
def get_absolute_url(self):
return reverse('calendar:event-details', kwargs={'pk': self.pk})
{% extends 'base.html' %}
{% load static %}
{% block title %}Widget's Calendar of Activities{% endblock %}
{% block heading %}
<h1 id="header">Widget's Calendar of Activities </h1>
<div class="separator-bar"></div>
{% endblock %}
{% block content %}
<ul>
{% for event in events %}
<li class="object-cell">
<a href="{{ event.get_absolute_url }}">
<span class="object-title">{{ event.activity }} </span> </a>
</li>
{% endfor %}
</ul>
<button onclick="window.location.href='{% url 'calendar:event-add' %}';" class="action-button">
New Activity
</button>
<div id="footer">
<a href="{% url 'dashboard:index' %}">Dashboard</a>
<a href="{% url 'announcementBoard:index' %}">Announcement Board</a>
<a href="{% url 'forum:index' %}">Forum</a>
<a href="{% url 'assignments:homePage' %}">Assignments</a>
</div>
{% endblock %}
\ No newline at end of file
{% extends 'base.html' %}
{% load static %}
{% block title %} Add Activity {% endblock %}
{% block heading %}
<h1 class="subheader"> Add a new activity: </h1>
{% endblock %}
{% block content %}
<form method="post">
{% csrf_token %}
<div class="form-fields"> {{ form.as_p }} </div>
<div class="separator-bar"></div>
<input class="action-button" type="submit" value="Save New Activity">
</form>
{% endblock %}
\ No newline at end of file
{% extends 'base.html' %}
{% load static %}
{% block title %} {{ object.activity }} {% endblock %}
{% block heading %}
<h1 class="subheader"> {{ object.activity }} </h1>
{% endblock %}
{% block content %}
<div class="separator-bar"></div>
<div id="main">
<p class="detail-header"> Target Date & Time: {{ event.target_datetime }} </p>
<p class="detail-header"> Estimated Hours: {{ event.estimated_hours }} </p>
<p class="detail-header"> Course: {{ event.course }} </p>
<p class="detail-header"> Location: {{ event.location }} </p>
</div>
<div class="separator-bar"></div>
<button class="action-button" onclick="window.location.href='{% url 'calendar:event-edit' pk=object.pk %}';">
Edit Activity
</button>
{% endblock %}
\ No newline at end of file
{% extends 'base.html' %}
{% load static %}
{% block title %} Edit Activity {% endblock %}
{% block heading %}
<h1 class="subheader"> Edit Activity: </h1>
{% endblock %}
{% block content %}
<form method="post">
{% csrf_token %}
{{ form.as_p }}
<div class="separator-bar"></div>
<input type="submit" value="Save New Activity" class="action-button">
</form>
{% endblock %}
\ No newline at end of file
from django.urls import path from django.urls import path
from .views import index from .views import index, EventDetailView, EventCreateView, EventUpdateView
urlpatterns = [ urlpatterns = [
path('', index, name='index'), path('', index, name='index'),
path('events/<int:pk>/details', EventDetailView.as_view(), name='event-details'),
path('events/add', EventCreateView.as_view(), name='event-add'),
path('events/<int:pk>/edit', EventUpdateView.as_view(), name='event-edit'),
] ]
app_name = "widget_calendar" app_name = "calendar"
from django.shortcuts import render from django.shortcuts import render
from django.http import HttpResponse from django.http import HttpResponse
from django.views.generic.detail import DetailView
from django.views.generic.edit import CreateView, UpdateView
from .models import Event, Location from .models import Event, Location
def index(request): def index(request):
events = Event.objects.all()
return render(request, 'calendar/calendar.html',
{'events': events, })
head = "<h1 style='border-bottom:4px solid lightgray;\
padding-bottom:30px;\ class EventDetailView(DetailView):
font-size:500%;'>\ model = Event
Widget’s Calendar of Activities\ template_name = 'calendar/event-details.html'
</h1>"
body = "" class EventCreateView(CreateView):
model = Event
for event in Event.objects.all(): template_name = 'calendar/event-add.html'
location = event.location fields = ["activity", "target_datetime", "estimated_hours", "location", "course"]
datetime = str(event.target_datetime)
estimated_hours = str(event.estimated_hours)
body += "<p style='border: 2px solid gray;\ class EventUpdateView(UpdateView):
border-radius:5px;\ model = Event
padding:20px 30px;'>\ template_name = 'calendar/event-edit.html'
Date and Time: "+datetime+" <br>\ fields = '__all__'
Activity: "+event.activity+" <br>\
Estimated Hours: "+estimated_hours+" <br>\
Course/Section: "+event.course.course_title+" <br>\
Mode: "+location.mode+" <br>\
Venue: "+location.venue+" <br>\
</p>"
return_string = "<html>\
<body style = 'font-family:helvetica;\
padding:30px;'>\
{}{}\
</body></html>".format(head, body)
return HttpResponse(return_string)
...@@ -19,7 +19,7 @@ from django.urls import include, path ...@@ -19,7 +19,7 @@ from django.urls import include, path
urlpatterns = [ urlpatterns = [
path('admin/', admin.site.urls), path('admin/', admin.site.urls),
path('', include('dashboard.urls', namespace="dashboard")), path('', include('dashboard.urls', namespace="dashboard")),
path('widget_calendar/', include('widget_calendar.urls', namespace="widget_calendar")), path('calendar/', include('widget_calendar.urls', namespace="widget_calendar")),
path('assignments/', include('assignments.urls', namespace="assignments")), path('assignments/', include('assignments.urls', namespace="assignments")),
path('announcements/', include('announcements.urls', namespace="announcements")), path('announcements/', include('announcements.urls', namespace="announcements")),
path('forum/', include('forum.urls', namespace="forum")), path('forum/', include('forum.urls', namespace="forum")),
......
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