Commit f6bb21db authored by Albert Gagalac's avatar Albert Gagalac

Fixed merge errors due to an SQL file, by refreshing files and implementing...

Fixed merge errors due to an SQL file, by refreshing files and implementing changes using an updated clone of master
parent fd895893
SECRET_KEY = 'django-insecure--4$e*nub=h-)k*y!7kid5dz=3g$f5_n2zn&yv(dmupxd-c=m6)'
\ No newline at end of file
from django.contrib import admin
from .models import Announcement, Reaction
class AnnouncementAdmin(admin.ModelAdmin):
model = Announcement
list_display = ["title", "body", "author"]
class ReactionAdmin(admin.ModelAdmin):
model = Reaction
list_display = ["announcement", "name", "tally"]
admin.site.register(Announcement, AnnouncementAdmin)
admin.site.register(Reaction, ReactionAdmin)
\ No newline at end of file
from django.apps import AppConfig
class AnnouncementsConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'announcements'
# Generated by Django 4.1.7 on 2023-03-05 09:23
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='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(max_length=1024)),
('pub_datetime', models.DateTimeField()),
('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=5)),
('tally', models.IntegerField()),
('announcement', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='announcements.announcement')),
],
),
]
# Generated by Django 4.1.7 on 2023-03-05 19:21
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("announcements", "0001_initial"),
]
operations = [
migrations.AlterField(
model_name="reaction",
name="name",
field=models.CharField(
choices=[("Like", "Like"), ("Love", "Love"), ("Angry", "Angry")],
max_length=5,
),
),
]
from django.db import models
from dashboard.models import WidgetUser
class Announcement(models.Model):
title = models.CharField(max_length=50)
body = models.TextField(max_length=1024)
author = models.ForeignKey(WidgetUser, on_delete=models.CASCADE)
pub_datetime = models.DateTimeField()
def __str__(self):
return self.title
class Reaction(models.Model):
LIKE = 'Like'
LOVE = 'Love'
ANGR = 'Angry'
namechoices = [
(LIKE, 'Like'),
(LOVE, 'Love'),
(ANGR, 'Angry')
]
name = models.CharField(
max_length=5,
choices=namechoices,
)
tally = models.IntegerField()
announcement = models.ForeignKey(Announcement, on_delete=models.CASCADE)
def __str__(self):
return self.name
from django.test import TestCase
# Create your tests here.
from django.urls import path
from .views import pageview
urlpatterns = [
path('', pageview, name='pageview')
]
app_name = "announcements"
\ No newline at end of file
from .models import Announcement, Reaction
from django.http import HttpResponse
def pageview(request):
announcements = Announcement.objects.all()
reactions = Reaction.objects.all()
string_builder = "Widget's Announcement Board <br> <br> Announcements: <br> "
for announcement in announcements:
string_builder = "{} <br> {} by {} published {} <br> {}".format(
string_builder, announcement.title, announcement.author,
announcement.pub_datetime.strftime("%m/%d/%Y, %I:%M %p:"),
announcement.body
)
for reaction in reactions:
if reaction.announcement == announcement:
string_builder = "{} <br> {}: {}".format(string_builder, reaction.name, reaction.tally)
string_builder += "<br>"
return HttpResponse(string_builder)
from django.contrib import admin
# Register your models here.
from .models import Assignment, Course
class AssignmentAdmin(admin.ModelAdmin):
model = Assignment
class CourseAdmin(admin.ModelAdmin):
model = Course
admin.site.register(Assignment, AssignmentAdmin)
admin.site.register(Course, CourseAdmin)
\ No newline at end of file
from django.apps import AppConfig
class AssignmentsConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'assignments'
# Generated by Django 4.1.7 on 2023-03-05 19:21
import django.core.validators
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(default="", max_length=10)),
("title", models.CharField(default="", max_length=50)),
(
"section",
models.CharField(
default="",
max_length=3,
unique=True,
validators=[
django.core.validators.RegexValidator(
"^[a-zA-Z]*$", message="Only letters are allowed"
)
],
),
),
],
),
migrations.CreateModel(
name="Assignment",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("name", models.CharField(default="", max_length=50)),
("description", models.TextField(default="", max_length=700)),
("perfect_score", models.PositiveIntegerField(default=0)),
(
"course",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
to="assignments.course",
),
),
],
),
]
from django.db import models
from django.core.validators import RegexValidator
# Create your models here.
class Course(models.Model):
code = models.CharField(default="", max_length=10)
title = models.CharField(default="", max_length=50)
section = models.CharField(
default="",max_length=3,
unique=True,
validators=[RegexValidator(r'^[a-zA-Z]*$',
message='Only letters are allowed')])
def __str__(self):
return "%s %s %s" % (self.code, self.title, self.section)
class Assignment(models.Model):
name = models.CharField(default="", max_length=50)
description = models.TextField(default="", max_length=700)
course = models.ForeignKey(Course, on_delete=models.CASCADE)
perfect_score = models.PositiveIntegerField(default=0)
def __str__(self):
return self.name
def get_passing_score(self):
pass_score = self.perfect_score * (60/100)
return pass_score
@property
def passing_score(self):
return self.get_passing_score()
\ No newline at end of file
<p>
{{"Widget's Assignments Page"}}
</p><br>
{% for data in assignment %}
<p>Assignment name: {{data.name}}</p>
<p>Description: {{data.description}}</p>
<p>Perfect Score: {{data.perfect_score}}</p>
<p>Passing Score: {{data.passing_score}}</p>
<p>Course/Section: {{data.course}}</p>
<br>
{% endfor %}
from django.test import TestCase
# Create your tests here.
from django.urls import path
from .views import pageview
urlpatterns = [
path('', pageview, name='pageview')
]
app_name = "assignments"
\ No newline at end of file
from django.shortcuts import render
from .models import Assignment, Course
def pageview(request):
num_assignment = Assignment.objects.all()
num_course = Course.objects.all()
return render(request, 'assignments/assignments.html', {'assignment': num_assignment, 'course': num_course})
from django.contrib import admin
from .models import Department, WidgetUser
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
from django.apps import AppConfig
class DashboardConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'dashboard'
# 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
# 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.test import TestCase
# Create your tests here.
from django.urls import path
from .views import pageview
urlpatterns = [
path('', pageview, name='pageview')
]
app_name = "dashboard"
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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