Skip to content
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

Create class #262

Merged
merged 11 commits into from
Feb 8, 2024
Merged

Create class #262

merged 11 commits into from
Feb 8, 2024

Conversation

SKairinos
Copy link
Contributor

@SKairinos SKairinos commented Feb 7, 2024

This change is Reviewable

Copy link
Contributor

@faucomte97 faucomte97 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 8 of 10 files at r1, all commit messages.
Reviewable status: 8 of 10 files reviewed, 5 unresolved discussions (waiting on @SKairinos)


backend/api/serializers/klass.py line 16 at r1 (raw file):

# pylint: disable-next=missing-class-docstring,too-many-ancestors
class ClassSerializer(_ClassSerializer):
    teacher = serializers.IntegerField(

Make teacher not required, grab request.user.teacher if teacher is non-admin


backend/api/serializers/klass.py line 20 at r1 (raw file):

    )

    school = serializers.IntegerField(

Remove this field and automatically assign the school to be the teacher's school


backend/api/serializers/klass.py line 62 at r1 (raw file):

            access_code = get_random_string(
                length=5,
                allowed_chars=string.ascii_uppercase + string.digits,

Remove digits


backend/api/tests/serializers/test_klass.py line 23 at r1 (raw file):

        self.class_1 = Class.objects.get(name="Class 1 @ School 1")

    def test_validate_name__name_not_unique(self):

Add test to check admin teacher can't create a class for teacher outside of school


backend/api/tests/views/test_klass.py line 83 at r1 (raw file):

        )

    def test_create(self):

Add a test checking that admin teacher can successfully create a class for a different teacher

Copy link
Contributor

@faucomte97 faucomte97 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 8 of 10 files reviewed, 6 unresolved discussions (waiting on @SKairinos)


backend/Pipfile line 31 at r1 (raw file):

google-cloud-container = "==2.3.0"
# "django-anymail[amazon_ses]" = "==7.0.*"
codeforlife = {ref = "create_class", git = "https://github.com/ocadotechnology/codeforlife-package-python.git"}

update package

Copy link
Contributor Author

@SKairinos SKairinos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewable status: 8 of 10 files reviewed, 6 unresolved discussions (waiting on @faucomte97)


backend/Pipfile line 31 at r1 (raw file):

Previously, faucomte97 (Florian Aucomte) wrote…

update package

Done.


backend/api/serializers/klass.py line 16 at r1 (raw file):

Previously, faucomte97 (Florian Aucomte) wrote…

Make teacher not required, grab request.user.teacher if teacher is non-admin

Done.


backend/api/serializers/klass.py line 20 at r1 (raw file):

Previously, faucomte97 (Florian Aucomte) wrote…

Remove this field and automatically assign the school to be the teacher's school

Done.


backend/api/serializers/klass.py line 62 at r1 (raw file):

Previously, faucomte97 (Florian Aucomte) wrote…

Remove digits

Done.


backend/api/tests/serializers/test_klass.py line 23 at r1 (raw file):

Previously, faucomte97 (Florian Aucomte) wrote…

Add test to check admin teacher can't create a class for teacher outside of school

Done.


backend/api/tests/views/test_klass.py line 83 at r1 (raw file):

Previously, faucomte97 (Florian Aucomte) wrote…

Add a test checking that admin teacher can successfully create a class for a different teacher

Done.

Copy link
Contributor

@faucomte97 faucomte97 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 2 of 10 files at r1, 6 of 6 files at r2, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @SKairinos)


backend/api/serializers/klass.py line 46 at r2 (raw file):

        user = self.request_school_teacher_user
        if not queryset.filter(school=user.teacher.school_id).exists():

This seems to just check whether the request teacher's school exists (which it always will).
Instead, shouldn't this check whether value != user.teacher.school_id?


backend/api/tests/views/test_klass.py line 85 at r2 (raw file):

    def test_create__self(self):
        """
        Teacher can create a class with their self as the class owner.

themself

Copy link
Contributor Author

@SKairinos SKairinos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @faucomte97)


backend/api/serializers/klass.py line 46 at r2 (raw file):

Previously, faucomte97 (Florian Aucomte) wrote…

This seems to just check whether the request teacher's school exists (which it always will).
Instead, shouldn't this check whether value != user.teacher.school_id?

Not quite. The original queryset checks if the teacher exists at all
queryset = Teacher.objects.filter(id=value)
Then we further filter by school to check if the teacher exists in the specific school
queryset.filter(school=user.teacher.school_id).exists()


backend/api/tests/views/test_klass.py line 85 at r2 (raw file):

Previously, faucomte97 (Florian Aucomte) wrote…

themself

Done.

Copy link
Contributor

@faucomte97 faucomte97 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewed 1 of 1 files at r3, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @SKairinos)

@faucomte97 faucomte97 merged commit 233dc83 into development Feb 8, 2024
3 checks passed
@faucomte97 faucomte97 deleted the create_class branch February 8, 2024 11:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants