Commit fd895893 authored by Albert Gagalac's avatar Albert Gagalac

Merged branch main into Assignments

parents 6e6c8657 a3790519
...@@ -2,9 +2,9 @@ CSCI 40 - E ...@@ -2,9 +2,9 @@ CSCI 40 - E
Arpas, Matthew Karl David, P. - 210493 Arpas, Matthew Karl David, P. - 210493
Cruz, Calvin Josh, G. - 211677 Cruz, Calvin Josh, G. - 211677
Gagalac, Albert, - Gagalac, Albert Emmanuel, B. - 192102
Lopez, Michael T. II – 213546 Lopez, Michael, T. II – 213546
Oarde, Carlos Gabriel, - Oarde, Carlos Gabriel, R. - 214279
Midterm Project: Widget v1 Midterm Project: Widget v1
...@@ -18,10 +18,14 @@ Calendar - Matt ...@@ -18,10 +18,14 @@ Calendar - Matt
Date of Submission: March 06, 2023 Date of Submission: March 06, 2023
The project was truthfully completed by the five of us in the appropriate specifications and with the proper workflow in git. The project was truthfully completed by the five of us in the appropriate specifications and with the proper workflow in Git and Gitlab.
References: References:
--------- https://docs.djangoproject.com/en/4.1/ref/models/fields/#choices
(sgd) Matthew Karl David P. Arpas - 3/4/2023 (sgd) Matthew Karl David P. Arpas - 3/4/2023
(sgd) Cruz, Calvin Josh, G. - 3/4/2023
(sgd) Gagalac, Albert Emmanuel, B. - 3/4/2023
(sgd) Lopez, Michael, T. II - 3/4/2023
(sgd) Oarde, Carlos Gabriel, R. - 3/4/2023
\ No newline at end of file
from django.contrib import admin from django.contrib import admin
from .models import Department, WidgetUser
# Register your models here. class DepartmentAdmin(admin.ModelAdmin):
model = Department
class WidgetUserAdmin(admin.ModelAdmin):
model = WidgetUser
admin.site.register(Department, DepartmentAdmin)
admin.site.register(WidgetUser, WidgetUserAdmin)
\ No newline at end of file
# Generated by Django 4.1.7 on 2023-03-04 07:48
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Department',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('dept_name', models.CharField(max_length=300)),
('home_unit', models.CharField(max_length=300)),
],
),
migrations.CreateModel(
name='WidgetUser',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('first_name', models.CharField(max_length=300)),
('middle_name', models.CharField(max_length=300)),
('last_name', models.CharField(max_length=300)),
('department', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='dashboard.department')),
],
),
]
from django.db import models from django.db import models
# Create your models here. # Create your models here.
class Department(models.Model):
dept_name = models.CharField(max_length=300)
home_unit = models.CharField(max_length=300)
def __str__(self):
return self.dept_name
class WidgetUser(models.Model):
first_name = models.CharField(max_length=300)
middle_name = models.CharField(max_length=300)
last_name = models.CharField(max_length=300)
department = models.ForeignKey(Department, on_delete=models.CASCADE)
def __str__(self):
return '{} {} {}'.format(self.first_name, self.middle_name, self.last_name)
\ No newline at end of file
<p>Welcome to Widget!</p>
<p>WIDGET USERS:<br>
{% for user in widgetusers %}
{{user.last_name}}, {{user.first_name}} {{user.middle_name}}: {{user.department.dept_name}}, {{user.department.home_unit}}<br>
{% endfor %}
from django.shortcuts import render from django.shortcuts import render
from django.http import HttpResponse from .models import Department, WidgetUser
def pageview(request): def pageview(request):
return HttpResponse() departments = Department.objects.all()
widgetusers = WidgetUser.objects.all()
return render(request, 'dashboard/dashboard.html', {'departments': departments, 'widgetusers': widgetusers})
from django.contrib import admin from django.contrib import admin
from .models import Event, Location
# Register your models here. class EventAdmin(admin.ModelAdmin):
model = Event
class LocationAdmin(admin.ModelAdmin):
model = Location
admin.site.register(Event, EventAdmin)
admin.site.register(Location, LocationAdmin)
\ No newline at end of file
# Generated by Django 4.1.6 on 2023-03-04 15:07
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Location',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('mode', models.CharField(choices=[('onsite', 'onsite'), ('online', 'online'), ('hybrid', 'hybrid')], default='onsite', max_length=6)),
('venue', models.TextField()),
],
),
migrations.CreateModel(
name='Event',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('target_datetime', models.DateTimeField()),
('activity', models.TextField(max_length=300)),
('estimated_hours', models.FloatField()),
('course', models.CharField(max_length=150)),
('location', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='widget_calendar.location')),
],
),
]
# Generated by Django 4.1.6 on 2023-03-04 17:46
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('widget_calendar', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='event',
name='target_datetime',
field=models.CharField(max_length=50),
),
]
from django.db import models from django.db import models
# Create your models here. class Location(models.Model):
modechoices = [
('onsite', 'onsite'),
('online', 'online'),
('hybrid', 'hybrid')
]
mode = models.CharField(
max_length=6,
choices=modechoices,
default='onsite'
)
venue = models.TextField()
def __str__(self):
return '{}, {}'.format(self.mode, self.venue)
class Event(models.Model):
target_datetime = models.CharField(max_length=50)
activity = models.TextField(max_length=300)
estimated_hours = models.FloatField()
location = models.ForeignKey(Location, on_delete=models.CASCADE)
course = models.CharField(max_length=150)
def __str__(self):
return self.activity
\ No newline at end of file
<p>Widget's Calendar of Activities<br><br></p>
{% for event in events %}
<p>
Date and Time: {{ event.target_datetime }}<br>
Activity: {{ event.activity }}<br>
Estimated Hours: {{ event.estimated_hours }}<br>
Course/Section: {{ event.course }}<br>
Mode: {{ event.location.mode }}<br>
Venue: {{ event.location.venue }}
</p>
{% endfor %}
from django.shortcuts import render from django.shortcuts import render
from django.http import HttpResponse from .models import Event, Location
def pageview(request): def pageview(request):
return HttpResponse() events = Event.objects.all()
locations = Location.objects.all()
return render(request, 'widget_calendar/widget_calendar.html', {'events': events, 'locations': locations})
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