Commit c553ad9c authored by Alec Dayupay's avatar Alec Dayupay

Pulling from gitlab

parents 86d2ff98 f677ebe2
# Generated by Django 4.2.1 on 2023-05-04 04:57
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('announcements', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='announcement',
name='pub_datetime',
field=models.DateTimeField(auto_now_add=True),
),
]
......@@ -5,7 +5,7 @@ class Announcement(models.Model):
title = models.CharField(max_length = 50)
body = models.TextField()
author = models.ForeignKey("dashboard.WidgetUser", on_delete=models.CASCADE)
pub_datetime = models.DateTimeField()
pub_datetime = models.DateTimeField(auto_now_add=True)
def __str__(self):
return self.title
......@@ -13,6 +13,12 @@ class Announcement(models.Model):
def get_absolute_url(self):
return reverse("announcement-details", kwargs={'pk': self.pk})
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'
Love = 'Love'
......
{% extends 'base.html' %}
{% load static %}
{% block title %}Add Annoucement{% endblock %}
{% block title %}Add Announcement{% endblock %}
{% block content %}
<p>Add a new announcement:</p>
<form method="POST">
{% csrf_token %}
{{ form.as_p }}
<input type="Submit" value="Save New Announcement">
<input type="Submit" value="Add Announcement">
</form>
{% endblock %}
\ No newline at end of file
......@@ -8,12 +8,11 @@
{% block content %}
<p>by {{ object.author }}</p>
<p>{{ object.datetime }}</p>
<p>{{ object.body }}</p>
<p>{{ object.body }}<br></p>
<p><br>Reactions:</p>
{% for reac in object.reaction_set.all %}
<p>by {{ reac.name }}: {{ reac.tally }}</p>
<p>{{ reac.name }}: {{ reac.tally }}</p>
{% endfor %}
<input type="button" value="Edit Post" onclick="location.href='{% url 'forumpost-edit' object.pk %}'"/>
<input type="button" value="Edit Announcement" onclick="location.href='{% url 'announcement-edit' object.pk %}'"/>
{% endblock %}
\ No newline at end of file
{% extends 'base.html' %}
{% load static %}
{% block title %}Widget's Forum{% endblock %}
{% block title %}Widget's Announcement Board{% endblock %}
{% block heading %}Welcome to Widget's Forum!{% endblock %}
{% block heading %}Welcome to Widget's Announcement Board!{% endblock %}
{% block content %}
<p>Announcements:</p>
{% for ann in announcements %}
<p><a href="{% url 'announcement-details' ann.pk %}">{{ ann.title }} by {{ ann.author }}</a></p>
{% endfor %}
<input type="button" value="New Post" onclick="location.href='{% url 'announcement-add' %}'"/>
<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/announcements/">Announcement</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>
{% endblock %}
\ No newline at end of file
......@@ -3,7 +3,7 @@ from . import views
from .views import (AnnouncementDetailView, AnnouncementCreateView, AnnouncementUpdateView)
urlpatterns = [
path('', views.announcements, name="announcements"),
path('', views.index, name='index'),
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 announcements(request):
def index(request):
return render(request, 'announcements/announcements.html', {'announcements': Announcement.objects.order_by('-pub_datetime')})
class AnnouncementDetailView(DetailView):
......@@ -18,4 +18,4 @@ class AnnouncementCreateView(CreateView):
class AnnouncementUpdateView(UpdateView):
model = Announcement
fields = '__all__'
template_name = 'announcements/announcement-edit.html'
\ No newline at end of file
template_name = 'announcements/announcement-edit.html'
from django.forms import ModelForm
from .models import Event
class EventForm(ModelForm):
class Meta:
model = Event
fields = "__all__"
\ No newline at end of file
from django.db import models
from django.urls import reverse
class Location(models.Model):
Onsite = 'Onsite'
......@@ -23,4 +24,7 @@ class Event(models.Model):
course = models.ForeignKey('assignments.Course', on_delete=models.CASCADE)
def __str__(self):
return self.activity
\ No newline at end of file
return self.activity
def get_absolute_url(self):
return reverse("event-details", kwargs={'pk': self.pk})
\ No newline at end of file
{% extends 'base.html' %}
{% load static %}
{% block title %}Widget's Calendar of Activities{% endblock %}
{% 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>
{% 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>
{% endblock %}
{% 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 }}
<input type="Submit" value="Save New Activity">
</form>
{% endblock %}
{% extends 'base.html' %}
{% load static %}
{% block title %}{{ object.activity }}{% endblock %}
{% block heading %}{{ object.activty }}{% endblock %}
{% block content %}
<p>Date and Time: {{ object.target_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 %}'"/>
{% 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 }}
<input type="Submit" value="Save New Activity">
</form>
{% endblock %}
from django.urls import path
from . import views
from .views import EventDetailView, EventCreateView, EventUpdateView
urlpatterns = [
path('', views.index, name = "index")
path('', views.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"),
]
\ No newline at end of file
from django.http import HttpResponse
from django.shortcuts import render
from django.views.generic.detail import DetailView
from django.views.generic.edit import CreateView, UpdateView
from .models import Event
def index(request):
events = Event.objects.all()
def calendar(request):
return render(request, 'calendars/calendar.html', {'event': Event.objects.all()})
response ="Widgets's Calendar of Activities<br><br>Date and Time: "
for event in events:
response += "{}<br>Activity: {}<br>Estimated Hours: {}<br>Course/Section: {}<br>Mode: {}<br>Venue: {}<br>".format(
event.target_datetime.strftime("%m/%d/%Y, %I:%M %p"),
event.activity,
str(event.estimated_hours),
event.course,
event.locations.modes,
event.locations.venue
)
class EventDetailView(DetailView):
model = Event
template_name = 'calendars/event-details.html'
return HttpResponse(response)
\ No newline at end of file
class EventCreateView(CreateView):
model = Event
fields = '__all__'
template_name = 'calendars/event-add.html'
class EventUpdateView(UpdateView):
model = Event
fields = '__all__'
template_name = 'calendars/event-edit.html'
\ No newline at end of file
......@@ -15,4 +15,7 @@ class WidgetUser(models.Model):
department = models.ForeignKey(Department, on_delete = models.CASCADE)
def __str__(self):
return '{} {}'.format(self.first_name, self.last_name)
\ No newline at end of file
return '{} {}'.format(self.first_name, self.last_name)
def get_absolute_url(self):
return reverse("widgetuser-details", kwargs={'pk': self.pk})
\ No newline at end of file
{% extends 'base.html' %}
{% load static %}
{% block title %}Widget's Forum{% endblock %}
{% block heading %}Welcome to Widget's Forum!{% 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>
{% 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>
{% endblock %}
\ No newline at end of file
{% extends 'base.html' %}
{% load static %}
{% block title %}Add Widget User{% endblock %}
{% block heading %}Add a new widget user:{% endblock %}
{% block content %}
<form method="POST">
{% csrf_token %}
{{ form.as_p }}
<input type="Submit" value="Add Widget User">
</form>
{% endblock %}
\ No newline at end of file
{% extends 'base.html' %}
{% load static %}
{% block title %}{{ object.last_name }}, {{ object.first_name }}{% endblock %}
{% block heading %}{{ object.first_name }} {{ object.middle_name }} {{ object.last_name }}{% endblock %}
{% block content %}
<p>{{ object.department }}</p>
<p>{{ object.department.home_unit }}</p>
<input type="button" value="Edit Widget User" onclick="location.href='{% url 'widgetuser-edit' object.pk %}'"/>
{% endblock %}
\ No newline at end of file
{% extends 'base.html' %}
{% load static %}
{% block title %}Edit Post{% endblock %}
{% block content %}
<p>Edit Widget User:</p>
<form method="POST">
{% csrf_token %}
{{ form.as_p }}
<input type="Submit" value="Save Changes to Widget User">
</form>
{% endblock %}
\ No newline at end of file
from django.urls import path
from .views import dashboard
from .views import (
dashboard, WidgetuserDetailView, WidgetuserCreateView, WidgetuserUpdateView
)
urlpatterns = [
path('', dashboard, name = "dashboard")
]
app_name = "dashboard"
\ No newline at end of file
path('', dashboard, name="dashboard"),
path('widgetuser/add', WidgetuserCreateView.as_view(), name = "widgetuser-add"),
path('widgetuser/<int:pk>/details/', WidgetuserDetailView.as_view(), name="widgetuser-details"),
path('widgetuser/<int:pk>/edit/', WidgetuserUpdateView.as_view(), name="widgetuser-edit"),
]
\ No newline at end of file
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
def dashboard(request):
widgetusers = WidgetUser.objects.all()
response = "Welcome to Widget!<br><br>WIDGET USERS:<br>"
for user in widgetusers:
response += "{}, {} {}: {}, {}<br>".format(
user.last_name,
user.first_name,
user.middle_name,
user.department,
user.department.home_unit
)
return HttpResponse(response)
\ No newline at end of file
return render(request, 'dashboard/dashboard.html', {'WidgetUser': 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__'
template_name ='dashboard/widgetuser-edit.html'
\ 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