Blank slate #10

This commit is contained in:
amazing-username
2019-03-11 22:31:09 -04:00
parent d2bb9b17af
commit 0b6d5b05f8
16 changed files with 0 additions and 252 deletions
View File
-3
View File
@@ -1,3 +0,0 @@
from django.contrib import admin
# Register your models here.
-5
View File
@@ -1,5 +0,0 @@
from django.apps import AppConfig
class ApiConfig(AppConfig):
name = 'api'
View File
-12
View File
@@ -1,12 +0,0 @@
from django.db import models
class Song(models.Model):
title = models.CharField(max_length=70)
album = models.CharField(max_length=170)
artist = models.CharField(max_length=100)
year = models.IntegerField()
genre = models.CharField(max_length=70)
duration = models.IntegerField()
track_number = models.IntegerField()
cover = models.BinaryField(editable=True)
file = models.BinaryField(editable=True)
-7
View File
@@ -1,7 +0,0 @@
from rest_framework import serializers
from .models import Song
class SongSerialzer(serializers.ModelSerializer):
class Meta:
model = Song
fields = ('id', 'title', 'albumn', 'year', 'genre', 'track_number', 'file')
-3
View File
@@ -1,3 +0,0 @@
from django.test import TestCase
# Create your tests here.
-10
View File
@@ -1,10 +0,0 @@
from django.urls import path
from rest_framework.urlpatterns import format_suffix_patterns
from api import views
urlpatterns = [
path('song/', views.UploadList().as_view()),
path('song/upload/', views.UploadList().as_view())
]
urlpatterns = format_suffix_patterns(urlpatterns)
-39
View File
@@ -1,39 +0,0 @@
from django.shortcuts import render
from rest_framework import status
from rest_framework.response import Response
from rest_framework.views import APIView
from .models import Song
from .serializers import SongSerialzer
class UploadList(APIView):
def post(self, request, format=None):
serializer = SongSerialzer(data=request.data)
if serializer.is_valid():
serializer.save()
return Response({
'demo':'success'
})
return Response({
'demo': 'failure'
}, status=status.HTTP_400_BAD_REQUEST)
def get(self, request, format=None):
songs = Song.objects.all()
serializer = SongSerialzer(songs, many=True)
return Response(serializer.data)
class UploadDetail(APIView):
def get_object(self, pk):
try:
return Song.objects.get(pk=pk)
except Song.DoesNotExist:
raise Http404
def get(self, request, pk, format=NONE):
song = self.get_object(pk)
serializer = SongSerializer(song)
return Response(serializer.data)
-7
View File
@@ -1,7 +0,0 @@
[client]
database =
host =
user =
password =
port =
default-character-set = utf8
View File
-124
View File
@@ -1,124 +0,0 @@
"""
Django settings for icarus project.
Generated by 'django-admin startproject' using Django 2.1.5.
For more information on this file, see
https://docs.djangoproject.com/en/2.1/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/2.1/ref/settings/
"""
import os
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 's$=99g-0dsyd5ijtglgbna@ma3zt_u%6-_30g7@97i@g_+$+&d'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'api',
'rest_framework'
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'icarus.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'icarus.wsgi.application'
# Database
# https://docs.djangoproject.com/en/2.1/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'OPTIONS': {
'read_default_file': os.path.join(BASE_DIR, 'database.cnf'),
}
}
}
# Password validation
# https://docs.djangoproject.com/en/2.1/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
# Internationalization
# https://docs.djangoproject.com/en/2.1/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/2.1/howto/static-files/
STATIC_URL = '/static/'
-7
View File
@@ -1,7 +0,0 @@
from django.contrib import admin
from django.urls import include, path
urlpatterns = [
path('admin/', admin.site.urls),
path('api/', include('api.urls'))
]
-16
View File
@@ -1,16 +0,0 @@
"""
WSGI config for icarus project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/2.1/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'icarus.settings')
application = get_wsgi_application()
-15
View File
@@ -1,15 +0,0 @@
#!/usr/bin/env python
import os
import sys
if __name__ == '__main__':
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'icarus.settings')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
execute_from_command_line(sys.argv)
-4
View File
@@ -1,4 +0,0 @@
icarus
django>=2.1
djangorestframework>=3.9.1
mysqlclient>=1.4.1