Skip to content

Commit

Permalink
Merge pull request #23 from OusmaneKK/22-ops-make-docker-compose
Browse files Browse the repository at this point in the history
feat: adding docker compose and dockerfile
  • Loading branch information
OusmaneKK authored Aug 29, 2023
2 parents 442a149 + 96ef50c commit f922950
Show file tree
Hide file tree
Showing 774 changed files with 269,878 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.env
36 changes: 36 additions & 0 deletions backend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Django project directories
__pycache__/
*.py[cod]

# Virtual environment directories
venv/
env/
*.env

# Development database
db.sqlite3

# Logs
*.log

# Generated media and static files
media/
staticfiles/

# IDE specific files
.vscode/
*.idea/

# Compiled Python files
*.pyc

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# Local development settings
*.local_settings.py

# Compiled translation files
locale/
17 changes: 17 additions & 0 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Utilisez une image Python
FROM python:3.8

# Créez un répertoire de travail
WORKDIR /app

# Copiez le fichier requirements.txt dans l'image
COPY requirements.txt /app/

# Installez les dépendances
RUN pip install -r requirements.txt

# Copiez votre application dans l'image
COPY . /app/

# Commande par défaut à exécuter lorsque le conteneur démarre
CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"]
1 change: 1 addition & 0 deletions backend/backend/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'main'
]

MIDDLEWARE = [
Expand Down
4 changes: 4 additions & 0 deletions backend/backend/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@
"""
from django.contrib import admin
from django.urls import path
from main import views

urlpatterns = [
path('admin/', admin.site.urls),
path('register/', views.register_view, name='register'),
path('login/', views.login_view, name='login'),
path('logout/', views.logout_view, name='logout'),
]
Empty file added backend/main/__init__.py
Empty file.
3 changes: 3 additions & 0 deletions backend/main/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.contrib import admin

# Register your models here.
6 changes: 6 additions & 0 deletions backend/main/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.apps import AppConfig


class MainConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'main'
26 changes: 26 additions & 0 deletions backend/main/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Generated by Django 4.2.3 on 2023-08-28 14:39

from django.db import migrations, models


class Migration(migrations.Migration):

initial = True

dependencies = [
]

operations = [
migrations.CreateModel(
name='Music',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('title', models.CharField(max_length=100)),
('description', models.TextField()),
('is_liked', models.BooleanField(default=False)),
('like_count', models.PositiveIntegerField(default=0)),
('image', models.ImageField(upload_to='music_images/')),
('audio_file', models.FileField(upload_to='music_audio/')),
],
),
]
Empty file.
13 changes: 13 additions & 0 deletions backend/main/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from django.db import models

# Create your models here.
class Music(models.Model):
title = models.CharField(max_length=100)
description = models.TextField()
is_liked = models.BooleanField(default=False)
like_count = models.PositiveIntegerField(default=0)
image = models.ImageField(upload_to='music_images/')
audio_file = models.FileField(upload_to='music_audio/')

def __str__(self):
return self.title
3 changes: 3 additions & 0 deletions backend/main/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.test import TestCase

# Create your tests here.
30 changes: 30 additions & 0 deletions backend/main/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from django.shortcuts import render, redirect
from django.contrib.auth import authenticate, login, logout
from django.http import JsonResponse

# Create your views here.

def register_view(request):
if request.method == 'POST':
return redirect('login')
return render(request, 'registration/register.html')

def login_view(request):
if request.method =='POST':
username = request.POST['username']
password = request.POST['password']
user = authenticate(request, username=username, password=password)
if user is not None:
login(request, user)
return redirect('home')
else:
pass
return render(request, 'registration/login.html')

def logout_view(request):
logout(request)
return redirect('login')

def check_authentication(request):
is_logged = request.user.is_authenticated
return JsonResponse({'isLogged': is_logged})
Loading

0 comments on commit f922950

Please sign in to comment.