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

IEEE-21 /api/event/teams/team #280

Merged
merged 23 commits into from
Jul 3, 2021
Merged

IEEE-21 /api/event/teams/team #280

merged 23 commits into from
Jul 3, 2021

Conversation

arshinmar
Copy link
Contributor

@arshinmar arshinmar commented Jun 8, 2021

Overview

  • Resolves Issue 21
  • Piggybacks from created CurrentTeamAPIView and serializer with test #131
  • Added API functionality for getting team info.
  • Created a team serializer.
  • Checks in tests.py ensure that profile, team and user are effectively linked and serializer info matches expected model.

Unit Tests Created

  • Added test additions to test_API file.
  • Added serializer & linking tests to tests.py.

Steps to QA

  • Simply run regular tests.

Copy link
Member

@grahamhoyes grahamhoyes left a comment

Choose a reason for hiding this comment

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

See comments.

I also think your version of Black might be wrong, since some of the formatting doesn't agree. Run black --version, and make sure you're on version 19.10b0. The later versions change formatting habits a bit it seems.

.gitignore Outdated Show resolved Hide resolved
hackathon_site/event/models.py Outdated Show resolved Hide resolved
@@ -10,7 +10,20 @@ class Meta:
fields = ("id", "name")


class TeamSerializer(serializers.ModelSerializer):
Copy link
Member

Choose a reason for hiding this comment

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

It wasn't in the ticket, but I think we should add a profiles serializer into here. That way, on the frontend, we can just get /api/event/teams/team/, and we'll have all the information we need about the team (aka, the members on it), rather than having to make a separate request.

When we eventually have a list view of /api/event/teams/ for the admin side of the site, that will also come in handy so we don't have to fetch the list of team members separately.

To do that, you won't want to use the ProfileSerializer below, since that includes the team - so you'll end up with a circular reference. I would create a new ProfileInTeamSerializer, that includes the profile as well as important related user fields - first name, last name, email. I think you can just put user__first_name etc in the fields list, otherwise you'll need a user serializer too.

Copy link
Member

Choose a reason for hiding this comment

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

Actually, disregard this for now. I'll create a separate ticket, so that we don't get in the habit of scope creep (which I am bad for).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

cool, is it ok if I resolve this?

Copy link
Member

Choose a reason for hiding this comment

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

Let's keep it unresolved just so it's visible for future reference

hackathon_site/event/test_api.py Outdated Show resolved Hide resolved
hackathon_site/event/tests.py Outdated Show resolved Hide resolved
hackathon_site/event/views.py Outdated Show resolved Hide resolved
hackathon_site/event/views.py Outdated Show resolved Hide resolved
hackathon_site/event/views.py Outdated Show resolved Hide resolved
@arshinmar
Copy link
Contributor Author

See comments.

I also think your version of Black might be wrong, since some of the formatting doesn't agree. Run black --version, and make sure you're on version 19.10b0. The later versions change formatting habits a bit it seems.

I'm having issues installing Black with that version. For example, "npm install black==19.10b0" or "yarn install black==19.10.0". I also tried "i" instead of install and also a decimal instead of b. Nothing seems to work.

Other than that, everything seems ok

@arshinmar
Copy link
Contributor Author

hey, so I still don’t fully understand the error

the test function that is bringing up the error is

def test_join_team(self):
    """
    Once the user has applied and before they have been reviewed, they can join
    a different team
    """
    self._login()
    self._apply()

    new_team = RegistrationTeam.objects.create()
    data = {"team_code": new_team.team_code}
    response = self.client.post(self.view, data=data)
    self.assertRedirects(response, self.view)
    redirected_response = self.client.get(response.url)
    self.assertContains(redirected_response, new_team.team_code)

The error it brings up is the same as the one on GitHub Actions.

My issue is the error still persists after adding the import statements shown below and changing the usages of the word “Team” to “EventTeam” in event/tests.py.

from event.models import Profile, User
from event.models import Team as EventTeam
from hackathon_site.tests import SetupUserMixin
from registration.models import Team as RegistrationTeam

I didn't see any of the team imports (other than the word TeamSerializer, which we aren't using in the function above) be greyed out.

Furthermore, it seems like when I use new_team = RegistrationTeam.(...) it fails to post. But when I use new_team = EventTeam.(...), it seems like it posts, but the response doesn't have an URL.

I tried changing the event/views.py code to include a similar input from event.models import Team as EventTeam, but that doesn't change anything either.

I've committed my code, if you could let me know what am I missing in my analysis, it would be much appreciated.

@arshinmar arshinmar merged commit 60c430a into develop Jul 3, 2021
@arshinmar arshinmar deleted the 21-api-team branch July 3, 2021 02:45
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