Skip to content

Commit

Permalink
add github workflows and refactoring code
Browse files Browse the repository at this point in the history
  • Loading branch information
RustamovAkrom committed Oct 21, 2024
1 parent 4131575 commit 0b3ce10
Show file tree
Hide file tree
Showing 78 changed files with 190 additions and 171 deletions.
14 changes: 14 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[flake8]
exclude =
migrations,
venv,
env,
__pycache__,
.git,
.github,
appender.py,
work.py,
faker_data.py,
max-line-length = 88
ignore = E203, E266, E501, W503
select = B,C,E,F,W
43 changes: 43 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: CI/CD Pipeline

on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.10'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Set up enviroment varibles
run: |
echo "SECRET_KEY"=${{ secrets.DJANGO_SECRET_KEY }} >> $GITHUB_ENV
- name: Run linters
run: |
flake8
- name: Run tests
run: |
python manage.py test
- name: Deploy
run: |
echo "Deploying application..."
3 changes: 0 additions & 3 deletions apps/shared/admin.py

This file was deleted.

6 changes: 2 additions & 4 deletions apps/shared/management/commands/createadmin.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def handle(self, *args, **options):
User = get_user_model()
options.setdefault("is_active", True)
self.create_superuser(User, "Akromjon9", "[email protected]", "2007")

def create_superuser(self, User, username, email, password):
if not User.objects.filter(username=username).exists():
user = User.objects.create_superuser(username, email, password)
Expand All @@ -17,6 +17,4 @@ def create_superuser(self, User, username, email, password):
self.style.SUCCESS(f"Superuser {username} created successfully.")
)
else:
self.stdout.write(
self.style.ERROR(f"Superuser {username} already exists.")
)
self.stdout.write(self.style.ERROR(f"Superuser {username} already exists."))
3 changes: 0 additions & 3 deletions apps/shared/tests.py

This file was deleted.

3 changes: 0 additions & 3 deletions apps/shared/views.py

This file was deleted.

2 changes: 1 addition & 1 deletion apps/spotify/api_endpoints/Album/AlbumCreate/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from .views import *
from .views import * # noqa
2 changes: 1 addition & 1 deletion apps/spotify/api_endpoints/Album/AlbumCreate/test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from django.test import TestCase
from django.urls import reverse
from apps.spotify.models import Album, Artist
from apps.spotify.models import Artist


class AlbumCreateTest(TestCase):
Expand Down
2 changes: 1 addition & 1 deletion apps/spotify/api_endpoints/Album/AlbumDestroy/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from .views import *
from .views import * # noqa
2 changes: 1 addition & 1 deletion apps/spotify/api_endpoints/Album/AlbumList/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from .views import *
from .views import * # noqa
2 changes: 1 addition & 1 deletion apps/spotify/api_endpoints/Album/AlbumRetrive/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from .views import *
from .views import * # noqa
2 changes: 1 addition & 1 deletion apps/spotify/api_endpoints/Album/AlbumUpdate/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from .views import *
from .views import * # noqa
10 changes: 5 additions & 5 deletions apps/spotify/api_endpoints/Album/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from .AlbumCreate import *
from .AlbumDestroy import *
from .AlbumList import *
from .AlbumRetrive import *
from .AlbumUpdate import *
from .AlbumCreate import * # noqa
from .AlbumDestroy import * # noqa
from .AlbumList import * # noqa
from .AlbumRetrive import * # noqa
from .AlbumUpdate import * # noqa
2 changes: 1 addition & 1 deletion apps/spotify/api_endpoints/Artist/ArtistCreate/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from .views import *
from .views import * # noqa
1 change: 0 additions & 1 deletion apps/spotify/api_endpoints/Artist/ArtistCreate/test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from django.test import TestCase
from apps.spotify.models import Artist
from django.urls import reverse
from faker import Faker

Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from .views import *
from .views import * # noqa
2 changes: 1 addition & 1 deletion apps/spotify/api_endpoints/Artist/ArtistList/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from .views import *
from .views import * # noqa
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from .views import *
from .views import * # noqa
2 changes: 1 addition & 1 deletion apps/spotify/api_endpoints/Artist/ArtistUpdate/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from .views import *
from .views import * # noqa
10 changes: 5 additions & 5 deletions apps/spotify/api_endpoints/Artist/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from .ArtistCreate import *
from .ArtistDestroy import *
from .ArtistList import *
from .ArtistRetrive import *
from .ArtistUpdate import *
from .ArtistCreate import * # noqa
from .ArtistDestroy import * # noqa
from .ArtistList import * # noqa
from .ArtistRetrive import * # noqa
from .ArtistUpdate import * # noqa
2 changes: 1 addition & 1 deletion apps/spotify/api_endpoints/Song/SongCreate/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from .views import *
from .views import * # noqa
4 changes: 1 addition & 3 deletions apps/spotify/api_endpoints/Song/SongCreate/test.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
from django.test import TestCase
from apps.spotify.models import Genre, Album, Artist, Song
import json
from django.core.files import File
from apps.spotify.models import Genre, Album, Artist
from django.urls import reverse


