Skip to content

Commit

Permalink
lint and pre-commit fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
rohangpta committed Oct 16, 2022
1 parent bb601bb commit 3137905
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 34 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ repos:
hooks:
- id: black
name: black
entry: black
entry: cd backend && pipenv run black
language: python
types: [python]
require_serial: true
Expand Down
8 changes: 2 additions & 6 deletions backend/clubs/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1574,9 +1574,7 @@ class ApplicationCommittee(models.Model):

name = models.TextField(blank=True)
application = models.ForeignKey(
ClubApplication,
related_name="committees",
on_delete=models.CASCADE,
ClubApplication, related_name="committees", on_delete=models.CASCADE,
)

def get_word_limit(self):
Expand Down Expand Up @@ -1628,9 +1626,7 @@ class ApplicationMultipleChoice(models.Model):

value = models.TextField(blank=True)
question = models.ForeignKey(
ApplicationQuestion,
related_name="multiple_choice",
on_delete=models.CASCADE,
ApplicationQuestion, related_name="multiple_choice", on_delete=models.CASCADE,
)


Expand Down
10 changes: 3 additions & 7 deletions backend/clubs/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2012,9 +2012,7 @@ def get_clubs(self, obj):
# hide non public memberships if not superuser
if user is None or not user.has_perm("clubs.manage_club"):
queryset = queryset.filter(
membership__person=obj,
membership__public=True,
approved=True,
membership__person=obj, membership__public=True, approved=True,
)

serializer = MembershipClubListSerializer(
Expand Down Expand Up @@ -2415,8 +2413,7 @@ def save(self):
ApplicationMultipleChoice.objects.filter(question=question_obj).delete()
for choice in multiple_choice:
ApplicationMultipleChoice.objects.create(
value=choice["value"],
question=question_obj,
value=choice["value"], question=question_obj,
)

# manually create committee choices as Django does not
Expand Down Expand Up @@ -2705,8 +2702,7 @@ def save(self):
for name in committees:
if name not in prev_committee_names:
ApplicationCommittee.objects.create(
name=name,
application=application_obj,
name=name, application=application_obj,
)

return application_obj
Expand Down
27 changes: 7 additions & 20 deletions backend/clubs/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1080,8 +1080,7 @@ def get_queryset(self):
self.request.user, get_user_model()
):
SearchQuery(
person=self.request.user,
query=self.request.query_params.get("search"),
person=self.request.user, query=self.request.query_params.get("search"),
).save()

# select subset of clubs if requested
Expand Down Expand Up @@ -1673,9 +1672,7 @@ def constitutions(self, request, *args, **kwargs):
query = (
Club.objects.filter(badges=badge, archived=False)
.order_by(Lower("name"))
.prefetch_related(
Prefetch("asset_set", to_attr="prefetch_asset_set"),
)
.prefetch_related(Prefetch("asset_set", to_attr="prefetch_asset_set"),)
)
if request.user.is_authenticated:
query = query.prefetch_related(
Expand Down Expand Up @@ -3222,9 +3219,7 @@ def destroy(self, request, *args, **kwargs):

def get_queryset(self):
return MembershipRequest.objects.filter(
person=self.request.user,
withdrew=False,
club__archived=False,
person=self.request.user, withdrew=False, club__archived=False,
)


Expand Down Expand Up @@ -4348,9 +4343,7 @@ def get(self, request):

try:
response = zoom_api_call(
request.user,
"GET",
"https://api.zoom.us/v2/users/{uid}/settings",
request.user, "GET", "https://api.zoom.us/v2/users/{uid}/settings",
)
except requests.exceptions.HTTPError as e:
raise DRFValidationError(
Expand Down Expand Up @@ -4471,9 +4464,7 @@ def get_operation_id(self, **kwargs):
def get_object(self):
user = self.request.user
prefetch_related_objects(
[user],
"profile__school",
"profile__major",
[user], "profile__school", "profile__major",
)
return user

Expand Down Expand Up @@ -4906,9 +4897,7 @@ def question_response(self, *args, **kwargs):
}
)
submission = ApplicationSubmission.objects.create(
user=self.request.user,
application=application,
committee=committee,
user=self.request.user, application=application, committee=committee,
)
for question_pk in questions:
question = ApplicationQuestion.objects.filter(pk=question_pk).first()
Expand All @@ -4929,9 +4918,7 @@ def question_response(self, *args, **kwargs):
text = question_data.get("text", None)
if text is not None and text != "":
obj = ApplicationQuestionResponse.objects.create(
text=text,
question=question,
submission=submission,
text=text, question=question, submission=submission,
).save()
response = Response(ApplicationQuestionResponseSerializer(obj).data)
elif question_type == ApplicationQuestion.MULTIPLE_CHOICE:
Expand Down

0 comments on commit 3137905

Please sign in to comment.