Skip to content

Commit

Permalink
Merge pull request #12 from Alschn/feature/prepare-backend-for-deploy
Browse files Browse the repository at this point in the history
Prepare backend for initial deployment
  • Loading branch information
Alschn committed Dec 15, 2023
2 parents eac16b4 + e71dd0f commit af2e1ca
Show file tree
Hide file tree
Showing 27 changed files with 814 additions and 665 deletions.
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,14 @@ pipenv install
Create `.env` file in `backend` directory and set following variables in plain text

```shell script
CLIENT_ID='id from spotify dashboard'
CLIENT_SECRET='secret from spotify dashboard'
REDIRECT_URI='redirect uri set in spotify dashboard (port 8000)'
REDIRECT_URI_DEV='other direct uri for development (port 3000)'
SECRET_KEY=your_secret_key
DEBUG=True
USE_LOCAL_SQLITE_DB=True
CORS_ALLOW_ALL_ORIGINS=True

SPOTIFY_CLIENT_ID='id from spotify dashboard'
SPOTIFY_CLIENT_SECRET='secret from spotify dashboard'
SPOTIFY_REDIRECT_URI='redirect uri set in spotify dashboard (port 3000)'
```

Run migrations and create superuser:
Expand Down
6 changes: 4 additions & 2 deletions backend/Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,17 @@ django-cors-headers = "*"
django-allauth = "*"
dj-rest-auth = "*"
django-filter = "*"
python-dotenv = "*"
django-environ = "*"
psycopg = {extras = ["binary"], version = "*"}
requests = "*"
psycopg2 = "*"
gunicorn = "*"
whitenoise = "*"
spotipy = "*"
drf-spectacular = "*"
dj-database-url = "*"

[dev-packages]
factory-boy = "*"
coverage = "*"
mypy = "*"
django-stubs = {extras = ["compatible-mypy"], version = "*"}
Expand Down
1,161 changes: 586 additions & 575 deletions backend/Pipfile.lock

Large diffs are not rendered by default.

File renamed without changes.
10 changes: 10 additions & 0 deletions backend/accounts/adapters.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from allauth.account.adapter import DefaultAccountAdapter
from allauth.socialaccount.adapter import DefaultSocialAccountAdapter


class AccountAdapter(DefaultAccountAdapter):
pass


class SocialAccountAdapter(DefaultSocialAccountAdapter):
pass
9 changes: 9 additions & 0 deletions backend/accounts/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from django.contrib import admin
from django.contrib.auth.admin import UserAdmin as BaseUserAdmin

from accounts.models import User


@admin.register(User)
class UserAdmin(BaseUserAdmin):
pass
6 changes: 6 additions & 0 deletions backend/accounts/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.apps import AppConfig


class AccountsConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'accounts'
44 changes: 44 additions & 0 deletions backend/accounts/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Generated by Django 4.2.7 on 2023-12-13 14:03

import django.contrib.auth.models
import django.contrib.auth.validators
from django.db import migrations, models
import django.utils.timezone


class Migration(migrations.Migration):

initial = True

dependencies = [
('auth', '0012_alter_user_first_name_max_length'),
]

operations = [
migrations.CreateModel(
name='User',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('password', models.CharField(max_length=128, verbose_name='password')),
('last_login', models.DateTimeField(blank=True, null=True, verbose_name='last login')),
('is_superuser', models.BooleanField(default=False, help_text='Designates that this user has all permissions without explicitly assigning them.', verbose_name='superuser status')),
('username', models.CharField(error_messages={'unique': 'A user with that username already exists.'}, help_text='Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.', max_length=150, unique=True, validators=[django.contrib.auth.validators.UnicodeUsernameValidator()], verbose_name='username')),
('first_name', models.CharField(blank=True, max_length=150, verbose_name='first name')),
('last_name', models.CharField(blank=True, max_length=150, verbose_name='last name')),
('email', models.EmailField(blank=True, max_length=254, verbose_name='email address')),
('is_staff', models.BooleanField(default=False, help_text='Designates whether the user can log into this admin site.', verbose_name='staff status')),
('is_active', models.BooleanField(default=True, help_text='Designates whether this user should be treated as active. Unselect this instead of deleting accounts.', verbose_name='active')),
('date_joined', models.DateTimeField(default=django.utils.timezone.now, verbose_name='date joined')),
('groups', models.ManyToManyField(blank=True, help_text='The groups this user belongs to. A user will get all permissions granted to each of their groups.', related_name='user_set', related_query_name='user', to='auth.group', verbose_name='groups')),
('user_permissions', models.ManyToManyField(blank=True, help_text='Specific permissions for this user.', related_name='user_set', related_query_name='user', to='auth.permission', verbose_name='user permissions')),
],
options={
'verbose_name': 'user',
'verbose_name_plural': 'users',
'abstract': False,
},
managers=[
('objects', django.contrib.auth.models.UserManager()),
],
),
]
Empty file.
1 change: 1 addition & 0 deletions backend/accounts/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .user import User
5 changes: 5 additions & 0 deletions backend/accounts/models/user.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from django.contrib.auth.models import AbstractUser


class User(AbstractUser):
pass
Empty file.
Empty file.
7 changes: 7 additions & 0 deletions backend/accounts/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from django.urls import path

from accounts.views import LogoutAPIView

urlpatterns = [
path('auth/logout/', LogoutAPIView.as_view(), name='logout'),
]
1 change: 1 addition & 0 deletions backend/accounts/views/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .logout import LogoutAPIView
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
from rest_framework.permissions import IsAuthenticated


class LogoutView(BaseLogoutView):
class LogoutAPIView(BaseLogoutView):
"""
POST /api/auth/logout/ - Logs out current user
"""
permission_classes = [IsAuthenticated]
http_method_names = ('post',)
2 changes: 1 addition & 1 deletion backend/core/asgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@

from django.core.asgi import get_asgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'core.settings.dev')
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'core.settings.base')

application = get_asgi_application()
Loading

0 comments on commit af2e1ca

Please sign in to comment.