Expand Down
2 changes: 1 addition & 1 deletion apps/spotify/api_endpoints/Song/SongDestroy/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from .views import *
from .views import * # noqa
1 change: 0 additions & 1 deletion apps/spotify/api_endpoints/Song/SongDestroy/test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from django.test import TestCase
from apps.spotify.models import Album, Genre, Artist, Song
from rest_framework.test import APITestCase
from django.urls import reverse


Expand Down
2 changes: 1 addition & 1 deletion apps/spotify/api_endpoints/Song/SongList/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from .views import *
from .views import * # noqa
2 changes: 1 addition & 1 deletion apps/spotify/api_endpoints/Song/SongList/test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from django.test import TestCase
from django.urls import reverse
from apps.spotify.models import Song, Genre, Artist, Album
from apps.spotify.models import Genre, Artist, Album
from faker import Faker
import random

Expand Down
2 changes: 1 addition & 1 deletion apps/spotify/api_endpoints/Song/SongRetrive/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from .views import *
from .views import * # noqa
13 changes: 0 additions & 13 deletions apps/spotify/api_endpoints/Song/SongRetrive/test.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,3 @@
<<<<<<< HEAD
from django.test import TestCase

# url = "http://127.0.0.1:8000/api/v1/spotify/song-retrive/2"


# class TestSongRetrive(TestCase):

# def test_list(self):
# response = self.client.get(url)
# print(response.status_code)
=======
# from django.test import TestCase
# from django.urls import reverse

Expand All @@ -18,4 +6,3 @@
# def setUp(self):

# self.url = reverse("spotify:song-retrive", kwargs={'pk':1})
>>>>>>> 8ba28da (update dir in push)
1 change: 0 additions & 1 deletion apps/spotify/api_endpoints/Song/SongRetrive/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from apps.spotify.models import Song
from .serializers import SongRetriveSerializer
from django.db import transaction
from rest_framework.response import Response


class SongRetriveAPIView(RetrieveAPIView):
Expand Down
2 changes: 1 addition & 1 deletion apps/spotify/api_endpoints/Song/SongUpdate/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from .views import *
from .views import * # noqa
4 changes: 2 additions & 2 deletions apps/spotify/api_endpoints/Song/SongUpdate/test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from django.test import TestCase
from django.urls import reverse
# from django.test import TestCase
# from django.urls import reverse


# class TestSongUpdate(TestCase):
Expand Down
10 changes: 5 additions & 5 deletions apps/spotify/api_endpoints/Song/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from .SongCreate import *
from .SongDestroy import *
from .SongList import *
from .SongRetrive import *
from .SongUpdate import *
from .SongCreate import * # noqa
from .SongDestroy import * # noqa
from .SongList import * # noqa
from .SongRetrive import * # noqa
from .SongUpdate import * # noqa
3 changes: 0 additions & 3 deletions apps/spotify/tests.py

This file was deleted.

3 changes: 0 additions & 3 deletions apps/spotify/views.py

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1 +1 @@
from .views import *
from .views import * # noqa
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from rest_framework import serializers
from apps.spotify.models import Artist


class UserArtisFollowSerializer(serializers.Serializer):
Expand Down
2 changes: 0 additions & 2 deletions apps/users/api_endpoints/Follow/UserArtistFollow/test.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
from django.test import TestCase
from apps.users.models import User
from apps.spotify.models import Artist
from django.urls import reverse
from faker import Faker
from rest_framework.authtoken.models import Token
from apps.users.tests import AuthenticationTest

