Commit 8250bfd6 authored by Alec Dayupay's avatar Alec Dayupay

Populated models

parent c6a2efb8
# Generated by Django 3.2 on 2023-05-12 14:47
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
('dashboard', '__first__'),
]
operations = [
migrations.CreateModel(
name='Announcement',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('title', models.CharField(max_length=50)),
('body', models.TextField()),
('pub_datetime', models.DateTimeField(auto_now_add=True)),
('author', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='dashboard.widgetuser')),
],
),
migrations.CreateModel(
name='Reaction',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(choices=[('Like', 'Like'), ('Love', 'Love'), ('Angry', 'Angry')], default='Like', max_length=50)),
('tally', models.IntegerField(default=0)),
('announcement', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='announcements.announcement')),
],
),
]
......@@ -15,9 +15,6 @@ class Announcement(models.Model):
def datetime(self):
return self.pub_datetime.strftime("%m/%d/%Y, %I:%M %p")
def get_absolute_url(self):
return reverse("announcement-details", kwargs={'pk': self.pk})
class Reaction(models.Model):
Like = 'Like'
......
......@@ -10,8 +10,8 @@
<p>{{ object.datetime }}</p>
<p>{{ object.body }}<br></p>
{% for reac in object.reaction_set.all %}
<p>{{ reac.name }}: {{ reac.tally }}</p>
{% for reaction in object.reaction_set.all %}
<p>{{ reaction.name }}: {{ reaction.tally }}</p>
{% endfor %}
<input type="button" value="Edit Announcement" onclick="location.href='{% url 'announcement-edit' object.pk %}'"/>
......
......@@ -7,15 +7,15 @@
{% block content %}
<p>Announcements:</p>
{% for ann in announcements %}
<p><a href="{% url 'announcement-details' ann.pk %}">{{ ann.title }} by {{ ann.author }}</a></p>
{% for object in announcements %}
<p><a href="{{ object.get_absolute_url }}">{{ object.title }} by {{ object.author }}</a></p>
{% endfor %}
<input type="button" value="New Announcement" onclick="location.href='{% url 'announcement-add' %}'"/>
{% endblock %}
{% block links %}
<p><a href="http://localhost:8000/dashboard/">Dashboard</a></p>
<p><a href="http://localhost:8000/forum/">Forum</a></p>
<p><a href="http://localhost:8000/assignments/">Assignment</a></p>
<p><a href="http://localhost:8000/calendar/">Calendar</a></p>
<p><a href="/dashboard/">Dashboard</a></p>
<p><a href="/forum/">Forum</a></p>
<p><a href="/assignments/">Assignments</a></p>
<p><a href="/calendar/">Calendar</a></p>
{% endblock %}
\ No newline at end of file
from django.urls import path
from . import views
from .views import (AnnouncementDetailView, AnnouncementCreateView, AnnouncementUpdateView)
from .views import (announcements, AnnouncementDetailView, AnnouncementCreateView, AnnouncementUpdateView)
urlpatterns = [
path('', views.index, name='index'),
path('', announcements, name='announcements'),
path('announcements/<int:pk>/details/', AnnouncementDetailView.as_view(), name="announcement-details"),
path('announcements/add/', AnnouncementCreateView.as_view(), name="announcement-add"),
path('announcements/<int:pk>/edit/', AnnouncementUpdateView.as_view(), name="announcement-edit"),
......
......@@ -3,7 +3,7 @@ from django.views.generic.detail import DetailView
from django.views.generic.edit import CreateView, UpdateView
from .models import Announcement
def index(request):
def announcements(request):
return render(request, 'announcements/announcements.html', {'announcements': Announcement.objects.order_by('-pub_datetime')})
class AnnouncementDetailView(DetailView):
......
# Generated by Django 3.2 on 2023-05-12 14:47
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Course',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('code', models.CharField(max_length=10)),
('title', models.CharField(max_length=50)),
('section', models.CharField(max_length=3)),
],
),
migrations.CreateModel(
name='Assignment',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=50)),
('description', models.TextField()),
('perfect_score', models.IntegerField(default=0)),
('passing_score', models.IntegerField(default=0)),
('course', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='assignments.course')),
],
),
]
......@@ -6,16 +6,15 @@
{% block heading %}Welcome to Widget's Assignments!{% endblock %}
{% block content %}
<p>Assignments posts:</p>
{% for assignment in assignments%}
<p><a href="{{assignment.get_absolute_url}}">{{ assignment.name }}</a></p>
{% endfor %}
<input type="button" value="New Assignment" onclick="location.href='{% url 'assignment-add' %}'"/>
{% for object in assignments%}
<p><a href="{{ object.get_absolute_url }}">{{ object.name }}</a></p>
{% endfor %}
<input type="button" value="New Assignment" onclick="location.href='{% url 'assignment-add' %}'"/>
{% endblock %}
{% block links %}
<p><a href="http://localhost:8000/dashboard/">Dashboard</a></p>
<p><a href="http://localhost:8000/announcements/">Announcement</a></p>
<p><a href="http://localhost:8000/forum/">Forum</a></p>
<p><a href="http://localhost:8000/calendar/">Calendar</a></p>
<p><a href="/dashboard/">Dashboard</a></p>
<p><a href="/announcements/">Announcements</a></p>
<p><a href="/forum/">Forum</a></p>
<p><a href="/calendar/">Calendar</a></p>
{% endblock %}
\ No newline at end of file
from django.urls import path
from .import views
from .views import (AssignmentDetailView, AssignmentCreateView, AssignmentUpdateView)
from .views import (assignments, AssignmentDetailView, AssignmentCreateView, AssignmentUpdateView)
urlpatterns = [
path('', views.assignments, name="assignments"),
path('', assignments, name="assignments"),
path('assignments/<int:pk>/details/', AssignmentDetailView.as_view(), name="assignment-details"),
path('assignment/add/', AssignmentCreateView.as_view(), name="assignment-add"),
path('assignments/<int:pk>/edit/', AssignmentUpdateView.as_view(), name="assignment-edit"),
......
# Generated by Django 3.2 on 2023-05-12 14:47
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
('assignments', '0001_initial'),
]
operations = [
migrations.CreateModel(
name='Location',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('modes', models.CharField(choices=[('Onsite', 'Onsite'), ('Online', 'Online'), ('Hybrid', 'Hybrid')], default='Onsite', max_length=50)),
('venue', models.CharField(max_length=50)),
],
),
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.CharField(max_length=50)),
('estimated_hours', models.FloatField(default=0)),
('course', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='assignments.course')),
('locations', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='calendars.location')),
],
),
]
......@@ -14,11 +14,11 @@ class Location(models.Model):
venue = models.CharField(max_length = 50)
def __str__(self):
return self.venue
return self.modes + " - " + self.venue
class Event(models.Model):
target_datetime = models.DateTimeField()
activity = models.CharField(max_length = 50)
target_datetime = models.DateTimeField()
estimated_hours = models.FloatField(default=0)
locations = models.ForeignKey(Location, on_delete=models.CASCADE)
course = models.ForeignKey('assignments.Course', on_delete=models.CASCADE)
......@@ -26,5 +26,8 @@ class Event(models.Model):
def __str__(self):
return self.activity
def datetime(self):
return self.target_datetime.strftime("%m/%d/%Y, %I:%M %p")
def get_absolute_url(self):
return reverse("event-details", kwargs={'pk': self.pk})
\ No newline at end of file
......@@ -6,15 +6,15 @@
{% block heading %}Widget's Calendar of Activities{% endblock %}
{% block content %}
{% for event in event %}
<p><a href="{% url 'event-details' event.pk %}">{{ event.activity }}</a></p>
{% for object in events %}
<p><a href="{{ object.get_absolute_url }}">{{ object.activity }}</a></p>
{% endfor %}
<input type="button" value="New Activity" onclick="location.href='{% url 'event-add' %}'"/>
{% endblock %}
{% block links %}
<p><a href="http://localhost:8000/dashboard/">Dashboard</a></p>
<p><a href="http://localhost:8000/announcements/">Announcement</a></p>
<p><a href="http://localhost:8000/assignments/">Assignment</a></p>
<p><a href="http://localhost:8000/calendar/">Calendar</a></p>
<p><a href="/dashboard/">Dashboard</a></p>
<p><a href="/announcements/">Announcements</a></p>
<p><a href="/forum/">Forum</a></p>
<p><a href="/assignments/">Assignments</a></p>
{% endblock %}
......@@ -3,14 +3,14 @@
{% block title %}{{ object.activity }}{% endblock %}
{% block heading %}{{ object.activty }}{% endblock %}
{% block heading %}{{ object.activity }}{% endblock %}
{% block content %}
<p>Date and Time: {{ object.target_datetime }}</p>
<p>Date and Time: {{ object.datetime }}</p>
<p>Estimated Hours: {{ object.estimated_hours }}</p>
<p>{{ object.course }}</p>
<p>Mode: {{ object.locations.modes }}</p>
<p>Venue: {{ object.locations.venue }}</p>
<input type="button" value="Edit Post" onclick="location.href='{% url 'event-edit' object.pk %}'"/>
<input type="button" value="Edit Activity" onclick="location.href='{% url 'event-edit' object.pk %}'"/>
{% endblock %}
from django.urls import path
from . import views
from .views import EventDetailView, EventCreateView, EventUpdateView
from .views import (calendar, EventDetailView, EventCreateView, EventUpdateView)
urlpatterns = [
path('', views.calendar, name = "calendar"),
path('', calendar, name = "calendar"),
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"),
......
......@@ -4,7 +4,7 @@ from django.views.generic.edit import CreateView, UpdateView
from .models import Event
def calendar(request):
return render(request, 'calendars/calendar.html', {'event': Event.objects.all()})
return render(request, 'calendars/calendar.html', {'events': Event.objects.all()})
class EventDetailView(DetailView):
model = Event
......
from django.forms import ModelForm
from .models import WidgetUser
class WidgetUserForm(ModelForm):
class Meta:
model = WidgetUser
fields = '__all__'
\ No newline at end of file
# Generated by Django 3.2 on 2023-05-12 14:47
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=50)),
('home_unit', models.CharField(max_length=50)),
],
),
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=50)),
('middle_name', models.CharField(max_length=50)),
('last_name', models.CharField(max_length=50)),
('department', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='dashboard.department')),
],
),
]
{% extends 'base.html' %}
{% load static %}
{% block title %}Widget's Forum{% endblock %}
{% block title %}Widget v2{% endblock %}
{% block heading %}Welcome to Widget's Forum!{% endblock %}
{% block heading %}Welcome to Widget!{% endblock %}
{% block content %}
<p>Forum posts:</p>
{% for user in WidgetUser %}
<p><a href="{{ user.get_absolute_url }}">{{ user.last_name }}, {{ user.first_name }}</a></p>
<p>Widget Users:</p>
{% for object in widgetusers %}
<p><a href="{{ object.get_absolute_url }}">{{ object.last_name }}, {{ object.first_name }}</a></p>
{% endfor %}
<input type="button" value="Add Widget User" onclick="location.href='{% url 'widgetuser-add' %}'"/>
{% endblock %}
{% block links %}
<p><a href="../announcements/">Announcement</a></p>
<p><a href="../forum/">Forum</a></p>
<p><a href="../assignments/">Assignment</a></p>
<p><a href="../calendar/">Calendar</a></p>
<p><a href="/announcements/">Announcement Board</a></p>
<p><a href="/forum/">Forum</a></p>
<p><a href="/assignments/">Assignments</a></p>
<p><a href="/calendar/">Calendar</a></p>
{% endblock %}
\ No newline at end of file
......@@ -4,6 +4,7 @@
{% block title %}Add Widget User{% endblock %}
{% block heading %}Add a new widget user:{% endblock %}
{% block content %}
<form method="POST">
{% csrf_token %}
......
from django.urls import path
from .views import (
dashboard, WidgetuserDetailView, WidgetuserCreateView, WidgetuserUpdateView
)
from .views import (dashboard, WidgetuserDetailView, WidgetuserCreateView, WidgetuserUpdateView)
urlpatterns = [
path('', dashboard, name="dashboard"),
......
from django.shortcuts import render
from django.http import HttpResponse
from django.views.generic.detail import DetailView
from django.views.generic.edit import CreateView, UpdateView
from .models import Department, WidgetUser
from .models import WidgetUser
def dashboard(request):
return render(request, 'dashboard/dashboard.html', {'WidgetUser': WidgetUser.objects.all()})
return render(request, 'dashboard/dashboard.html', {'widgetusers': WidgetUser.objects.all()})
class WidgetuserDetailView(DetailView):
model = WidgetUser
template_name ='dashboard/widgetuser-details.html'
fields = '__all__'
class WidgetuserCreateView(CreateView):
model = WidgetUser
fields = '__all__'
template_name ='dashboard/widgetuser-add.html'
class WidgetuserUpdateView(UpdateView):
model = WidgetUser
fields = '__all__'
......
from django.contrib import admin
from .models import ForumPost, Reply
class ReplyInline(admin.TabularInline):
model = Reply
class ForumPostAdmin(admin.ModelAdmin):
model = ForumPost
list_display = ("title", "body", "author", "pub_datetime",)
search_field = ("title", "body", "author", "pub_datetime",)
inlines = [ReplyInline]
class ReplyAdmin(admin.ModelAdmin):
model = Reply
......
# Generated by Django 3.2 on 2023-05-12 14:47
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
('dashboard', '0001_initial'),
]
operations = [
migrations.CreateModel(
name='ForumPost',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('title', models.CharField(max_length=50)),
('body', models.TextField()),
('pub_datetime', models.DateTimeField(auto_now_add=True)),
('author', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='dashboard.widgetuser')),
],
),
migrations.CreateModel(
name='Reply',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('body', models.TextField()),
('pub_datetime', models.DateTimeField(auto_now_add=True)),
('author', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='dashboard.widgetuser')),
('forum_post', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='forum.forumpost')),
],
),
]
......@@ -7,15 +7,15 @@
{% block content %}
<p>Forum posts:</p>
{% for post in forumposts %}
<p><a href="{% url 'forumpost-details' post.pk %}">{{ post.title }} by {{ post.author }}</a></p>
{% for object in forumposts %}
<p><a href="{{ object.get_absolute_url }}">{{ object.title }} by {{ object.author }}</a></p>
{% endfor %}
<input type="button" value="New Post" onclick="location.href='{% url 'forumpost-add' %}'"/>
{% endblock %}
{% block links %}
<p><a href="http://localhost:8000/dashboard/">Dashboard</a></p>
<p><a href="http://localhost:8000/announcements/">Announcement</a></p>
<p><a href="http://localhost:8000/assignments/">Assignment</a></p>
<p><a href="http://localhost:8000/calendar/">Calendar</a></p>
<p><a href="/dashboard/">Dashboard</a></p>
<p><a href="/announcements/">Announcements</a></p>
<p><a href="/assignments/">Assignments</a></p>
<p><a href="/calendar/">Calendar</a></p>
{% endblock %}
\ No newline at end of file
from django.urls import path
from . import views
from .views import (ForumPostDetailView, ForumPostCreateView, ForumPostUpdateView)
from .views import (forum, ForumPostDetailView, ForumPostCreateView, ForumPostUpdateView)
urlpatterns = [
path('', views.forum, name="forum"),
path('', forum, name="forum"),
path('forumposts/<int:pk>/details/', ForumPostDetailView.as_view(), name="forumpost-details"),
path('forumposts/add/', ForumPostCreateView.as_view(), name="forumpost-add"),
path('forumposts/<int:pk>/edit/', ForumPostUpdateView.as_view(), name="forumpost-edit"),
......
......@@ -16,8 +16,4 @@
{% block links %}{% endblock %}
</div>
</body>
<<<<<<< HEAD
</html>
=======
</html>
>>>>>>> f677ebe22bd65d5a5b7defd80f65be44b8893457
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