Commit e04995f1 authored by Eldon Dagdag's avatar Eldon Dagdag

Fixed merge conflicts with master

parents d8829f75 819d6dba
# Generated by Django 4.1.7 on 2023-05-10 05:08
from django.db import migrations, models
import django.utils.timezone
class Migration(migrations.Migration):
dependencies = [
('announcement_board', '0006_alter_reaction_announcement'),
]
operations = [
migrations.AlterField(
model_name='announcement',
name='pub_datetime',
field=models.DateTimeField(default=django.utils.timezone.now),
),
]
from django.db import models from django.db import models
from django.urls import reverse
from django.utils.translation import gettext_lazy as _ from django.utils.translation import gettext_lazy as _
from django.utils import timezone
from dashboard import models as dashboard_models from dashboard import models as dashboard_models
class Announcement(models.Model): class Announcement(models.Model):
title = models.CharField(max_length=255, default="") title = models.CharField(max_length=255, default="")
body = models.TextField(default="") body = models.TextField(default="")
author = models.ForeignKey(dashboard_models.WidgetUser, on_delete=models.CASCADE) author = models.ForeignKey(dashboard_models.WidgetUser, on_delete=models.CASCADE)
pub_datetime = models.DateTimeField() pub_datetime = models.DateTimeField(default=timezone.now)
def __str__(self): def __str__(self):
return '{} by {} {} published on {}: {}'.format( return '{} by {} {} published on {}, {}: {}'.format(
self.title, self.title,
self.author.first_name, self.author.first_name,
self.author.last_name, self.author.last_name,
self.pub_datetime.strftime("%m/%d/%Y %I:%M %p"), self.pub_datetime.strftime("%m/%d/%y"),
self.pub_datetime.strftime("%I:%M %p"),
self.body self.body
) )
def formatted_date(self):
return '{}'.format(self.pub_datetime.strftime("%m/%d/%y"))
def formatted_time(self):
return '{}'.format(self.pub_datetime.strftime("%I:%M %p"))
def getLikeReactions(self):
try:
return '{}'.format(Reaction.objects.get(name="Like", announcement=self).tally)
except:
return '0'
def getLoveReactions(self):
try:
return '{}'.format(Reaction.objects.get(name="Love", announcement=self).tally)
except:
return '0'
def getAngryReactions(self):
try:
return '{}'.format(Reaction.objects.get(name="Angry", announcement=self).tally)
except:
return '0'
def get_absolute_url(self):
return reverse('announcement_board:announcement-details', kwargs={'pk': self.pk})
class Reaction(models.Model): class Reaction(models.Model):
announcement = models.ForeignKey(Announcement, on_delete=models.CASCADE, related_name='reactions') announcement = models.ForeignKey(Announcement, on_delete=models.CASCADE, related_name='reactions')
......
{% extends 'base.html' %}
{% load static %}
{% block title %}Add Announcement{% endblock %}
{% block content %}
<div class="row">
<div class="col-3 text-center text-white" style="background-color:#052c65">
<br>
<br>
<img src="{% static 'announcements_icon.png'%}" class="img-fluid" width="100" height="100">
<br>
<br>
<h2>Announcements</h2>
<h4 class="display-6" style="font-size:20px">Add New Announcement</h4>
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
<p>© Jenica e-Sports</p>
</div>
<div class="col-9 text-center">
<div class="row p-5 text-center" style="background-color:#e3e4e6">
<h1 class="display-3" style="font-size:50px; color:#052c65">Add a new announcement:</h1>
</div>
<br>
<div class="row"></div>
<form method="post">
{% csrf_token %}
{% for field in form %}
<div class="row">
<div class="col-5" style="text-align:right">
<h5 class="display-3" style="font-size:25px">{{field.label}}:</h4>
</div>
<div class="col-7" style="text-align:left">
{{field}}
</div>
</div>
<br>
{% endfor %}
<input type="submit" class="btn btn-dark" value="Save New Announcement" style="background-color:#052c65">
</form>
<br><br>
</div>
</div>
{% endblock %}
\ No newline at end of file
{% extends 'base.html' %}
{% load static %}
{% block title %}{{ object.title }}{% endblock %}
{% block content %}
<div class="row">
<div class="col-3 text-center text-white" style="background-color:#052c65">
<br>
<br>
<img src="{% static 'announcements_icon.png'%}" class="img-fluid" width="100" height="100">
<br>
<br>
<h2>Announcements</h2>
<h4 class="display-6" style="font-size:20px">Announcement Details</h4>
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
<p>© Jenica e-Sports</p>
</div>
<div class="col-9 text-center">
<div class="row p-5 text-center" style="background-color:#e3e4e6">
<h1 class="display-3" style="font-size:55px; color:#052c65">{{ object.title }}</h1>
</div>
<br>
<div class="row">
<div class="col-5" style="text-align:right">
<h4 style="font-size:25px">Author:</h4>
<h4 style="font-size:25px">Date and Time:</h4>
</div>
<div class="col-7" style="text-align:left">
<h5 class="display-3" style="font-size:25px">{{ object.author.first_name }} {{ object.author.last_name }}</h5>
<h5 class="display-3" style="font-size:25px">{{ object.formatted_date }}, {{ object.formatted_time }}</h5>
</div>
</div>
<br>
<div class="row p-2" style="background-color:#e3e4e6">
<h5 class="display-3" style="font-size:25px">{{ object.body }}</h5>
</div>
<br>
<div class="row">
<div class="col-5" style="text-align:right">
<h4 style="font-size:25px">Like:</h4>
<h4 style="font-size:25px">Love:</h4>
<h4 style="font-size:25px">Angry:</h4>
</div>
<div class="col-7" style="text-align:left">
<h5 class="display-3" style="font-size:25px">{{ object.getLikeReactions }}</h5>
<h5 class="display-3" style="font-size:25px">{{ object.getLoveReactions }}</h5>
<h5 class="display-3" style="font-size:25px">{{ object.getAngryReactions }}</h5>
</div>
</div>
<br><br>
<button type="button" class="btn" style="background-color:#e3e4e6">
<a href="/announcements/{{object.pk}}/edit" class="link-dark">Edit Announcement</a>
</button> &nbsp; &nbsp;
<button type="button" class="btn" style="background-color:#052c65">
<a href="/announcements/" class="link-light">Back to Announcement Board</a>
</button>
</div>
</div>
{% endblock %}
\ No newline at end of file
{% extends 'base.html' %}
{% load static %}
{% block title %}Edit Announcement{% endblock %}
{% block content %}
<div class="row">
<div class="col-3 text-center text-white" style="background-color:#052c65">
<br>
<br>
<img src="{% static 'announcements_icon.png'%}" class="img-fluid" width="100" height="100">
<br>
<br>
<h2>Announcements</h2>
<h4 class="display-6" style="font-size:20px">Edit Announcement</h4>
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
<p>© Jenica e-Sports</p>
</div>
<div class="col-9 text-center">
<div class="row p-5 text-center" style="background-color:#e3e4e6">
<h1 class="display-3" style="font-size:50px; color:#052c65">Edit announcement:</h1>
</div>
<br>
<div class="row"></div>
<form method="post">
{% csrf_token %}
{% for field in form %}
<div class="row">
<div class="col-5" style="text-align:right">
<h5 class="display-3" style="font-size:25px">{{field.label}}:</h4>
</div>
<div class="col-7" style="text-align:left">
{{field}}
</div>
</div>
<br>
{% endfor %}
<input type="submit" class="btn btn-dark" value="Save Changes" style="background-color:#052c65">
</form>
<br><br>
</div>
</div>
{% endblock %}
\ No newline at end of file
{% extends 'base.html' %}
{% load static %}
{% block title %}Widget's Announcement Board{% endblock %}
{% block content %}
<div class="row">
<div class="col-3 text-center text-white" style="background-color:#052c65">
<br>
<br>
<img src="{% static 'announcements_icon.png'%}" class="img-fluid" width="100" height="100">
<br>
<br>
<h2>Announcements</h2>
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
<p>© Jenica e-Sports</p>
</div>
<div class="col-9 text-center">
<div class="row p-5 text-center" style="background-color:#e3e4e6">
<h1 class="display-3"style="font-size:55px; color:#052c65">Wecome to Widget's Announcement Board!</h1>
</div>
<br>
<br>
<h5 class="display-3"style="font-size:40px; color:#052c65">Announcements:</h5>
<br>
{% for object in announcements %}
<a href="{{ object.get_absolute_url }}" class="link-dark; display-3" style="font-size:18px; color:#052c65">
{{ object.title }} by {{ object.author.first_name }} {{ object.author.last_name }}</a>
<br>
{% endfor %}
<br><br>
<button type="button" class="btn btn-dark" style="background-color:#e3e4e6">
<a href="/announcements/add" class="link-dark">New Announcement</a>
</button>
<br>
<br>
<br>
<button type="button" class="btn btn-dark" style="background-color:#052c65">
<a href="/dashboard/" class="link-light">Dashboard</a>
</button> &nbsp;
<button type="button" class="btn btn-dark" style="background-color:#334277">
<a href="/forum/" class="link-light">Forum</a>
</button> &nbsp;
<button type="button" class="btn btn-dark" style="background-color:#425086">
<a href="/assignments/" class="link-light">Assignments</a>
</button> &nbsp;
<button type="button" class="btn btn-dark" style="background-color:#515e96">
<a href="/calendar/" class="link-light">Calendar</a>
</button>
</div>
</div>
{% endblock %}
\ No newline at end of file
from django.urls import path from django.urls import path
from .views import index from .views import announcements, AnnouncementDetailView, AnnouncementCreateView, AnnouncementUpdateView
urlpatterns = [ urlpatterns = [
path('', index, name='index'), path('', announcements, name='announcements'),
path('<int:pk>/details/', AnnouncementDetailView.as_view(), name='announcement-details'),
path('add/', AnnouncementCreateView.as_view(), name='announcement-add'),
path('<int:pk>/edit/', AnnouncementUpdateView.as_view(), name='announcement-edit'),
] ]
app_name = "announcement_board" app_name = "announcement_board"
\ No newline at end of file
from django.shortcuts import render from django.shortcuts import render, redirect
from django.views.generic.detail import DetailView
from django.views.generic.edit import CreateView, UpdateView
from django.http import HttpResponse from django.http import HttpResponse
from .models import Announcement
from .models import Reaction
def index(request): from .models import Announcement, Reaction
return_string = "<p>Widget's Announcement Board</p> <p>Announcements:<br>"
for announcements in Announcement.objects.all(): def announcements(request):
announcement_string = '{} by {} {} published {}, {}:<br>{}<br>'.format( return render(request, 'announcement_board/announcements.html', {'announcements':Announcement.objects.order_by('-pub_datetime')})
announcements.title,
announcements.author.first_name,
announcements.author.last_name,
announcements.pub_datetime.strftime("%m/%d/%Y"),
announcements.pub_datetime.strftime("%I:%M %p"),
announcements.body
)
return_string += announcement_string
reactionList = announcements.reactions.all() class AnnouncementDetailView(DetailView):
sortedReactionList = sortReactions(reactionList) model = Announcement
template_name = 'announcement_board/announcement-details.html'
for reaction in sortedReactionList: class AnnouncementCreateView(CreateView):
reactions_string = '{}: {}<br>'.format( model = Announcement
reaction.name, fields = 'title', 'body', 'author'
reaction.tally template_name = 'announcement_board/announcement-add.html'
)
return_string += reactions_string
return_string += '</p>' class AnnouncementUpdateView(UpdateView):
html_string = '<html><body>{}</body></html>'.format(return_string) model = Announcement
fields = 'title', 'body', 'author'
return HttpResponse(return_string) template_name = 'announcement_board/announcement-edit.html'
\ No newline at end of file
# Sorting the reactions to Like, Love, and Angry order.
def sortReactions(list):
sortedReactionList = ['']*3
for reaction in list:
if reaction.name=="Like":
sortedReactionList[0] = reaction
elif reaction.name=="Love":
sortedReactionList[1] = reaction
elif reaction.name=="Angry":
sortedReactionList[2] = reaction
return sortedReactionList
\ No newline at end of file
# Generated by Django 4.1.6 on 2023-05-04 10:33
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
("dashboard", "0001_initial"),
]
operations = [
migrations.AlterField(
model_name="widgetuser",
name="department",
field=models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
to="dashboard.department",
verbose_name="Department, Home Unit",
),
),
]
# Generated by Django 4.1.6 on 2023-05-10 07:26
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("dashboard", "0002_alter_widgetuser_department"),
]
operations = [
migrations.AlterField(
model_name="widgetuser",
name="first_name",
field=models.CharField(
default="", max_length=255, verbose_name="First Name"
),
),
migrations.AlterField(
model_name="widgetuser",
name="last_name",
field=models.CharField(
default="", max_length=255, verbose_name="Last Name"
),
),
migrations.AlterField(
model_name="widgetuser",
name="middle_name",
field=models.CharField(
default="", max_length=255, verbose_name="Middle Name"
),
),
]
from django.db import models from django.db import models
from django.urls import reverse
class Department(models.Model): class Department(models.Model):
dept_name = models.CharField(max_length=255, default='') dept_name = models.CharField(max_length=255, default='')
home_unit = models.CharField(max_length=255, default='') home_unit = models.CharField(max_length=255, default='')
def __str__(self): def __str__(self):
return 'Department Name and Home Unit: {}, {}'.format(self.dept_name, self.home_unit) return '{}, {}'.format(self.dept_name, self.home_unit)
class WidgetUser(models.Model): class WidgetUser(models.Model):
first_name = models.CharField(max_length=255, default='') first_name = models.CharField(max_length=255, default='', verbose_name='First Name')
middle_name = models.CharField(max_length=255, default='') middle_name = models.CharField(max_length=255, default='', verbose_name='Middle Name')
last_name = models.CharField(max_length=255, default='') last_name = models.CharField(max_length=255, default='', verbose_name='Last Name')
department = models.ForeignKey(Department, on_delete=models.CASCADE) department = models.ForeignKey(Department, on_delete=models.CASCADE, verbose_name='Department, Home Unit')
def __str__(self): def __str__(self):
return '{}, {} {}'.format(self.last_name, self.first_name, self.middle_name) return '{}, {}'.format(self.last_name, self.first_name)
\ No newline at end of file
def get_absolute_url(self):
return reverse('dashboard:widgetuser-details', kwargs={'pk': self.pk})
{% extends 'base.html' %}
{% load static %}
{% block title %}Widget v2{% endblock %}
{% block content %}
<div class="row">
<div class="col-3 text-center text-white" style="background-color:#052c65">
<br>
<br>
<img src="{% static 'dashboard_icon.png'%}" class="img-fluid" width="100" height="100">
<br>
<br>
<h2>Dashboard</h2>
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
<p>© Jenica e-Sports</p>
</div>
<div class="col-9 text-center">
<div class="row p-5 text-center" style="background-color:#e3e4e6">
<h1 class="display-3"style="font-size:60px; color:#052c65">Welcome to Widget!</h1>
</div>
<br>
<br>
<h6 class="display-3"style="font-size:40px; color:#052c65">Widget Users:</h6><br>
{% for user in users %}
<a href="{{ user.get_absolute_url }}" class="link-dark; display-3" style="font-size:18px; color:#052c65">
{{ user }}</a>
<br>
{% endfor %}
<br><br>
<button type="button" class="btn" style="background-color:#e3e4e6">
<a href="/dashboard/widgetusers/add/" class="link-dark">Add Widget User</a>
</button>
<br>
<br>
<br>
</button> &nbsp;
<button type="button" class="btn" style="background-color:#052c65">
<a href="/announcements/" class="link-light">Announcement Board</a>
</button> &nbsp;
<button type="button" class="btn" style="background-color:#334277">
<a href="/forum/" class="link-light">Forum</a>
</button> &nbsp;
<button type="button" class="btn" style="background-color:#425086">
<a href="/assignments/" class="link-light">Assignments</a>
</button> &nbsp;
<button type="button" class="btn" style="background-color:#515e96">
<a href="/calendar/" class="link-light">Calendar</a>
</button>
</div>
</div>
{% endblock %}
\ No newline at end of file
{% extends 'base.html' %}
{% load static %}
{% block title %}Add Widget User{% endblock %}
{% block content %}
<div class="row">
<div class="col-3 text-center text-white" style="background-color:#052c65">
<br>
<br>
<img src="{% static 'dashboard_icon.png'%}" class="img-fluid" width="100" height="100">
<br>
<br>
<h2>Dashboard</h2>
<h4 class="display-6" style="font-size:20px">Add Widget User</h4>
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
<p>© Jenica e-Sports</p>
</div>
<div class="col-9 text-center">
<div class="row p-5 text-center" style="background-color:#e3e4e6">
<h1 class="display-3" style="font-size:50px; color:#052c65">Add a new widget user:</h1>
</div>
<br>
<div class="row"></div>
<form method="post">
{% csrf_token %}
{% for field in form %}
<div class="row">
<div class="col-5" style="text-align:right">
<h5 class="display-3" style="font-size:25px">{{field.label}}:</h4>
</div>
<div class="col-7" style="text-align:left">
{{field}}
</div>
</div>
<br>
{% endfor %}
<input type="submit" class="btn btn-dark" value="Add Widget User" style="background-color:#052c65">
</form>
<br><br>
</div>
</div>
{% endblock %}
\ No newline at end of file
{% extends 'base.html' %}
{% load static %}
{% block title %}{{ object }}{% endblock %}
{% block content %}
<div class="row">
<div class="col-3 text-center text-white" style="background-color:#052c65">
<br>
<br>
<img src="{% static 'dashboard_icon.png'%}" class="img-fluid" width="100" height="100">
<br>
<br>
<h2>Dashboard</h2>
<h4 class="display-6" style="font-size:20px">Widget User Details</h4>
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
<p>© Jenica e-Sports</p>
</div>
<div class="col-9 text-center">
<div class="row p-5 text-center" style="background-color:#e3e4e6">
<h1 class="display-3" style="font-size:50px; color:#052c65">{{ object.first_name }} {{ object.middle_name }} {{ object.last_name }}</h1>
</div>
<br>
<div class="row">
<div class="col-5" style="text-align:right">
<h4 style="font-size:25px">Department Name:</h4>
<h4 style="font-size:25px">Home Unit:</h4>
</div>
<div class="col-7" style="text-align:left">
<h5 class="display-3" style="font-size:25px">{{ object.department.dept_name }}</h5>
<h5 class="display-3" style="font-size:25px">{{ object.department.home_unit }}</h5>
</div>
</div>
<br><br>
<button type="button" class="btn" style="background-color:#e3e4e6">
<a href="/dashboard/widgetusers/{{ object.pk }}/edit/" class="link-dark">Edit Widget User</a>
</button> &nbsp; &nbsp;
<button type="button" class="btn" style="background-color:#052c65">
<a href="/dashboard/" class="link-light">Back to Dashboard</a>
</button>
</div>
</div>
{% endblock %}
\ No newline at end of file
{% extends 'base.html' %}
{% load static %}
{% block title %}Edit Widget User{% endblock %}
{% block content %}
<div class="row">
<div class="col-3 text-center text-white" style="background-color:#052c65">
<br>
<br>
<img src="{% static 'dashboard_icon.png'%}" class="img-fluid" width="100" height="100">
<br>
<br>
<h2>Dashboard</h2>
<h4 class="display-6" style="font-size:20px">Edit Widget User</h4>
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
<p>© Jenica e-Sports</p>
</div>
<div class="col-9 text-center">
<div class="row p-5 text-center" style="background-color:#e3e4e6">
<h1 class="display-3" style="font-size:50px; color:#052c65">Edit Widget User:</h1>
</div>
<br>
<div class="row"></div>
<form method="post">
{% csrf_token %}
{% for field in form %}
<div class="row">
<div class="col-5" style="text-align:right">
<h5 class="display-3" style="font-size:25px">{{field.label}}:</h4>
</div>
<div class="col-7" style="text-align:left">
{{field}}
</div>
</div>
<br>
{% endfor %}
<input type="submit" class="btn btn-dark" value="Save Changes to Widget User" style="background-color:#052c65">
</form>
<br><br>
</div>
</div>
{% endblock %}
\ No newline at end of file
from django.urls import path from django.urls import path
from .views import index from .views import (
dashboard_view, WidgetUserDetailView, WidgetUserCreateView, WidgetUserUpdateView
)
urlpatterns = [ urlpatterns = [
path('', index, name='index') path('', dashboard_view, name='dashboard'),
path('widgetusers/<int:pk>/details/', WidgetUserDetailView.as_view(), name='widgetuser-details'),
path('widgetusers/add/', WidgetUserCreateView.as_view(), name='widgetuser-add'),
path('widgetusers/<int:pk>/edit/', WidgetUserUpdateView.as_view(), name='widgetuser-edit'),
] ]
app_name = 'dashboard' 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.views.generic.detail import DetailView
from django.views.generic.edit import CreateView, UpdateView
from .models import WidgetUser from .models import WidgetUser
def index(request): def dashboard_view(request):
return_string = '<p>Welcome to Widget!</p> <p>WIDGET USERS:<br>' users = WidgetUser.objects.all()
context = {'users' : users}
return render(request, 'dashboard/dashboard.html', context)
for user in WidgetUser.objects.all(): class WidgetUserDetailView(DetailView):
user_string = '{}, {} {}: {}, {}<br>'.format( model = WidgetUser
user.last_name, user.first_name, user.middle_name, template_name = 'dashboard/widgetuser-details.html'
user.department.dept_name, user.department.home_unit
)
return_string += user_string
return_string += '</p>' class WidgetUserCreateView(CreateView):
html_string = '<html><body>{}</body></html>'.format(return_string) model = WidgetUser
fields = '__all__'
template_name = 'dashboard/widgetuser-add.html'
return HttpResponse(return_string) class WidgetUserUpdateView(UpdateView):
\ No newline at end of file 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