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

tech: Apply Black to the entire codebase. #1814

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Migrate code style to Black
8ae6bfea62e0714cc86371c0618a43987a42ee10
78b659721671dffbccaf2f1a38695b1f9cb50be0
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ before starting work on new features.
$ cd amy
~~~

1. Configure git to automatically ignore revisions in the `.git-blame-ignore-revs`:

~~~
$ git config blame.ignoreRevsFile .git-blame-ignore-revs
~~~

1. Install Django and other dependencies:

~~~
Expand Down
2 changes: 1 addition & 1 deletion amy/api/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@


class ApiConfig(AppConfig):
name = 'api'
name = "api"
78 changes: 44 additions & 34 deletions amy/api/filters.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from django.forms import widgets
from django_filters import rest_framework as filters

from extrequests.filters import (
Expand All @@ -11,43 +10,47 @@


class EventFilter(filters.FilterSet):
start_after = filters.DateFilter(field_name='start', lookup_expr='gte')
start_before = filters.DateFilter(field_name='start', lookup_expr='lte')
end_after = filters.DateFilter(field_name='end', lookup_expr='gte')
end_before = filters.DateFilter(field_name='end', lookup_expr='lte')
start_after = filters.DateFilter(field_name="start", lookup_expr="gte")
start_before = filters.DateFilter(field_name="start", lookup_expr="lte")
end_after = filters.DateFilter(field_name="end", lookup_expr="gte")
end_before = filters.DateFilter(field_name="end", lookup_expr="lte")
tags = filters.ModelMultipleChoiceFilter(
field_name='tags__name',
to_field_name='name',
field_name="tags__name",
to_field_name="name",
queryset=Tag.objects.all(),
conjoined=True,
)
order_by = filters.OrderingFilter(
fields=(
'slug',
'start',
'end',
"slug",
"start",
"end",
),
)

class Meta:
model = Event
fields = (
'completed', 'tags',
'administrator', 'host',
'start', 'start_before', 'start_after',
'end', 'end_before', 'end_after',
'country',
"completed",
"tags",
"administrator",
"host",
"start",
"start_before",
"start_after",
"end",
"end_before",
"end_after",
"country",
)


class TaskFilter(filters.FilterSet):
role = filters.CharFilter(field_name='role__name')
role = filters.CharFilter(field_name="role__name")

class Meta:
model = Task
fields = (
'role',
)
fields = ("role",)


def filter_instructors(queryset, name, value):
Expand All @@ -61,20 +64,27 @@ def filter_instructors(queryset, name, value):


class PersonFilter(filters.FilterSet):
is_instructor = filters.BooleanFilter(method=filter_instructors,
label='Is instructor?')
is_instructor = filters.BooleanFilter(
method=filter_instructors, label="Is instructor?"
)

order_by = NamesOrderingFilter(
fields=(
'email',
),
fields=("email",),
)

class Meta:
model = Person
fields = (
'badges', 'username', 'personal', 'middle', 'family', 'email',
'may_contact', 'publish_profile', 'github', 'country',
"badges",
"username",
"personal",
"middle",
"family",
"email",
"may_contact",
"publish_profile",
"github",
"country",
)


Expand All @@ -83,15 +93,15 @@ class IdInFilter(filters.BaseInFilter, filters.NumberFilter):


class TrainingRequestFilterIDs(TrainingRequestFilter):
ids = IdInFilter(field_name='id', lookup_expr='in')
ids = IdInFilter(field_name="id", lookup_expr="in")

class Meta(TrainingRequestFilter.Meta):
fields = [
'ids',
'search',
'group_name',
'state',
'matched',
'affiliation',
'location',
"ids",
"search",
"group_name",
"state",
"matched",
"affiliation",
"location",
]
94 changes: 46 additions & 48 deletions amy/api/renderers.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,58 +8,56 @@

class TrainingRequestCSVColumns:
translation_labels = {
'created_at': 'Created at',
'last_updated_at': 'Last updated at',
'state': 'State',
'person': 'Matched Trainee',
'person_id': 'Matched Trainee ID',
'awards': 'Badges',
'training_tasks': 'Training Tasks',
'review_process': 'Application Type',
'group_name': 'Registration Code',
'personal': 'Personal',
'middle': 'Middle',
'family': 'Family',
'email': 'Email',
'secondary_email': 'Secondary email',
'github': 'GitHub username',
'underrepresented': 'Underrepresented',
'underrepresented_details': 'Underrepresented (reason)',
'occupation': 'Occupation',
'occupation_other': 'Occupation (other)',
'affiliation': 'Affiliation',
'location': 'Location',
'country': 'Country',
'underresourced': 'Underresourced institution',
'domains': 'Expertise areas',
'domains_other': 'Expertise areas (other)',
'nonprofit_teaching_experience': 'Non-profit teaching experience',
'previous_involvement': 'Previous Involvement',
'previous_training': 'Previous Training in Teaching',
'previous_training_other': 'Previous Training (other)',
'previous_training_explanation': 'Previous Training (explanation)',
'previous_experience': 'Previous Experience in Teaching',
'previous_experience_other': 'Previous Experience (other)',
'previous_experience_explanation': 'Previous Experience (explanation)',
'programming_language_usage_frequency': 'Programming Language Usage',
'teaching_frequency_expectation': 'Teaching Frequency Expectation',
'teaching_frequency_expectation_other': 'Teaching Frequency Expectation (other)',
'max_travelling_frequency': 'Max Travelling Frequency',
'max_travelling_frequency_other': 'Max Travelling Frequency (other)',
'reason': 'Reason for undertaking training',
'user_notes': 'User notes',
'training_completion_agreement': 'Training completion agreement (yes/no)',
'workshop_teaching_agreement': 'Workshop teaching agreement (yes/no)',
'data_privacy_agreement': 'Data privacy agreement (yes/no)',
'code_of_conduct_agreement': 'Code of Conduct agreement (yes/no)',
"created_at": "Created at",
"last_updated_at": "Last updated at",
"state": "State",
"person": "Matched Trainee",
"person_id": "Matched Trainee ID",
"awards": "Badges",
"training_tasks": "Training Tasks",
"review_process": "Application Type",
"group_name": "Registration Code",
"personal": "Personal",
"middle": "Middle",
"family": "Family",
"email": "Email",
"secondary_email": "Secondary email",
"github": "GitHub username",
"underrepresented": "Underrepresented",
"underrepresented_details": "Underrepresented (reason)",
"occupation": "Occupation",
"occupation_other": "Occupation (other)",
"affiliation": "Affiliation",
"location": "Location",
"country": "Country",
"underresourced": "Underresourced institution",
"domains": "Expertise areas",
"domains_other": "Expertise areas (other)",
"nonprofit_teaching_experience": "Non-profit teaching experience",
"previous_involvement": "Previous Involvement",
"previous_training": "Previous Training in Teaching",
"previous_training_other": "Previous Training (other)",
"previous_training_explanation": "Previous Training (explanation)",
"previous_experience": "Previous Experience in Teaching",
"previous_experience_other": "Previous Experience (other)",
"previous_experience_explanation": "Previous Experience (explanation)",
"programming_language_usage_frequency": "Programming Language Usage",
"teaching_frequency_expectation": "Teaching Frequency Expectation",
"teaching_frequency_expectation_other": "Teaching Frequency Expectation (other)", # noqa: line too long
"max_travelling_frequency": "Max Travelling Frequency",
"max_travelling_frequency_other": "Max Travelling Frequency (other)",
"reason": "Reason for undertaking training",
"user_notes": "User notes",
"training_completion_agreement": "Training completion agreement (yes/no)",
"workshop_teaching_agreement": "Workshop teaching agreement (yes/no)",
"data_privacy_agreement": "Data privacy agreement (yes/no)",
"code_of_conduct_agreement": "Code of Conduct agreement (yes/no)",
}

def __init__(self):
self.header = self.serializer.Meta.fields
self.labels = {
k: v
for k, v in self.translation_labels.items()
if k in self.header
k: v for k, v in self.translation_labels.items() if k in self.header
}


Expand All @@ -69,4 +67,4 @@ class TrainingRequestCSVRenderer(CSVRenderer, TrainingRequestCSVColumns):

class TrainingRequestManualScoreCSVRenderer(CSVRenderer, TrainingRequestCSVColumns):
serializer = TrainingRequestForManualScoringSerializer
format = 'csv2'
format = "csv2"