-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add delete button to allow coordinators to drop sections #443
Open
KartavyaSharma
wants to merge
13
commits into
master
Choose a base branch
from
feat/delete-sections/main
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
d223b4f
Added destroy method to section view and added tests
KartavyaSharma 86b0537
Added destroy method to section view and added tests
KartavyaSharma 533c942
Fixed incorrect export
KartavyaSharma 1cecffb
Better logging for section delete method
KartavyaSharma e2e56b3
Added delete button
jacovkim e53cc8b
Coordinators must remove all students manually for a delete section r…
KartavyaSharma 92fd246
added warning and invalidating queries
jacovkim 268962f
Merge branch 'feat/delete-sections/main' of https://github.com/csmber…
jacovkim 4da7c30
Fixed eslint error for courseIds variable in MentorSectionInfo.tsx
KartavyaSharma 6997dc7
update drop to delete
jacovkim 3bc3ff9
changes 2
jacovkim 410e740
Deleted comments in css
jacovkim c8b1998
Mooved coordinator check before student check, made delete section pr…
KartavyaSharma File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import pytest | ||
from django.urls import reverse | ||
from scheduler.factories import ( | ||
CoordinatorFactory, | ||
CourseFactory, | ||
MentorFactory, | ||
SectionFactory, | ||
StudentFactory, | ||
UserFactory, | ||
) | ||
from scheduler.models import Section | ||
|
||
|
||
@pytest.fixture(name="setup") | ||
def setup_test(): | ||
""" | ||
Create a course, coordinator, mentor, and a student for testing. | ||
""" | ||
# Setup course | ||
course = CourseFactory.create() | ||
# Setup sections | ||
section_one = create_section(course) | ||
section_two = create_section(course) | ||
# Setup students | ||
create_students(course, section_one, 3) | ||
create_students(course, section_two, 3) | ||
# Setup coordinator for course | ||
coordinator_user = UserFactory.create() | ||
# Create coordinator for course | ||
CoordinatorFactory.create(user=coordinator_user, course=course) | ||
|
||
return ( | ||
section_one, | ||
coordinator_user, | ||
) | ||
|
||
|
||
@pytest.mark.django_db | ||
def test_section_delete(client, setup): | ||
KartavyaSharma marked this conversation as resolved.
Show resolved
Hide resolved
|
||
""" | ||
Test that a section can be deleted. | ||
""" | ||
( | ||
section_one, | ||
coordinator_user, | ||
) = setup | ||
# Login as coordinator | ||
client.force_login(coordinator_user) | ||
# Delete section | ||
response = client.delete(reverse("section-detail", kwargs={"pk": section_one.id})) | ||
# Check that section was deleted | ||
assert response.status_code == 204 | ||
assert Section.objects.count() == 1 | ||
|
||
|
||
def create_students(course, section, quantity): | ||
""" | ||
Creates a given number of students for a given section. | ||
""" | ||
student_users = UserFactory.create_batch(quantity) | ||
students = [] | ||
for student_user in student_users: | ||
student = StudentFactory.create( | ||
user=student_user, course=course, section=section | ||
) | ||
students.append(student) | ||
return students | ||
|
||
|
||
def create_section(course): | ||
""" | ||
Creates a section for a given course. | ||
""" | ||
mentor_user = UserFactory.create() | ||
mentor = MentorFactory.create(user=mentor_user, course=course) | ||
section = SectionFactory.create(mentor=mentor) | ||
return section |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are a lot of ESLint warnings here about unused variables; you should delete the unused variables here.