-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update .pre-commit-config.yaml file. Add github action CI.
- Loading branch information
1 parent
7559de4
commit 3e16723
Showing
21 changed files
with
250 additions
and
137 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
--- | ||
name: Tests CI | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
tests: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
max-parallel: 4 | ||
matrix: | ||
python-version: [3.12.x] | ||
|
||
services: | ||
postgres: | ||
image: postgres:14-alpine | ||
env: | ||
POSTGRES_PASSWORD: postgres | ||
ports: | ||
- 5432:5432 | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip -r requirements/test.txt | ||
- name: Set up databases | ||
run: | | ||
PGPASSWORD="postgres" createuser -U postgres -d django_template --superuser -h localhost | ||
PGPASSWORD="postgres" createdb -U postgres -O django_template django_template -h localhost | ||
- name: Load fixture | ||
run: | | ||
python manage.py loaddata authentication/fixtures/customer.json --app authentication.customer | ||
- name: Check linter | ||
run: | | ||
flake8 . | ||
- name: Format code | ||
run: | | ||
black . | ||
isort . | ||
- name: Run unit test and report coverage | ||
run: | | ||
coverage run --source='.' manage.py test | ||
coverage report |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,13 @@ | ||
repos: | ||
- repo: https://github.com/psf/black | ||
rev: 22.12.0 | ||
rev: "23.11.0" | ||
hooks: | ||
- id: black | ||
- id: black | ||
- repo: https://github.com/pycqa/isort | ||
rev: "5.12.0" | ||
hooks: | ||
- id: isort | ||
- repo: https://github.com/pycqa/flake8 | ||
rev: "6.1.0" | ||
hooks: | ||
- id: flake8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,15 @@ | ||
from django.contrib import admin | ||
|
||
|
||
class CustomerAdmin(admin.ModelAdmin): | ||
list_display = ('id', 'bio', 'birth_date', 'address', ) | ||
search_fields = ('id', 'address', ) | ||
list_filter = ('birth_date', ) | ||
list_display = ( | ||
"id", | ||
"bio", | ||
"birth_date", | ||
"address", | ||
) | ||
search_fields = ( | ||
"id", | ||
"address", | ||
) | ||
list_filter = ("birth_date",) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,4 @@ | |
|
||
|
||
class AuthConfig(AppConfig): | ||
name = 'authentication' | ||
name = "authentication" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,26 @@ | ||
from rest_framework import serializers | ||
from django.contrib.auth.models import User | ||
from rest_framework.validators import UniqueValidator | ||
from django.contrib.auth.password_validation import validate_password | ||
from rest_framework import serializers | ||
from rest_framework.validators import UniqueValidator | ||
|
||
|
||
class RegisterSerializer(serializers.ModelSerializer): | ||
email = serializers.EmailField( | ||
required=True, | ||
validators=[UniqueValidator(queryset=User.objects.all())] | ||
required=True, validators=[UniqueValidator(queryset=User.objects.all())] | ||
) | ||
|
||
password = serializers.CharField(write_only=True, required=True, validators=[validate_password]) | ||
password = serializers.CharField( | ||
write_only=True, required=True, validators=[validate_password] | ||
) | ||
|
||
class Meta: | ||
model = User | ||
fields = ('username', 'password', 'email', 'first_name', 'last_name') | ||
fields = ("username", "password", "email", "first_name", "last_name") | ||
|
||
def create(self, validated_data): | ||
user = User.objects.create(**validated_data) | ||
|
||
user.set_password(validated_data['password']) | ||
user.set_password(validated_data["password"]) | ||
user.save() | ||
|
||
return user |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,10 @@ | ||
from django_template.celery import Celery | ||
|
||
app = Celery('tasks',) | ||
app = Celery( | ||
"tasks", | ||
) | ||
|
||
@app.task(name='run_every_monday_morning') | ||
|
||
@app.task(name="run_every_monday_morning") | ||
def add(x, y): | ||
return x + y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
from django.urls import path | ||
from authentication.views import RegisterView | ||
from rest_framework_simplejwt.views import TokenObtainPairView, TokenRefreshView | ||
|
||
from authentication.views import RegisterView | ||
|
||
urlpatterns = [ | ||
path('login/', TokenObtainPairView.as_view(), name='token_obtain_pair'), | ||
path('token/refresh/', TokenRefreshView.as_view(), name='token_refresh'), | ||
path('register/', RegisterView.as_view(), name='auth_register'), | ||
path("login/", TokenObtainPairView.as_view(), name="token_obtain_pair"), | ||
path("token/refresh/", TokenRefreshView.as_view(), name="token_refresh"), | ||
path("register/", RegisterView.as_view(), name="auth_register"), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.