Commit 6c40e867 authored by Deokhyun Lee's avatar Deokhyun Lee

Merge remote-tracking branch 'origin/calendarv2'

parents 90ab54e7 9ddc9801
......@@ -7,10 +7,13 @@ Damalerio, Adrian Lance T. , 211778
Lee, DeokHyun , 195736
Salvador, Jan Enzo C. , 215218
Syquia Luis Augusto A. , 215670
<<<<<<< HEAD
=======
>>>>>>> origin/calendarv2
Midterm Proj: Widget v1
<<<<<<< HEAD
App Assignments:
Lance: Dashboard
Agu: Announcement Board
......@@ -29,6 +32,28 @@ https://stackoverflow.com/questions/3876977/update-git-branches-from-master
https://stackoverflow.com/questions/64208678/hiding-secret-key-in-django-project-on-github-after-uploading-project
https://docs.djangoproject.com/en/4.1/
=======
Final Project: Widget v2
App Assignments:
Lance: Dashboard
Agu: Announcement Board
Enzo: Forum
Deokhyun: Assignments
Jan: Calendar
Date of Submission: May 15, 2023
This project was done only by members of this group. It was done without the aid of others.
We consulted sources provided and online materials.
References:
https://www.geeksforgeeks.org/django-model-data-types-and-fields-list/
https://stackoverflow.com/questions/3876977/update-git-branches-from-master
https://stackoverflow.com/questions/64208678/hiding-secret-key-in-django-project-on-github-after-uploading-project
https://docs.djangoproject.com/en/4.1/
>>>>>>> origin/calendarv2
(sgd) Jan Ericsson O. Ang
(sgd) Adrian Lance T. Damalerio
......
from django import forms
from .models import Event
class AddEventForm(forms.ModelForm):
class Meta:
model = Event
fields = "__all__"
from django.db import models
from assignments.models import Course
from django.urls import reverse
# Location Choices
location_choices = [
......@@ -20,7 +21,11 @@ class Location(models.Model):
# Event
# target_datetime; activity; estimated_hours; location; course
class Event(models.Model):
<<<<<<< HEAD
target_datetime = models.DateTimeField("Date and Time: ", max_length = 50)
=======
target_datetime = models.DateTimeField("Date and Time: ", max_length = 50, )
>>>>>>> origin/calendarv2
activity = models.CharField("Activity: ", max_length = 50)
estimated_hours = models.FloatField("Estimated Hours: ", max_length = 50)
location = models.ForeignKey(Location, on_delete = models.CASCADE)
......@@ -29,4 +34,7 @@ class Event(models.Model):
def __str__(self):
return self.activity
def get_absolute_url(self):
return (reverse('calendar_app:event_details', kwargs={'pk' : self.pk}))
#refernce for location_choices: https://stackoverflow.com/questions/31130706/dropdown-in-django-model
\ No newline at end of file
{% extends 'base.html' %}
{% load static %}
{% block title %}Widget's Calendar of Activities{% endblock %}
{% block content %}
{% block header %}<h1>Widget's Calendar of Activities</h1>{% endblock %}
{% for event in events %}
<a href="{{event.get_absolute_url}}"> {{event.activity}} </a><br>
{% endfor %}
<br>
<form action="events/add">
<button type="submit">New Activity</button>
</form>
<br>
<a href="/dashboard">Dashboard</a><br>
<a href="/announcements">Announcements</a><br>
<a href="/forum">Forum</a><br>
<a href="/assignments">Assignments</a><br>
{% endblock %}
\ No newline at end of file
{% extends 'base.html'%}
{% load static %}
{% block title %}
Add Activity
{% endblock %}
{% block content %}
<p>Add a new activity:</p>
<form method="POST">
{% csrf_token %}
{{ form.as_p }}
<button type="submit">Save New Activity</button>
</form>
{% endblock %}
{% extends 'base.html'%}
{% block title %} {{object.activity}} {% endblock %}
{% block content %}
<h1>{{object.activity}}</h1>
<ul>
Date and Time: {{object.target_datetime|date:'m/d/Y, h:i A'}}<br>
Estimated Hours: {{object.estimated_hours}}<br>
{{object.course.code}} {{object.course.title}} - {{object.course.section}}<br>
Mode: {{object.location.mode}}<br>
Venue: {{object.location.venue}}<br>
</ul>
<form action="./edit">
<button type="submit">Edit Activity</button>
</form>
{% endblock %}
{% extends 'base.html'%}
{% load static %}
{% block title %}
Edit Activity
{% endblock %}
{% block content %}
<p>Edit Activity:</p>
<form method="POST">
{% csrf_token %}
{{ form.as_p }}
<button type="submit">Save New Activity</button>
</form>
{% endblock %}
\ No newline at end of file
......@@ -3,5 +3,9 @@ from . import views
# url for calendar
urlpatterns = [
path('', views.calendarIndex, name='calendarIndex'),
]
\ No newline at end of file
path('', views.calendar_view, name='calendar_app'),
path('events/<int:pk>/details', views.EventDetailView.as_view(), name='event_details'),
path('events/add', views.EventAddListView.as_view(), name="new_event"),
path('events/<int:pk>/edit', views.EventEditView.as_view(), name='update_event'),
]
app_name = "calendar_app"
\ No newline at end of file
from django.http import HttpResponse
from django.shortcuts import render, redirect
from django.views.generic import DetailView, CreateView, UpdateView
from .models import Event, Location
<<<<<<< HEAD
# calendar view from .models
def calendarIndex(request):
title = 'Widget’s Calendar of Activities<br><br>'
=======
# calendar view for FBV implmentation
def calendar_view(request):
>>>>>>> origin/calendarv2
events = Event.objects.all()
return render(request, 'calendar.html', {'events': events})
output_view = ""
for event in events:
date_and_time = "Date and Time: " + event.target_datetime.strftime("%m/%d/%Y, %I:%M %p") + "<br>"
event_activity = "Activity: " + event.activity + "<br>"
estimated_duration = "Estimated Hours: " + str(event.estimated_hours) + "<br>"
course_section = "Course/Section: " + event.course.code + " " + event.course.title + "-" + event.course.section + "<br>"
event_mode = "Mode: " + event.location.mode + "<br>"
event_venue = "Venue: " + event.location.venue + "<br><br>"
#calendar Detail View for CBV Implementation
class EventDetailView(DetailView):
model = Event
template_name = 'event-details.html'
output_view = output_view + date_and_time + event_activity + estimated_duration + course_section + event_mode + event_venue
class EventAddListView(CreateView):
model = Event
template_name = "event-add.html"
fields = "__all__"
# calendar for editing CBV implementation.
class EventEditView(UpdateView):
model = Event
template_name = 'event-edit.html'
fields = "__all__"
return HttpResponse(title + output_view)
\ No newline at end of file
......@@ -10,4 +10,4 @@
{% block content %}{% endblock %}
</div>
</body>
</html>
\ No newline at end of file
</html>
......@@ -62,6 +62,7 @@ STATIC_URL = '/static/'
STATICFILES_DIRS = [BASE_DIR / "static"]
TEMPLATES = [
{
<<<<<<< HEAD
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, 'templates')],
'APP_DIRS': True,
......@@ -71,6 +72,17 @@ TEMPLATES = [
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
=======
"BACKEND": "django.template.backends.django.DjangoTemplates",
'DIRS': [os.path.join(BASE_DIR, 'templates')],
"APP_DIRS": True,
"OPTIONS": {
"context_processors": [
"django.template.context_processors.debug",
"django.template.context_processors.request",
"django.contrib.auth.context_processors.auth",
"django.contrib.messages.context_processors.messages",
>>>>>>> origin/calendarv2
],
},
},
......@@ -120,6 +132,9 @@ USE_I18N = True
USE_TZ = True
USE_L10N = False
DATE_FORMAT = "%m/%d/%Y"
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/4.1/howto/static-files/
......
......@@ -19,7 +19,10 @@ from django.urls import path, include
urlpatterns = [
path("admin/", admin.site.urls),
path("dashboard/", include("dashboard.urls", namespace="dashboard")),
<<<<<<< HEAD
path("widgetusers/", include("dashboard.urls", namespace="widgetusers")),
=======
>>>>>>> origin/calendarv2
path("assignments/", include("assignments.urls")),
path("forum/", include("forum.urls")),
path("calendar/", include("calendar_app.urls")),
......
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