From 16611e8ac37a0b3e360b2307a364dd23c1b7eda3 Mon Sep 17 00:00:00 2001 From: Steve Brownlee Date: Wed, 10 Jul 2024 21:39:37 -0500 Subject: [PATCH 1/2] Start tracking the DBML --- LearningAPI/views/student_view.py | 1 + bangazon.dbml | 105 ++++++++++++++++++++++++++++++ 2 files changed, 106 insertions(+) create mode 100644 bangazon.dbml diff --git a/LearningAPI/views/student_view.py b/LearningAPI/views/student_view.py index 74664a5..150b688 100644 --- a/LearningAPI/views/student_view.py +++ b/LearningAPI/views/student_view.py @@ -295,6 +295,7 @@ def assess(self, request, pk): try: existing_assessment = StudentAssessment.objects.get(student=student, assessment=assessment) assessment_uri = request.build_absolute_uri(f'/assessments/{existing_assessment.id}') + return Response( { 'message': f'Conflict: {student.full_name} is already assigned to the {assessment.name} assessment' }, status=status.HTTP_409_CONFLICT, diff --git a/bangazon.dbml b/bangazon.dbml new file mode 100644 index 0000000..46d7ef8 --- /dev/null +++ b/bangazon.dbml @@ -0,0 +1,105 @@ +Table Order { + Id int PK + PaymentTypeId int + CustomerId int + CreatedAt datetime +} + +Table Product { + Id int PK + Name varchar(50) + CustomerId int + Price decimal + Description varchar(255) + Quantity int + Location varchar(75) + ImagePath varchar(255) + CreatedAt datetime + ProductCategoryId int +} + +Table ProductCategory { + Id int pk + Name varchar(55) +} + +Table OrderProduct { + OrderProductId int PK + OrderId int + ProductId int +} + +Table Customer { + Id int PK + FirstName varchar(55) + LastName varchar(55) + Email varchar(55) + CreatedAt datetime + IsActive boolean +} + +Table ProductRating { + Id int pk + CustomerId int + ProductId int + Score int +} + +Ref FK_OrderProduct_Order { + OrderProduct.OrderId > Order.Id +} + +Ref FK_OrderProduct_Product { + OrderProduct.ProductId > Product.Id +} + +Ref FK_Product_Merchant { + Product.CustomerId > Customer.Id +} + +Table PaymentType { + PaymentTypeId int PK + MerchantName varchar(25) + AcctNumber varchar(25) + ExpirationDate datetime + CustomerId int + CreatedAt datetime +} + +Table Favorite { + Id int PK + CustomerId int + SellerId int +} + + +Table Recommendation { + Id int PK + RecommenderId int + CustomerId int + ProductId int +} + +Ref FK_OrderPaymentType{ + Order.PaymentTypeId > PaymentType.PaymentTypeId +} + +Ref FK_OrderCustomer{ + Order.CustomerId > Customer.Id +} + +Ref: "Customer"."Id" < "ProductRating"."CustomerId" + +Ref: "Product"."Id" < "ProductRating"."ProductId" + +Ref: "Customer"."Id" < "Favorite"."CustomerId" + +Ref: "Customer"."Id" < "Favorite"."SellerId" + +Ref: "Customer"."Id" < "Recommendation"."RecommenderId" + +Ref: "Customer"."Id" < "Recommendation"."CustomerId" + +Ref: "Product"."Id" < "Recommendation"."ProductId" + +Ref: "ProductCategory"."Id" < "Product"."ProductCategoryId" \ No newline at end of file From 31fca5f1f829dac5de81ea22b02cf6ac5ce796ea Mon Sep 17 00:00:00 2001 From: Steve Brownlee Date: Tue, 16 Jul 2024 14:46:24 -0500 Subject: [PATCH 2/2] Add new field to admin interface for StudentCohort --- LearningAPI/admin.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/LearningAPI/admin.py b/LearningAPI/admin.py index 6f99a7b..626ca41 100644 --- a/LearningAPI/admin.py +++ b/LearningAPI/admin.py @@ -87,8 +87,9 @@ class CapstoneTimelineAdmin(admin.ModelAdmin): @admin.register(NssUserCohort) class NssUserCohortAdmin(admin.ModelAdmin): """For assigning students to cohorts""" - list_display = ('nss_user', 'cohort',) + list_display = ('nss_user', 'cohort', 'is_github_org_member') search_fields = ["nss_user__user__last_name"] + ordering = ('-pk',) search_help_text = "Search by last name" @admin.register(StudentTag)