From afddfbfe4b41f42d0e2065558629497e4669b11f Mon Sep 17 00:00:00 2001 From: Nolan Gregory <65730528+nulzo@users.noreply.github.com> Date: Sat, 28 Oct 2023 21:25:19 -0500 Subject: [PATCH] Enhanced loading CSV into database --- backend/.dockerignore | 4 + backend/base/urls.py | 1 + backend/generate_ticket.py | 32 ++ backend/poetry.lock | 16 +- backend/pyproject.toml | 1 + backend/src/api/admin.py | 3 +- backend/src/api/data/students.JSON | 402 +++++++++++++++++ .../migrations/0002_alter_user_managers.py | 19 + backend/src/api/migrations/0003_hour.py | 56 +++ backend/src/api/models/hours.py | 36 ++ backend/src/api/models/user.py | 1 + backend/src/api/scripts/load_students.py | 423 ++++++++++++++++++ backend/src/api/views.py | 161 ++++++- backend/tests/test_course.py | 3 +- .../src/components/assets/ZoomIcon.tsx | 6 +- .../src/components/navigation/Sidebar.tsx | 1 - .../src/views/development/DevSandbox.tsx | 5 + 17 files changed, 1157 insertions(+), 13 deletions(-) create mode 100644 backend/generate_ticket.py create mode 100644 backend/src/api/data/students.JSON create mode 100644 backend/src/api/migrations/0002_alter_user_managers.py create mode 100644 backend/src/api/migrations/0003_hour.py create mode 100644 backend/src/api/models/hours.py create mode 100644 backend/src/api/scripts/load_students.py diff --git a/backend/.dockerignore b/backend/.dockerignore index 5fb7ee6..8c448ea 100644 --- a/backend/.dockerignore +++ b/backend/.dockerignore @@ -39,3 +39,7 @@ env.dist # No reason to send a gitignore to the container .gitignore + +data + +data/ \ No newline at end of file diff --git a/backend/base/urls.py b/backend/base/urls.py index 86d23a8..faf535a 100644 --- a/backend/base/urls.py +++ b/backend/base/urls.py @@ -140,6 +140,7 @@ view=routing.StudentDetailView.as_view(), name="Student Detail View", ), + path("api/users/", view=routing.APIUserList.as_view()), # path("api/students/"), # path("api/students/"), # Admin (Superuser) URLS diff --git a/backend/generate_ticket.py b/backend/generate_ticket.py new file mode 100644 index 0000000..7e929ea --- /dev/null +++ b/backend/generate_ticket.py @@ -0,0 +1,32 @@ +import json + +from faker import Faker + + +class Generator: + def __init__(self): + self.tickets = [] + self.students: list = [] + self.faker = Faker() + + def create_students(self): + for _ in range(50): + first = self.faker.first_name() + last = self.faker.last_name() + email = f"{first}{last}@unomaha.edu" + msoid = self.faker.ean(length=8) + student_nuid = self.faker.ean(length=8) + student = { + "name": f"{first} {last}", + "student_nuid": student_nuid, + "email": email, + "is_tutor": False, + "is_admin": False, + "MSOID": msoid, + } + self.students.append(student) + print(json.dumps(self.students, indent=2)) + + +gen = Generator() +print(gen.create_students()) diff --git a/backend/poetry.lock b/backend/poetry.lock index 9a3fc19..264bd29 100644 --- a/backend/poetry.lock +++ b/backend/poetry.lock @@ -724,6 +724,20 @@ files = [ django = ">=3.0" pytz = "*" +[[package]] +name = "faker" +version = "19.12.0" +description = "Faker is a Python package that generates fake data for you." +optional = false +python-versions = ">=3.8" +files = [ + {file = "Faker-19.12.0-py3-none-any.whl", hash = "sha256:5990380a8ee81cf189d6b85d5fdc1fb43772cb136aca0385a08ff24ef01b9fdf"}, + {file = "Faker-19.12.0.tar.gz", hash = "sha256:91438f6b1713274ec3f24970ba303617be86ce5caf6f6a0776f1d04777b6ff5f"}, +] + +[package.dependencies] +python-dateutil = ">=2.4" + [[package]] name = "filelock" version = "3.12.4" @@ -2151,4 +2165,4 @@ testing = ["coverage (>=5.0.3)", "zope.event", "zope.testing"] [metadata] lock-version = "2.0" python-versions = ">=3.11,<3.13" -content-hash = "37d730b87414beee7a0e1f5f2d180440df8857303426e44007ecd9a484bf9f94" +content-hash = "9a759b5a4bb528832edd59f045a49d3dfc64e8504ae00ffd7994fb1a50dedcbf" diff --git a/backend/pyproject.toml b/backend/pyproject.toml index 16a1381..2c3d528 100644 --- a/backend/pyproject.toml +++ b/backend/pyproject.toml @@ -20,6 +20,7 @@ coverage = "^7.3.2" pytest-cov = "^4.1.0" pytest-django = "^4.5.2" autopep8 = "^2.0.4" +faker = "^19.12.0" [tool.poetry.group.dev.dependencies] bruhcolor = "^0.0.56" diff --git a/backend/src/api/admin.py b/backend/src/api/admin.py index 862ff44..71ba6bb 100644 --- a/backend/src/api/admin.py +++ b/backend/src/api/admin.py @@ -1,6 +1,6 @@ from django.contrib import admin -from .models import course, issue, messages, professor, sections, ticket, user +from .models import course, hours, issue, messages, professor, sections, ticket, user # Register your models here. admin.site.register(ticket.Ticket) @@ -10,3 +10,4 @@ admin.site.register(user.User) admin.site.register(sections.Section) admin.site.register(messages.Messages) +admin.site.register(hours.Hour) diff --git a/backend/src/api/data/students.JSON b/backend/src/api/data/students.JSON new file mode 100644 index 0000000..7381064 --- /dev/null +++ b/backend/src/api/data/students.JSON @@ -0,0 +1,402 @@ +[ + { + "name": "Stacey Rodriguez", + "student_nuid": "32429909", + "email": "StaceyRodriguez@unomaha.edu", + "is_tutor": false, + "is_admin": false, + "MSOID": "49148305" + }, + { + "name": "Sandra Murillo", + "student_nuid": "72973844", + "email": "SandraMurillo@unomaha.edu", + "is_tutor": false, + "is_admin": false, + "MSOID": "08070241" + }, + { + "name": "Rachael Cooper", + "student_nuid": "61097995", + "email": "RachaelCooper@unomaha.edu", + "is_tutor": false, + "is_admin": false, + "MSOID": "95543505" + }, + { + "name": "Christopher Jones", + "student_nuid": "39914927", + "email": "ChristopherJones@unomaha.edu", + "is_tutor": false, + "is_admin": false, + "MSOID": "77115188" + }, + { + "name": "Robin Wallace", + "student_nuid": "29183692", + "email": "RobinWallace@unomaha.edu", + "is_tutor": false, + "is_admin": false, + "MSOID": "55144506" + }, + { + "name": "Tammy Ortiz", + "student_nuid": "43825707", + "email": "TammyOrtiz@unomaha.edu", + "is_tutor": false, + "is_admin": false, + "MSOID": "30894808" + }, + { + "name": "Sean Lester", + "student_nuid": "83185892", + "email": "SeanLester@unomaha.edu", + "is_tutor": false, + "is_admin": false, + "MSOID": "25643503" + }, + { + "name": "Bryan Williams", + "student_nuid": "78336070", + "email": "BryanWilliams@unomaha.edu", + "is_tutor": false, + "is_admin": false, + "MSOID": "33782263" + }, + { + "name": "Mark Martinez", + "student_nuid": "19649566", + "email": "MarkMartinez@unomaha.edu", + "is_tutor": false, + "is_admin": false, + "MSOID": "05093335" + }, + { + "name": "Catherine Gonzalez", + "student_nuid": "06369040", + "email": "CatherineGonzalez@unomaha.edu", + "is_tutor": false, + "is_admin": false, + "MSOID": "79973014" + }, + { + "name": "Timothy Rodgers", + "student_nuid": "18685480", + "email": "TimothyRodgers@unomaha.edu", + "is_tutor": false, + "is_admin": false, + "MSOID": "94504002" + }, + { + "name": "Mary Campbell", + "student_nuid": "70341362", + "email": "MaryCampbell@unomaha.edu", + "is_tutor": false, + "is_admin": false, + "MSOID": "67737758" + }, + { + "name": "Todd Williams", + "student_nuid": "86440936", + "email": "ToddWilliams@unomaha.edu", + "is_tutor": false, + "is_admin": false, + "MSOID": "62980104" + }, + { + "name": "Michaela Harris", + "student_nuid": "94392425", + "email": "MichaelaHarris@unomaha.edu", + "is_tutor": false, + "is_admin": false, + "MSOID": "32914313" + }, + { + "name": "Kathleen Brooks", + "student_nuid": "19960081", + "email": "KathleenBrooks@unomaha.edu", + "is_tutor": false, + "is_admin": false, + "MSOID": "51603984" + }, + { + "name": "Alexander Wu", + "student_nuid": "40540825", + "email": "AlexanderWu@unomaha.edu", + "is_tutor": false, + "is_admin": false, + "MSOID": "35967682" + }, + { + "name": "Paige Howard", + "student_nuid": "10469026", + "email": "PaigeHoward@unomaha.edu", + "is_tutor": false, + "is_admin": false, + "MSOID": "72103487" + }, + { + "name": "Cory Allen", + "student_nuid": "08508751", + "email": "CoryAllen@unomaha.edu", + "is_tutor": false, + "is_admin": false, + "MSOID": "05175246" + }, + { + "name": "Paul Mercado", + "student_nuid": "95569307", + "email": "PaulMercado@unomaha.edu", + "is_tutor": false, + "is_admin": false, + "MSOID": "53581259" + }, + { + "name": "Renee Sanders", + "student_nuid": "31646307", + "email": "ReneeSanders@unomaha.edu", + "is_tutor": false, + "is_admin": false, + "MSOID": "63682434" + }, + { + "name": "Jose May", + "student_nuid": "40736716", + "email": "JoseMay@unomaha.edu", + "is_tutor": false, + "is_admin": false, + "MSOID": "43360970" + }, + { + "name": "Linda Mcdonald", + "student_nuid": "31662604", + "email": "LindaMcdonald@unomaha.edu", + "is_tutor": false, + "is_admin": false, + "MSOID": "14121241" + }, + { + "name": "Jerome Rodriguez", + "student_nuid": "06488321", + "email": "JeromeRodriguez@unomaha.edu", + "is_tutor": false, + "is_admin": false, + "MSOID": "35879930" + }, + { + "name": "Kimberly Fisher", + "student_nuid": "78391598", + "email": "KimberlyFisher@unomaha.edu", + "is_tutor": false, + "is_admin": false, + "MSOID": "80157106" + }, + { + "name": "Lisa Perez", + "student_nuid": "31454223", + "email": "LisaPerez@unomaha.edu", + "is_tutor": false, + "is_admin": false, + "MSOID": "90150012" + }, + { + "name": "Vickie Phillips", + "student_nuid": "24850919", + "email": "VickiePhillips@unomaha.edu", + "is_tutor": false, + "is_admin": false, + "MSOID": "37809256" + }, + { + "name": "Jeffrey Herrera", + "student_nuid": "03100851", + "email": "JeffreyHerrera@unomaha.edu", + "is_tutor": false, + "is_admin": false, + "MSOID": "81784516" + }, + { + "name": "Michelle Gallagher", + "student_nuid": "58436462", + "email": "MichelleGallagher@unomaha.edu", + "is_tutor": false, + "is_admin": false, + "MSOID": "47161337" + }, + { + "name": "Brian Larson", + "student_nuid": "48046688", + "email": "BrianLarson@unomaha.edu", + "is_tutor": false, + "is_admin": false, + "MSOID": "03158760" + }, + { + "name": "Rachael Jackson", + "student_nuid": "28544975", + "email": "RachaelJackson@unomaha.edu", + "is_tutor": false, + "is_admin": false, + "MSOID": "86189606" + }, + { + "name": "Hailey West", + "student_nuid": "71266084", + "email": "HaileyWest@unomaha.edu", + "is_tutor": false, + "is_admin": false, + "MSOID": "40102153" + }, + { + "name": "Michelle Bell", + "student_nuid": "01324020", + "email": "MichelleBell@unomaha.edu", + "is_tutor": false, + "is_admin": false, + "MSOID": "59043157" + }, + { + "name": "Emily Grant", + "student_nuid": "23335110", + "email": "EmilyGrant@unomaha.edu", + "is_tutor": false, + "is_admin": false, + "MSOID": "90233678" + }, + { + "name": "Tracey Johnson", + "student_nuid": "59529507", + "email": "TraceyJohnson@unomaha.edu", + "is_tutor": false, + "is_admin": false, + "MSOID": "23260931" + }, + { + "name": "James Armstrong", + "student_nuid": "28039211", + "email": "JamesArmstrong@unomaha.edu", + "is_tutor": false, + "is_admin": false, + "MSOID": "68104276" + }, + { + "name": "Karen Walls", + "student_nuid": "05685806", + "email": "KarenWalls@unomaha.edu", + "is_tutor": false, + "is_admin": false, + "MSOID": "50684700" + }, + { + "name": "Richard Jackson", + "student_nuid": "28775317", + "email": "RichardJackson@unomaha.edu", + "is_tutor": false, + "is_admin": false, + "MSOID": "43962341" + }, + { + "name": "Leah Gutierrez", + "student_nuid": "16260696", + "email": "LeahGutierrez@unomaha.edu", + "is_tutor": false, + "is_admin": false, + "MSOID": "57344058" + }, + { + "name": "David Kelley", + "student_nuid": "84248992", + "email": "DavidKelley@unomaha.edu", + "is_tutor": false, + "is_admin": false, + "MSOID": "51348397" + }, + { + "name": "Kristin Smith", + "student_nuid": "87403817", + "email": "KristinSmith@unomaha.edu", + "is_tutor": false, + "is_admin": false, + "MSOID": "19444086" + }, + { + "name": "Cindy Watkins", + "student_nuid": "80240532", + "email": "CindyWatkins@unomaha.edu", + "is_tutor": false, + "is_admin": false, + "MSOID": "68394578" + }, + { + "name": "Ariel Pitts", + "student_nuid": "06967826", + "email": "ArielPitts@unomaha.edu", + "is_tutor": false, + "is_admin": false, + "MSOID": "11642749" + }, + { + "name": "Lauren Bentley", + "student_nuid": "12211265", + "email": "LaurenBentley@unomaha.edu", + "is_tutor": false, + "is_admin": false, + "MSOID": "51603960" + }, + { + "name": "Brooke Gibson", + "student_nuid": "19628448", + "email": "BrookeGibson@unomaha.edu", + "is_tutor": false, + "is_admin": false, + "MSOID": "78168343" + }, + { + "name": "Debra Bell", + "student_nuid": "10793930", + "email": "DebraBell@unomaha.edu", + "is_tutor": false, + "is_admin": false, + "MSOID": "59370826" + }, + { + "name": "Jennifer Zimmerman", + "student_nuid": "36746750", + "email": "JenniferZimmerman@unomaha.edu", + "is_tutor": false, + "is_admin": false, + "MSOID": "19485478" + }, + { + "name": "Sheila Cooper", + "student_nuid": "62702041", + "email": "SheilaCooper@unomaha.edu", + "is_tutor": false, + "is_admin": false, + "MSOID": "01234619" + }, + { + "name": "Michael Estrada", + "student_nuid": "96670163", + "email": "MichaelEstrada@unomaha.edu", + "is_tutor": false, + "is_admin": false, + "MSOID": "52967528" + }, + { + "name": "Nancy Obrien", + "student_nuid": "20791742", + "email": "NancyObrien@unomaha.edu", + "is_tutor": false, + "is_admin": false, + "MSOID": "33977010" + }, + { + "name": "Justin Deleon", + "student_nuid": "71210940", + "email": "JustinDeleon@unomaha.edu", + "is_tutor": false, + "is_admin": false, + "MSOID": "14496981" + } +] \ No newline at end of file diff --git a/backend/src/api/migrations/0002_alter_user_managers.py b/backend/src/api/migrations/0002_alter_user_managers.py new file mode 100644 index 0000000..1062cde --- /dev/null +++ b/backend/src/api/migrations/0002_alter_user_managers.py @@ -0,0 +1,19 @@ +# Generated by Django 4.2.6 on 2023-10-28 22:43 + +import django.db.models.manager +from django.db import migrations + + +class Migration(migrations.Migration): + dependencies = [ + ("api", "0001_initial"), + ] + + operations = [ + migrations.AlterModelManagers( + name="user", + managers=[ + ("generic", django.db.models.manager.Manager()), + ], + ), + ] diff --git a/backend/src/api/migrations/0003_hour.py b/backend/src/api/migrations/0003_hour.py new file mode 100644 index 0000000..ce33119 --- /dev/null +++ b/backend/src/api/migrations/0003_hour.py @@ -0,0 +1,56 @@ +# Generated by Django 4.2.6 on 2023-10-28 22:45 + +import django.db.models.deletion +import django.db.models.manager +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ("api", "0002_alter_user_managers"), + ] + + operations = [ + migrations.CreateModel( + name="Hour", + fields=[ + ( + "id", + models.BigAutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ( + "day_id", + models.IntegerField( + choices=[ + (1, "Monday"), + (2, "Tuesday"), + (3, "Wednesday"), + (4, "Thursday"), + (5, "Friday"), + (6, "Saturday"), + (7, "Sunday"), + ] + ), + ), + ("time_in", models.DateTimeField()), + ("time_out", models.DateTimeField()), + ( + "tutor", + models.ForeignKey( + on_delete=django.db.models.deletion.PROTECT, to="api.user" + ), + ), + ], + options={ + "verbose_name_plural": "tutor_hours", + }, + managers=[ + ("generic", django.db.models.manager.Manager()), + ], + ), + ] diff --git a/backend/src/api/models/hours.py b/backend/src/api/models/hours.py new file mode 100644 index 0000000..f70903c --- /dev/null +++ b/backend/src/api/models/hours.py @@ -0,0 +1,36 @@ +from django.db import models + +from .user import User + + +class HourManager(models.Manager): + def get_all_hours(self): + return super().get_queryset().all() + + def get_tutor(self, name: str): + return super().get_queryset().filter(tutor=name) + + +class Hour(models.Model): + class Day(models.IntegerChoices): + MONDAY = 1 + TUESDAY = 2 + WEDNESDAY = 3 + THURSDAY = 4 + FRIDAY = 5 + SATURDAY = 6 + SUNDAY = 7 + + tutor = models.ForeignKey(User, blank=False, null=False, on_delete=models.PROTECT) + day_id = models.IntegerField(choices=Day.choices) + time_in = models.DateTimeField() + time_out = models.DateTimeField() + + generic = models.Manager() + hours = HourManager() + + def __str__(self): + return str(self.tutor) + " " + "Hours" + + class Meta: + verbose_name_plural = "tutor_hours" diff --git a/backend/src/api/models/user.py b/backend/src/api/models/user.py index 69f31a5..907a272 100644 --- a/backend/src/api/models/user.py +++ b/backend/src/api/models/user.py @@ -52,6 +52,7 @@ class User(models.Model): email = models.EmailField(blank=False, unique=True) MSOID = models.CharField(max_length=75, unique=True) + generic = models.Manager() student = StudentManager() tutor = TutorManager() admin = AdminManager() diff --git a/backend/src/api/scripts/load_students.py b/backend/src/api/scripts/load_students.py new file mode 100644 index 0000000..e13fdaa --- /dev/null +++ b/backend/src/api/scripts/load_students.py @@ -0,0 +1,423 @@ +# from src.api.models.user import User + +from src.api.models.user import User + +data = [ + { + "name": "Stacey Rodriguez", + "student_nuid": "32429909", + "email": "StaceyRodriguez@unomaha.edu", + "is_tutor": False, + "is_admin": False, + "MSOID": "49148305", + }, + { + "name": "Sandra Murillo", + "student_nuid": "72973844", + "email": "SandraMurillo@unomaha.edu", + "is_tutor": False, + "is_admin": False, + "MSOID": "08070241", + }, + { + "name": "Rachael Cooper", + "student_nuid": "61097995", + "email": "RachaelCooper@unomaha.edu", + "is_tutor": False, + "is_admin": False, + "MSOID": "95543505", + }, + { + "name": "Christopher Jones", + "student_nuid": "39914927", + "email": "ChristopherJones@unomaha.edu", + "is_tutor": False, + "is_admin": False, + "MSOID": "77115188", + }, + { + "name": "Robin Wallace", + "student_nuid": "29183692", + "email": "RobinWallace@unomaha.edu", + "is_tutor": False, + "is_admin": False, + "MSOID": "55144506", + }, + { + "name": "Tammy Ortiz", + "student_nuid": "43825707", + "email": "TammyOrtiz@unomaha.edu", + "is_tutor": False, + "is_admin": False, + "MSOID": "30894808", + }, + { + "name": "Sean Lester", + "student_nuid": "83185892", + "email": "SeanLester@unomaha.edu", + "is_tutor": False, + "is_admin": False, + "MSOID": "25643503", + }, + { + "name": "Bryan Williams", + "student_nuid": "78336070", + "email": "BryanWilliams@unomaha.edu", + "is_tutor": False, + "is_admin": False, + "MSOID": "33782263", + }, + { + "name": "Mark Martinez", + "student_nuid": "19649566", + "email": "MarkMartinez@unomaha.edu", + "is_tutor": False, + "is_admin": False, + "MSOID": "05093335", + }, + { + "name": "Catherine Gonzalez", + "student_nuid": "06369040", + "email": "CatherineGonzalez@unomaha.edu", + "is_tutor": False, + "is_admin": False, + "MSOID": "79973014", + }, + { + "name": "Timothy Rodgers", + "student_nuid": "18685480", + "email": "TimothyRodgers@unomaha.edu", + "is_tutor": False, + "is_admin": False, + "MSOID": "94504002", + }, + { + "name": "Mary Campbell", + "student_nuid": "70341362", + "email": "MaryCampbell@unomaha.edu", + "is_tutor": False, + "is_admin": False, + "MSOID": "67737758", + }, + { + "name": "Todd Williams", + "student_nuid": "86440936", + "email": "ToddWilliams@unomaha.edu", + "is_tutor": False, + "is_admin": False, + "MSOID": "62980104", + }, + { + "name": "Michaela Harris", + "student_nuid": "94392425", + "email": "MichaelaHarris@unomaha.edu", + "is_tutor": False, + "is_admin": False, + "MSOID": "32914313", + }, + { + "name": "Kathleen Brooks", + "student_nuid": "19960081", + "email": "KathleenBrooks@unomaha.edu", + "is_tutor": False, + "is_admin": False, + "MSOID": "51603984", + }, + { + "name": "Alexander Wu", + "student_nuid": "40540825", + "email": "AlexanderWu@unomaha.edu", + "is_tutor": False, + "is_admin": False, + "MSOID": "35967682", + }, + { + "name": "Paige Howard", + "student_nuid": "10469026", + "email": "PaigeHoward@unomaha.edu", + "is_tutor": False, + "is_admin": False, + "MSOID": "72103487", + }, + { + "name": "Cory Allen", + "student_nuid": "08508751", + "email": "CoryAllen@unomaha.edu", + "is_tutor": False, + "is_admin": False, + "MSOID": "05175246", + }, + { + "name": "Paul Mercado", + "student_nuid": "95569307", + "email": "PaulMercado@unomaha.edu", + "is_tutor": False, + "is_admin": False, + "MSOID": "53581259", + }, + { + "name": "Renee Sanders", + "student_nuid": "31646307", + "email": "ReneeSanders@unomaha.edu", + "is_tutor": False, + "is_admin": False, + "MSOID": "63682434", + }, + { + "name": "Jose May", + "student_nuid": "40736716", + "email": "JoseMay@unomaha.edu", + "is_tutor": False, + "is_admin": False, + "MSOID": "43360970", + }, + { + "name": "Linda Mcdonald", + "student_nuid": "31662604", + "email": "LindaMcdonald@unomaha.edu", + "is_tutor": False, + "is_admin": False, + "MSOID": "14121241", + }, + { + "name": "Jerome Rodriguez", + "student_nuid": "06488321", + "email": "JeromeRodriguez@unomaha.edu", + "is_tutor": False, + "is_admin": False, + "MSOID": "35879930", + }, + { + "name": "Kimberly Fisher", + "student_nuid": "78391598", + "email": "KimberlyFisher@unomaha.edu", + "is_tutor": False, + "is_admin": False, + "MSOID": "80157106", + }, + { + "name": "Lisa Perez", + "student_nuid": "31454223", + "email": "LisaPerez@unomaha.edu", + "is_tutor": False, + "is_admin": False, + "MSOID": "90150012", + }, + { + "name": "Vickie Phillips", + "student_nuid": "24850919", + "email": "VickiePhillips@unomaha.edu", + "is_tutor": False, + "is_admin": False, + "MSOID": "37809256", + }, + { + "name": "Jeffrey Herrera", + "student_nuid": "03100851", + "email": "JeffreyHerrera@unomaha.edu", + "is_tutor": False, + "is_admin": False, + "MSOID": "81784516", + }, + { + "name": "Michelle Gallagher", + "student_nuid": "58436462", + "email": "MichelleGallagher@unomaha.edu", + "is_tutor": False, + "is_admin": False, + "MSOID": "47161337", + }, + { + "name": "Brian Larson", + "student_nuid": "48046688", + "email": "BrianLarson@unomaha.edu", + "is_tutor": False, + "is_admin": False, + "MSOID": "03158760", + }, + { + "name": "Rachael Jackson", + "student_nuid": "28544975", + "email": "RachaelJackson@unomaha.edu", + "is_tutor": False, + "is_admin": False, + "MSOID": "86189606", + }, + { + "name": "Hailey West", + "student_nuid": "71266084", + "email": "HaileyWest@unomaha.edu", + "is_tutor": False, + "is_admin": False, + "MSOID": "40102153", + }, + { + "name": "Michelle Bell", + "student_nuid": "01324020", + "email": "MichelleBell@unomaha.edu", + "is_tutor": False, + "is_admin": False, + "MSOID": "59043157", + }, + { + "name": "Emily Grant", + "student_nuid": "23335110", + "email": "EmilyGrant@unomaha.edu", + "is_tutor": False, + "is_admin": False, + "MSOID": "90233678", + }, + { + "name": "Tracey Johnson", + "student_nuid": "59529507", + "email": "TraceyJohnson@unomaha.edu", + "is_tutor": False, + "is_admin": False, + "MSOID": "23260931", + }, + { + "name": "James Armstrong", + "student_nuid": "28039211", + "email": "JamesArmstrong@unomaha.edu", + "is_tutor": False, + "is_admin": False, + "MSOID": "68104276", + }, + { + "name": "Karen Walls", + "student_nuid": "05685806", + "email": "KarenWalls@unomaha.edu", + "is_tutor": False, + "is_admin": False, + "MSOID": "50684700", + }, + { + "name": "Richard Jackson", + "student_nuid": "28775317", + "email": "RichardJackson@unomaha.edu", + "is_tutor": False, + "is_admin": False, + "MSOID": "43962341", + }, + { + "name": "Leah Gutierrez", + "student_nuid": "16260696", + "email": "LeahGutierrez@unomaha.edu", + "is_tutor": False, + "is_admin": False, + "MSOID": "57344058", + }, + { + "name": "David Kelley", + "student_nuid": "84248992", + "email": "DavidKelley@unomaha.edu", + "is_tutor": False, + "is_admin": False, + "MSOID": "51348397", + }, + { + "name": "Kristin Smith", + "student_nuid": "87403817", + "email": "KristinSmith@unomaha.edu", + "is_tutor": False, + "is_admin": False, + "MSOID": "19444086", + }, + { + "name": "Cindy Watkins", + "student_nuid": "80240532", + "email": "CindyWatkins@unomaha.edu", + "is_tutor": False, + "is_admin": False, + "MSOID": "68394578", + }, + { + "name": "Ariel Pitts", + "student_nuid": "06967826", + "email": "ArielPitts@unomaha.edu", + "is_tutor": False, + "is_admin": False, + "MSOID": "11642749", + }, + { + "name": "Lauren Bentley", + "student_nuid": "12211265", + "email": "LaurenBentley@unomaha.edu", + "is_tutor": False, + "is_admin": False, + "MSOID": "51603960", + }, + { + "name": "Brooke Gibson", + "student_nuid": "19628448", + "email": "BrookeGibson@unomaha.edu", + "is_tutor": False, + "is_admin": False, + "MSOID": "78168343", + }, + { + "name": "Debra Bell", + "student_nuid": "10793930", + "email": "DebraBell@unomaha.edu", + "is_tutor": False, + "is_admin": False, + "MSOID": "59370826", + }, + { + "name": "Jennifer Zimmerman", + "student_nuid": "36746750", + "email": "JenniferZimmerman@unomaha.edu", + "is_tutor": False, + "is_admin": False, + "MSOID": "19485478", + }, + { + "name": "Sheila Cooper", + "student_nuid": "62702041", + "email": "SheilaCooper@unomaha.edu", + "is_tutor": False, + "is_admin": False, + "MSOID": "01234619", + }, + { + "name": "Michael Estrada", + "student_nuid": "96670163", + "email": "MichaelEstrada@unomaha.edu", + "is_tutor": False, + "is_admin": False, + "MSOID": "52967528", + }, + { + "name": "Nancy Obrien", + "student_nuid": "20791742", + "email": "NancyObrien@unomaha.edu", + "is_tutor": False, + "is_admin": False, + "MSOID": "33977010", + }, + { + "name": "Justin Deleon", + "student_nuid": "71210940", + "email": "JustinDeleon@unomaha.edu", + "is_tutor": False, + "is_admin": False, + "MSOID": "14496981", + }, +] + + +def loaddata(): + for i in data: + user = User() + user.name = i.get("name") + user.student_nuid = i.get("student_nuid") + user.email = i.get("email") + user.is_tutor = False + user.is_admin = False + user.MSOID = i.get("MSOID") + user.save() + print("SAVED!") + + +def run(): + loaddata() diff --git a/backend/src/api/views.py b/backend/src/api/views.py index 4574813..5929d6b 100644 --- a/backend/src/api/views.py +++ b/backend/src/api/views.py @@ -26,7 +26,7 @@ ) # We don't need to check for duplicate class names and function names. -# pylint: disable=E0102,E1101 +# pylint: disable=E0102,E1101,R0914 # -------------------------- CONFIG --------------------------- @@ -407,17 +407,26 @@ def get(self, request): if querystring: if section := querystring.get("section"): sections = sections.filter(section=section) + if professor := querystring.get("professor"): query = Professor.prof.get(full_name=professor) sections = sections.filter(professor=query) + if last_name := querystring.get("last-name"): - query = Professor.prof.get(last_name=last_name.capitalize()) - sections = sections.filter(professor=query) + query = Professor.prof.filter(last_name=last_name.capitalize()) + sections = sections.filter(professor__in=query) + + if first_name := querystring.get("first-name"): + query = Professor.prof.filter(first_name=first_name.capitalize()) + sections = sections.filter(professor__in=query) + if modality := querystring.get("modality"): sections = sections.filter(modality=modality) + if course := querystring.get("course"): - query = Course.generic.get(course_name=course) - sections = sections.filter(course=query) + query = Course.generic.filter(course_name=course) + sections = sections.filter(course__in=query) + serializer = SectionSerializer(sections, many=True) return Response(serializer.data) @@ -445,15 +454,32 @@ def sanitize(self, querystring: str): def get(self, request): courses = Course.generic.all() querystring = self.get_querystring(request=request) + if querystring: if department := querystring.get("department"): courses = courses.filter(course_department=self.sanitize(department)) + if name := querystring.get("name"): courses = courses.filter(course_name=name) + + if name_contains := querystring.get("name-contains"): + courses = courses.filter(course_name__contains=name_contains) + if course_id := querystring.get("course-id"): courses = courses.filter(course_id=course_id) + + if course_id_contains := querystring.get("course-id-contains"): + courses = courses.filter(course_id__contains=course_id_contains) + + if greater_than_code := querystring.get("higher-than"): + courses = courses.filter(course_id__gt=greater_than_code) + + if less_than_code := querystring.get("less-than"): + courses = courses.filter(course_id__lt=less_than_code) + if code := querystring.get("code"): courses = courses.filter(course_code=code) + serializer = CourseSerializer(courses, many=True) return Response(serializer.data) @@ -468,6 +494,131 @@ def post(self, request): # -------------------------- USERS -------------------------- +class APIUserList(APIView): + serializer_class = UserSerializer + renderer_classes = (BrowsableAPIRenderer, JSONRenderer, HTMLFormRenderer) + + def get_querystring(self, request): + return request.GET + + def sanitize(self, querystring: str): + return querystring.upper() + + def get(self, request): + users = User.generic.all() + querystring = self.get_querystring(request=request) + + if querystring: + if department := querystring.get("department"): + users = users.filter(course_department=self.sanitize(department)) + + if name := querystring.get("name"): + users = users.filter(name=name) + + if name_contains := querystring.get("name-contains"): + users = users.filter(name__icontains=name_contains) + + if first_name := querystring.get("first-name"): + users = users.filter(name__istartswith=first_name) + + if last_name := querystring.get("last-name"): + users = users.filter(name__iendswith=last_name) + + if tutor := querystring.get("tutor"): + users = users.filter(is_tutor=tutor.capitalize()) + + if admin := querystring.get("admin"): + users = users.filter(is_admin=admin.capitalize()) + + if msoid := querystring.get("msoid"): + users = users.filter(MSOID=msoid) + + if nuid := querystring.get("nuid"): + users = users.filter(student_nuid=nuid) + + if working := querystring.get("working"): + users = users.filter(is_tutor=True).filter( + is_working=working.capitalize() + ) + + if active := querystring.get("active"): + users = users.filter(is_active=active.capitalize()) + + serializer = UserSerializer(users, many=True) + return Response(serializer.data) + + def post(self, request): + serializer = UserSerializer(data=request.data) + if serializer.is_valid(): + serializer.save() + return Response(serializer.data, status=status.HTTP_201_CREATED) + return Response(serializer.data) + + +# -------------------------- TICKETS -------------------------- + + +class APITicketList(APIView): + serializer_class = TicketSerializer + renderer_classes = (BrowsableAPIRenderer, JSONRenderer, HTMLFormRenderer) + + def get_querystring(self, request): + return request.GET + + def sanitize(self, querystring: str): + return querystring.upper() + + def get(self, request): + users = User.generic.all() + querystring = self.get_querystring(request=request) + + if querystring: + if department := querystring.get("department"): + users = users.filter(course_department=self.sanitize(department)) + + if name := querystring.get("name"): + users = users.filter(name=name) + + if name_contains := querystring.get("name-contains"): + users = users.filter(name__icontains=name_contains) + + if first_name := querystring.get("first-name"): + users = users.filter(name__istartswith=first_name) + + if last_name := querystring.get("last-name"): + users = users.filter(name__iendswith=last_name) + + if tutor := querystring.get("tutor"): + users = users.filter(is_tutor=tutor.capitalize()) + + if admin := querystring.get("admin"): + users = users.filter(is_admin=admin.capitalize()) + + if msoid := querystring.get("msoid"): + users = users.filter(MSOID=msoid) + + if nuid := querystring.get("nuid"): + users = users.filter(student_nuid=nuid) + + if working := querystring.get("working"): + users = users.filter(is_tutor=True).filter( + is_working=working.capitalize() + ) + + if active := querystring.get("active"): + users = users.filter(is_active=active.capitalize()) + + serializer = TicketSerializer(users, many=True) + return Response(serializer.data) + + def post(self, request): + serializer = TicketSerializer(data=request.data) + if serializer.is_valid(): + serializer.save() + return Response(serializer.data, status=status.HTTP_201_CREATED) + return Response(serializer.data) + + class StudentListView(APIView): serializer_class = UserSerializer renderer_classes = (BrowsableAPIRenderer, JSONRenderer, HTMLFormRenderer) diff --git a/backend/tests/test_course.py b/backend/tests/test_course.py index 2332e09..a567f4f 100644 --- a/backend/tests/test_course.py +++ b/backend/tests/test_course.py @@ -48,8 +48,7 @@ def test_default_values(): """ Test that default values are correctly set for course_department and is_active. """ - course = Course.generic.create( - course_name="Random Name", course_id=1234) + course = Course.generic.create(course_name="Random Name", course_id=1234) assert course.course_department == "CSCI" diff --git a/frontend-ts/src/components/assets/ZoomIcon.tsx b/frontend-ts/src/components/assets/ZoomIcon.tsx index 5e441e2..a527682 100644 --- a/frontend-ts/src/components/assets/ZoomIcon.tsx +++ b/frontend-ts/src/components/assets/ZoomIcon.tsx @@ -1,8 +1,8 @@ interface svgProps { - width: string; - height: string; + width: number; + height: number; viewBox: string; - strokeWidth: string; + strokeWidth: number; } export default function ZoomIcon({ diff --git a/frontend-ts/src/components/navigation/Sidebar.tsx b/frontend-ts/src/components/navigation/Sidebar.tsx index 78bdae6..dec3f1a 100644 --- a/frontend-ts/src/components/navigation/Sidebar.tsx +++ b/frontend-ts/src/components/navigation/Sidebar.tsx @@ -197,7 +197,6 @@ export function Sidebar() { height={20} viewBox={"0 0 24 24"} strokeWidth={stroke_width} - shapeRendering={shape_rendering} /> } /> diff --git a/frontend-ts/src/views/development/DevSandbox.tsx b/frontend-ts/src/views/development/DevSandbox.tsx index e69de29..408df9a 100644 --- a/frontend-ts/src/views/development/DevSandbox.tsx +++ b/frontend-ts/src/views/development/DevSandbox.tsx @@ -0,0 +1,5 @@ +export default function DevSandbox() { + return ( + <> + ) +} \ No newline at end of file