fake = Faker()
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from .views import *
from .views import * # noqa
1 change: 0 additions & 1 deletion apps/users/api_endpoints/Follow/UserArtistUnfollow/test.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from django.test import TestCase
from django.urls import reverse
from apps.users.models import User
from apps.spotify.models import Artist
import faker
from apps.users.tests import AuthenticationTest

Expand Down
2 changes: 1 addition & 1 deletion apps/users/api_endpoints/Follow/UserFollow/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from .views import *
from .views import * # noqa
3 changes: 2 additions & 1 deletion apps/users/api_endpoints/Follow/UserFollow/views.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from rest_framework import status
from rest_framework.authentication import TokenAuthentication

# from rest_framework.authentication import TokenAuthentication
from rest_framework.exceptions import APIException
from rest_framework.permissions import IsAuthenticated
from rest_framework.response import Response
Expand Down
2 changes: 1 addition & 1 deletion apps/users/api_endpoints/Follow/UserFollowers/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from .views import *
from .views import * # noqa
7 changes: 3 additions & 4 deletions apps/users/api_endpoints/Follow/UserFollowers/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@

class UserUnfollowTest(AuthenticationTest, TestCase):


def test_follow_user(self):

for _ in range(5):
self.users = User.objects.create(username = fake.user_name())
self.user = User.objects.create(username = "Ahmadjon")
self.users = User.objects.create(username=fake.user_name())
self.user = User.objects.create(username="Ahmadjon")
self.user.profiles.follow(User.objects.last())
url = reverse("users:followers-user", kwargs={"pk":self.user.id})
url = reverse("users:followers-user", kwargs={"pk": self.user.id})
response = self.client.get(url, data={"userid": 1}, headers=self.headers)
self.assertEqual(response.status_code, 200)
2 changes: 1 addition & 1 deletion apps/users/api_endpoints/Follow/UserFollowing/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from .views import *
from .views import * # noqa
2 changes: 1 addition & 1 deletion apps/users/api_endpoints/Follow/UserUnfollow/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from .views import *
from .views import * # noqa
3 changes: 1 addition & 2 deletions apps/users/api_endpoints/Follow/UserUnfollow/views.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from rest_framework import status
from rest_framework.authentication import TokenAuthentication
# from rest_framework.authentication import TokenAuthentication
from rest_framework.exceptions import APIException
from rest_framework.generics import get_object_or_404
from rest_framework.permissions import IsAuthenticated
Expand Down
12 changes: 6 additions & 6 deletions apps/users/api_endpoints/Follow/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from .UserFollow import *
from .UserUnfollow import *
from .UserFollowers import *
from .UserFollowing import *
from .UserArtistFollow import *
from .UserArtistUnfollow import *
from .UserFollow import * # noqa
from .UserUnfollow import * # noqa
from .UserFollowers import * # noqa
from .UserFollowing import * # noqa
from .UserArtistFollow import * # noqa
from .UserArtistUnfollow import * # noqa
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from .views import *
from .views import * # noqa
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from django.test import TestCase
from apps.users.models import UserProfile, User
from apps.users.models import User
from django.urls import reverse


Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from .views import *
from .views import * # noqa
4 changes: 2 additions & 2 deletions apps/users/api_endpoints/UserProfile/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
from .UserProfileDestroy import *
from .UserProfileUpdate import *
from .UserProfileDestroy import * # noqa
from .UserProfileUpdate import * # noqa
2 changes: 1 addition & 1 deletion apps/users/api_endpoints/Users/ForgotPassword/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from .views import *
from .views import * # noqa
18 changes: 8 additions & 10 deletions apps/users/api_endpoints/Users/ForgotPassword/views.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
import os

from django.views.decorators.cache import cache_page
from django.utils.decorators import method_decorator
from django.core.mail import send_mail

from rest_framework.views import APIView
from apps.users.models import User
from rest_framework.response import Response
from rest_framework.generics import get_object_or_404

from apps.users.models import User

from dotenv import load_dotenv

load_dotenv()
import os

from django.core.mail import send_mail
from apps.users.utils import generate_token

from apps.users.models import User
from celery import shared_task
from django.views.decorators.cache import cache_page
from django.utils.decorators import method_decorator


class ForgotPasswordAPIView(APIView):
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from .views import *
from .views import * # noqa
Loading

0 comments on commit 0b3ce10

Please sign in to comment.