Skip to content

Commit

Permalink
Run black formatter in github action
Browse files Browse the repository at this point in the history
  • Loading branch information
manjurulhoque committed Oct 10, 2024
1 parent f29dceb commit f6f4998
Show file tree
Hide file tree
Showing 13 changed files with 55 additions and 41 deletions.
2 changes: 1 addition & 1 deletion .env.dev.sample
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ RECAPTCHA_PRIVATE_KEY=secret
# To enable prometheus monitoring
ENABLE_PROMETHEUS=0

DEBUG=False
DEBUG=True
6 changes: 3 additions & 3 deletions .github/workflows/pythonapp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
# - name: Run black code formatter
# run: |
# black --check --exclude=./*/migrations/ ./
- name: Run black code formatter
run: |
black --check --exclude='./*/migrations/' ./
# - name: Django Testing project
# run: |
# python manage.py collectstatic
Expand Down
7 changes: 5 additions & 2 deletions jobs/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,8 +315,11 @@

if ENABLE_PROMETHEUS:
INSTALLED_APPS += ["django_prometheus"]
MIDDLEWARE = ['django_prometheus.middleware.PrometheusBeforeMiddleware'] + MIDDLEWARE + \
['django_prometheus.middleware.PrometheusAfterMiddleware', "jobs.middlewares.CustomMiddleware"]
MIDDLEWARE = (
["django_prometheus.middleware.PrometheusBeforeMiddleware"]
+ MIDDLEWARE
+ ["django_prometheus.middleware.PrometheusAfterMiddleware", "jobs.middlewares.CustomMiddleware"]
)
MIDDLEWARE.append("jobs.middlewares.CustomMiddleware")
MIDDLEWARE.append("jobs.middlewares.ResponseTimeMiddleware")
MIDDLEWARE.append("jobs.middlewares.ErrorTrackingMiddleware")
11 changes: 6 additions & 5 deletions jobs/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@
permission_classes=(permissions.AllowAny,),
)

lang_patterns = i18n_patterns(path("", include("jobsapp.urls")),
path("", include("accounts.urls")),
path("", include("resume_cv.urls")),
)
lang_patterns = i18n_patterns(
path("", include("jobsapp.urls")),
path("", include("accounts.urls")),
path("", include("resume_cv.urls")),
)

# sitemaps = {
# '': JobViewSitemap
Expand Down Expand Up @@ -61,7 +62,7 @@
]

if settings.ENABLE_PROMETHEUS:
urlpatterns.append(path("", include('django_prometheus.urls')))
urlpatterns.append(path("", include("django_prometheus.urls")))

if bool(settings.DEBUG):
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
Expand Down
2 changes: 1 addition & 1 deletion jobsapp/api/views/employee.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

class ApplyJobApiView(CreateAPIView):
serializer_class = ApplyJobSerializer
http_method_names = [u"post"]
http_method_names = ["post"]
permission_classes = [IsAuthenticated, IsEmployee]

def perform_create(self, serializer):
Expand Down
2 changes: 1 addition & 1 deletion jobsapp/graphql/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def __init__(self, message=None):

class WrongUsage(GraphQLError):
"""
Internal exception
Internal exception
"""

default_message = _("Wrong usage, check your code!.")
Expand Down
8 changes: 2 additions & 6 deletions jobsapp/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,9 @@
)

response_time_histogram = Histogram(
name='app_response_time_seconds',
documentation='Response time for requests',
labelnames=['method', 'endpoint']
name="app_response_time_seconds", documentation="Response time for requests", labelnames=["method", "endpoint"]
)

error_rates_counter = Counter(
name='app_error_rates_total',
documentation='The total number of errors',
labelnames=['status_code', 'endpoint']
name="app_error_rates_total", documentation="The total number of errors", labelnames=["status_code", "endpoint"]
)
2 changes: 1 addition & 1 deletion jobsapp/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ def dispatch(self, request, *args, **kwargs):
user = request.user
if user.role != "employer":
return self.handle_no_permission()
return super().dispatch(request, *args, **kwargs)
return super().dispatch(request, *args, **kwargs)
2 changes: 1 addition & 1 deletion jobsapp/views/home.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def get_queryset(self):

def get_context_data(self, **kwargs):
data = super().get_context_data(**kwargs)
data['total_jobs'] = self.model.objects.unfilled().count()
data["total_jobs"] = self.model.objects.unfilled().count()
return data


Expand Down
4 changes: 2 additions & 2 deletions resume_cv/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@


class ResumeCvConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'resume_cv'
default_auto_field = "django.db.models.BigAutoField"
name = "resume_cv"
2 changes: 1 addition & 1 deletion resume_cv/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@


def resume_cv_directory_path(instance, filename):
return 'resumes/{0}/{1}'.format(strftime('%Y/%m/%d'), generate_file_name() + '.' + filename.split('.')[-1])
return "resumes/{0}/{1}".format(strftime("%Y/%m/%d"), generate_file_name() + "." + filename.split(".")[-1])


class ResumeCvCategory(models.Model):
Expand Down
46 changes: 30 additions & 16 deletions resume_cv/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class TemplateListView(ListView):
"""
Get list of templates to create resume/cv
"""

model = ResumeCvTemplate
context_object_name = "templates"
template_name = "resumes/templates.html"
Expand All @@ -27,14 +28,15 @@ def get_queryset(self):

def get_context_data(self, **kwargs):
data = super().get_context_data(**kwargs)
data['categories'] = ResumeCvCategory.objects.all()
data["categories"] = ResumeCvCategory.objects.all()
return data


class ResumeCVCreateView(LoginRequiredMixin, EmployeeRequiredMixin, View):
"""
Create resume/cv
"""

form_class = ResumeCvForm

def post(self, request):
Expand Down Expand Up @@ -65,15 +67,21 @@ def update_builder(request, id):
resume = ResumeCv.objects.get(id=id)
if resume:
data = json.loads(request.body)
resume.content = data.get('gjs-html')
resume.style = data.get('gjs-css')
resume.content = data.get("gjs-html")
resume.style = data.get("gjs-css")
resume.save()
return JsonResponse({
'success': "Updated successfully",
}, safe=True)
return JsonResponse({
'error': "No resume found",
}, safe=True)
return JsonResponse(
{
"success": "Updated successfully",
},
safe=True,
)
return JsonResponse(
{
"error": "No resume found",
},
safe=True,
)


def load_builder(request, id):
Expand All @@ -82,11 +90,17 @@ def load_builder(request, id):
"""
resume = ResumeCv.objects.get(id=id)
if resume:
return JsonResponse({
'gjs-html': resume.content if resume.content else resume.template.content,
'gjs-css': resume.style if resume.style else resume.template.style
}, safe=True)
return JsonResponse(
{
"gjs-html": resume.content if resume.content else resume.template.content,
"gjs-css": resume.style if resume.style else resume.template.style,
},
safe=True,
)
else:
return JsonResponse({
'error': "No template found",
}, safe=True)
return JsonResponse(
{
"error": "No template found",
},
safe=True,
)
2 changes: 1 addition & 1 deletion utils/filename.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@

def generate_file_name(length=30):
letters = string.ascii_letters + string.digits
return ''.join(choice(letters) for _ in range(length))
return "".join(choice(letters) for _ in range(length))

0 comments on commit f6f4998

Please sign in to comment.