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): ...@@ -5,7 +5,7 @@ class Announcement(models.Model):
title = models.CharField(max_length = 50) title = models.CharField(max_length = 50)
body = models.TextField() body = models.TextField()
author = models.ForeignKey("dashboard.WidgetUser", on_delete=models.CASCADE) author = models.ForeignKey("dashboard.WidgetUser", on_delete=models.CASCADE)
pub_datetime = models.DateTimeField() pub_datetime = models.DateTimeField(auto_now_add=True)
def __str__(self): def __str__(self):
return self.title return self.title
...@@ -13,6 +13,12 @@ class Announcement(models.Model): ...@@ -13,6 +13,12 @@ class Announcement(models.Model):
def get_absolute_url(self): def get_absolute_url(self):
return reverse("announcement-details", kwargs={'pk': self.pk}) 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): class Reaction(models.Model):
Like = 'Like' Like = 'Like'
Love = 'Love' Love = 'Love'
......
{% extends 'base.html' %} {% extends 'base.html' %}
{% load static %} {% load static %}
{% block title %}Add Annoucement{% endblock %} {% block title %}Add Announcement{% endblock %}
{% block content %} {% block content %}
<p>Add a new announcement:</p> <p>Add a new announcement:</p>
<form method="POST"> <form method="POST">
{% csrf_token %} {% csrf_token %}
{{ form.as_p }} {{ form.as_p }}
<input type="Submit" value="Save New Announcement"> <input type="Submit" value="Add Announcement">
</form> </form>
{% endblock %} {% endblock %}
\ No newline at end of file
...@@ -8,12 +8,11 @@ ...@@ -8,12 +8,11 @@
{% block content %} {% block content %}
<p>by {{ object.author }}</p> <p>by {{ object.author }}</p>
<p>{{ object.datetime }}</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 %} {% for reac in object.reaction_set.all %}
<p>by {{ reac.name }}: {{ reac.tally }}</p> <p>{{ reac.name }}: {{ reac.tally }}</p>
{% endfor %} {% 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 %} {% endblock %}
\ No newline at end of file
{% extends 'base.html' %} {% extends 'base.html' %}
{% load static %} {% 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 %} {% block content %}
<p>Announcements:</p> <p>Announcements:</p>
{% for ann in announcements %} {% for ann in announcements %}
<p><a href="{% url 'announcement-details' ann.pk %}">{{ ann.title }} by {{ ann.author }}</a></p> <p><a href="{% url 'announcement-details' ann.pk %}">{{ ann.title }} by {{ ann.author }}</a></p>
{% endfor %} {% 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 %} {% endblock %}
{% block links %} {% block links %}
<p><a href="http://localhost:8000/dashboard/">Dashboard</a></p> <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/assignments/">Assignment</a></p>
<p><a href="http://localhost:8000/calendar/">Calendar</a></p> <p><a href="http://localhost:8000/calendar/">Calendar</a></p>
{% endblock %} {% endblock %}
\ No newline at end of file
...@@ -3,7 +3,7 @@ from . import views ...@@ -3,7 +3,7 @@ from . import views
from .views import (AnnouncementDetailView, AnnouncementCreateView, AnnouncementUpdateView) from .views import (AnnouncementDetailView, AnnouncementCreateView, AnnouncementUpdateView)
urlpatterns = [ urlpatterns = [
path('', views.announcements, name="announcements"), path('', views.index, name='index'),
path('announcements/<int:pk>/details/', AnnouncementDetailView.as_view(), name="announcement-details"), path('announcements/<int:pk>/details/', AnnouncementDetailView.as_view(), name="announcement-details"),
path('announcements/add/', AnnouncementCreateView.as_view(), name="announcement-add"), path('announcements/add/', AnnouncementCreateView.as_view(), name="announcement-add"),
path('announcements/<int:pk>/edit/', AnnouncementUpdateView.as_view(), name="announcement-edit"), path('announcements/<int:pk>/edit/', AnnouncementUpdateView.as_view(), name="announcement-edit"),
......
...@@ -3,7 +3,7 @@ from django.views.generic.detail import DetailView ...@@ -3,7 +3,7 @@ from django.views.generic.detail import DetailView
from django.views.generic.edit import CreateView, UpdateView from django.views.generic.edit import CreateView, UpdateView
from .models import Announcement from .models import Announcement
def announcements(request): def index(request):
return render(request, 'announcements/announcements.html', {'announcements': Announcement.objects.order_by('-pub_datetime')}) return render(request, 'announcements/announcements.html', {'announcements': Announcement.objects.order_by('-pub_datetime')})
class AnnouncementDetailView(DetailView): class AnnouncementDetailView(DetailView):
......
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.db import models
from django.urls import reverse
class Location(models.Model): class Location(models.Model):
Onsite = 'Onsite' Onsite = 'Onsite'
...@@ -24,3 +25,6 @@ class Event(models.Model): ...@@ -24,3 +25,6 @@ class Event(models.Model):
def __str__(self): def __str__(self):
return self.activity 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 django.urls import path
from . import views from . import views
from .views import EventDetailView, EventCreateView, EventUpdateView
urlpatterns = [ 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 from .models import Event
def index(request): def calendar(request):
events = Event.objects.all() return render(request, 'calendars/calendar.html', {'event': Event.objects.all()})
response ="Widgets's Calendar of Activities<br><br>Date and Time: " class EventDetailView(DetailView):
for event in events: model = Event
response += "{}<br>Activity: {}<br>Estimated Hours: {}<br>Course/Section: {}<br>Mode: {}<br>Venue: {}<br>".format( template_name = 'calendars/event-details.html'
event.target_datetime.strftime("%m/%d/%Y, %I:%M %p"),
event.activity,
str(event.estimated_hours),
event.course,
event.locations.modes,
event.locations.venue
)
return HttpResponse(response) class EventCreateView(CreateView):
\ No newline at end of file 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
...@@ -16,3 +16,6 @@ class WidgetUser(models.Model): ...@@ -16,3 +16,6 @@ class WidgetUser(models.Model):
def __str__(self): def __str__(self):
return '{} {}'.format(self.first_name, self.last_name) 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 django.urls import path
from .views import dashboard from .views import (
dashboard, WidgetuserDetailView, WidgetuserCreateView, WidgetuserUpdateView
)
urlpatterns = [ urlpatterns = [
path('', dashboard, name = "dashboard") 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
app_name = "dashboard"
\ No newline at end of file
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 Department, WidgetUser from .models import Department, WidgetUser
def dashboard(request): def dashboard(request):
widgetusers = WidgetUser.objects.all() return render(request, 'dashboard/dashboard.html', {'WidgetUser': WidgetUser.objects.all()})
response = "Welcome to Widget!<br><br>WIDGET USERS:<br>"
for user in widgetusers: class WidgetuserDetailView(DetailView):
response += "{}, {} {}: {}, {}<br>".format( model = WidgetUser
user.last_name, template_name ='dashboard/widgetuser-details.html'
user.first_name, fields = '__all__'
user.middle_name,
user.department,
user.department.home_unit class WidgetuserCreateView(CreateView):
) model = WidgetUser
fields = '__all__'
return HttpResponse(response) template_name ='dashboard/widgetuser-add.html'
\ No newline at end of file
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