Skip to content

Commit

Permalink
Enhanced loading CSV into database
Browse files Browse the repository at this point in the history
  • Loading branch information
nulzo committed Oct 29, 2023
1 parent 8f3dc53 commit afddfbf
Show file tree
Hide file tree
Showing 17 changed files with 1,157 additions and 13 deletions.
4 changes: 4 additions & 0 deletions backend/.dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,7 @@ env.dist

# No reason to send a gitignore to the container
.gitignore

data

data/
1 change: 1 addition & 0 deletions backend/base/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@
view=routing.StudentDetailView.as_view(),
name="Student Detail View",
),
path("api/users/", view=routing.APIUserList.as_view()),
# path("api/students/<str:student_pk>"),
# path("api/students/<str:grade_level>"),
# Admin (Superuser) URLS
Expand Down
32 changes: 32 additions & 0 deletions backend/generate_ticket.py
Original file line number Diff line number Diff line change
@@ -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())
16 changes: 15 additions & 1 deletion backend/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions backend/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 2 additions & 1 deletion backend/src/api/admin.py
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -10,3 +10,4 @@
admin.site.register(user.User)
admin.site.register(sections.Section)
admin.site.register(messages.Messages)
admin.site.register(hours.Hour)
Loading

0 comments on commit afddfbf

Please sign in to comment.