diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8e0848b --- /dev/null +++ b/.gitignore @@ -0,0 +1,103 @@ +### OSX ### +.DS_Store +.AppleDouble +.LSOverride + +# Icon must ends with two \r. +Icon + +# Thumbnails +._* + +# Files that might appear on external disk +.Spotlight-V100 +.Trashes + + +### Python ### +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] + +# C extensions +*.so + +# Distribution / packaging +.Python +*.egg-info/ +.installed.cfg +*.egg + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +.tox/ +.coverage +.cache +nosetests.xml +coverage.xml +htmlcov/ + +# Translations +*.mo + +# Mr Developer +.mr.developer.cfg +.project +.pydevproject + +# Rope +.ropeproject + +# Django stuff: +*.log +*.pot +.staticfiles/ +.media/ + +# Sphinx documentation +docs/_build/ + +# npm +node_modules/ + +# Campass +.sass-cache + +# Celery +celerybeat-schedule + +# Vagrant +.vagrant + +# Redis +dump.rdb + +# python-dotenv +.env + +# Others +_docs_html/ +media/ +provisioner/site.retry +*.sqlite3 + +# Virtualenv +venv/ + +### Vim ### +[._]*.s[a-w][a-z] +[._]s[a-w][a-z] +*.un~ +Session.vim +.netrwhist + +# Pycharm +.idea/ + +# Local Files +.static_media/* +.cache/* +../.vscode/ diff --git a/code_share/Procfile b/Procfile similarity index 100% rename from code_share/Procfile rename to Procfile diff --git a/code_share/.gitignore b/code_share/.gitignore deleted file mode 100644 index 1815772..0000000 --- a/code_share/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -app_code_share/migrations/* -venv1/* -*.pyc -db.sqlite3 -debug.log -static_media/* -.cache/* -../.vscode/ diff --git a/code_share/__init__.py b/code_share/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/code_share/api_app/serializers.py b/code_share/api_app/serializers.py index 6b37cb6..e79a688 100644 --- a/code_share/api_app/serializers.py +++ b/code_share/api_app/serializers.py @@ -1,5 +1,5 @@ from rest_framework import serializers -from app_code_share.models import CodeShare +from code_share.app_code_share.models import CodeShare class Codeserializer(serializers.ModelSerializer): diff --git a/code_share/api_app/views.py b/code_share/api_app/views.py index c410b48..20c1bd1 100644 --- a/code_share/api_app/views.py +++ b/code_share/api_app/views.py @@ -1,7 +1,7 @@ from django.shortcuts import get_object_or_404 as goo404, redirect from rest_framework.decorators import api_view from .serializers import Codeserializer -from app_code_share.models import CodeShare +from code_share.app_code_share.models import CodeShare from rest_framework.response import Response import random diff --git a/code_share/app_code_share/migrations/0001_initial.py b/code_share/app_code_share/migrations/0001_initial.py new file mode 100644 index 0000000..d7900df --- /dev/null +++ b/code_share/app_code_share/migrations/0001_initial.py @@ -0,0 +1,29 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.2 on 2017-09-28 09:10 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='CodeShare', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('code', models.TextField(blank=True, max_length=100000, null=True)), + ('hash_value', models.SlugField(blank=True, max_length=100, null=True, unique=True)), + ('file_name', models.CharField(blank=True, max_length=50, null=True)), + ('language', models.CharField(blank=True, default=None, max_length=20, null=True)), + ], + options={ + 'verbose_name': 'CodeShare', + }, + ), + ] diff --git a/code_share/app_code_share/migrations/__init__.py b/code_share/app_code_share/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/code_share/app_code_share/views.py b/code_share/app_code_share/views.py index 8cea51f..bcce35f 100644 --- a/code_share/app_code_share/views.py +++ b/code_share/app_code_share/views.py @@ -26,7 +26,7 @@ def home(request): """ if request.method == 'GET': - return render(request, 'app_code_share/homepage.html', {}) + return render(request, 'homepage.html', {}) if request.method == 'POST': code_share = request.POST.get('code_snippet') @@ -68,7 +68,7 @@ def view_by_hash(request, hash_id): except CodeShare.DoesNotExist: raise Http404("Codeshare does not exist") context = {'code_share': code_share} - return render(request, 'app_code_share/code_view.html', context) + return render(request, 'code_view.html', context) if request.method == 'POST': code_share = request.POST.get('code_snippet') diff --git a/code_share/app_code_share/templates/app_code_share/base.html b/code_share/templates/app_code_share/base.html similarity index 100% rename from code_share/app_code_share/templates/app_code_share/base.html rename to code_share/templates/app_code_share/base.html diff --git a/code_share/app_code_share/templates/app_code_share/code_view.html b/code_share/templates/app_code_share/code_view.html similarity index 100% rename from code_share/app_code_share/templates/app_code_share/code_view.html rename to code_share/templates/app_code_share/code_view.html diff --git a/code_share/app_code_share/templates/app_code_share/fork_github.html b/code_share/templates/app_code_share/fork_github.html similarity index 100% rename from code_share/app_code_share/templates/app_code_share/fork_github.html rename to code_share/templates/app_code_share/fork_github.html diff --git a/code_share/app_code_share/templates/app_code_share/homepage.html b/code_share/templates/app_code_share/homepage.html similarity index 100% rename from code_share/app_code_share/templates/app_code_share/homepage.html rename to code_share/templates/app_code_share/homepage.html diff --git a/code_share/app_code_share/templates/error/HTTP400.html b/code_share/templates/error/HTTP400.html similarity index 100% rename from code_share/app_code_share/templates/error/HTTP400.html rename to code_share/templates/error/HTTP400.html diff --git a/code_share/app_code_share/templates/error/HTTP403.html b/code_share/templates/error/HTTP403.html similarity index 100% rename from code_share/app_code_share/templates/error/HTTP403.html rename to code_share/templates/error/HTTP403.html diff --git a/code_share/app_code_share/templates/error/HTTP404.html b/code_share/templates/error/HTTP404.html similarity index 100% rename from code_share/app_code_share/templates/error/HTTP404.html rename to code_share/templates/error/HTTP404.html diff --git a/code_share/app_code_share/templates/error/HTTP500.html b/code_share/templates/error/HTTP500.html similarity index 100% rename from code_share/app_code_share/templates/error/HTTP500.html rename to code_share/templates/error/HTTP500.html diff --git a/code_share/code_share/urls.py b/code_share/urls.py similarity index 70% rename from code_share/code_share/urls.py rename to code_share/urls.py index 56d1752..4d29841 100644 --- a/code_share/code_share/urls.py +++ b/code_share/urls.py @@ -2,18 +2,16 @@ from django.contrib import admin from django.conf import settings from django.conf.urls.static import static -from .views import ( - page_not_found_view, - my_custom_error_view, - permission_denied_view, - bad_request_view, +from .code_share.views import ( + page_not_found_view, my_custom_error_view, + permission_denied_view, bad_request_view, ) urlpatterns = [ url(r'^admin', admin.site.urls), - url(r'^', include('app_code_share.urls', namespace='code_share')), - url(r'^api/', include('api_app.urls')), + url(r'^', include('code_share.app_code_share.urls', namespace='code_share')), + url(r'^api/', include('code_share.api_app.urls')), ] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) if settings.DEBUG: diff --git a/code_share/manage.py b/manage.py similarity index 90% rename from code_share/manage.py rename to manage.py index e9fc98e..c810539 100644 --- a/code_share/manage.py +++ b/manage.py @@ -3,7 +3,7 @@ import sys if __name__ == "__main__": - os.environ.setdefault("DJANGO_SETTINGS_MODULE", "code_share.settings") + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings.settings") try: from django.core.management import execute_from_command_line except ImportError: diff --git a/code_share/pytest.ini b/pytest.ini similarity index 100% rename from code_share/pytest.ini rename to pytest.ini diff --git a/code_share/requirements.txt b/requirements/requirements.txt similarity index 100% rename from code_share/requirements.txt rename to requirements/requirements.txt diff --git a/code_share/runtime.txt b/runtime.txt similarity index 100% rename from code_share/runtime.txt rename to runtime.txt diff --git a/settings/__init__.py b/settings/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/code_share/code_share/settings.py b/settings/settings.py similarity index 85% rename from code_share/code_share/settings.py rename to settings/settings.py index 7cce392..f54bb9e 100644 --- a/code_share/code_share/settings.py +++ b/settings/settings.py @@ -26,9 +26,9 @@ 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', - 'app_code_share', + 'code_share.app_code_share', 'rest_framework', - 'api_app', + 'code_share.api_app', ] MIDDLEWARE = [ @@ -46,7 +46,7 @@ TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', - 'DIRS': ['app_code_share/templates/app_code_share'], + 'DIRS': ['code_share/templates/app_code_share', 'code_share/templates/error', ], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ @@ -59,7 +59,7 @@ }, ] -WSGI_APPLICATION = 'code_share.wsgi.application' +WSGI_APPLICATION = 'wsgi.application' # Database @@ -129,29 +129,18 @@ # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/1.10/howto/static-files/ -STATIC_ROOT = os.path.join(BASE_DIR, 'static_media') +STATIC_ROOT = os.path.join(BASE_DIR, '.static_media') -STATIC_PATH = os.path.join(BASE_DIR, 'static') +STATIC_PATH = os.path.join(BASE_DIR, 'code_share/static') STATICFILES_DIRS = ( STATIC_PATH, ) STATIC_URL = '/static/' -''' -Settings for running on heroku - -''' -# DATABASES['default'] = dj_database_url.config() -# print (DATABASES['default']) - -# SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https') - -# ALLOWED_HOSTS = ['*'] - -# DEBUG = True - -# try: -# from .local_settings import * -# except ImportError: -# pass +# List of finder classes that know how to find static files in +# various locations. +STATICFILES_FINDERS = ( + 'django.contrib.staticfiles.finders.FileSystemFinder', + 'django.contrib.staticfiles.finders.AppDirectoriesFinder', +) diff --git a/code_share/setup.cfg b/setup.cfg similarity index 100% rename from code_share/setup.cfg rename to setup.cfg diff --git a/code_share/app_code_share/tests/test_models.py b/tests/test_models.py similarity index 100% rename from code_share/app_code_share/tests/test_models.py rename to tests/test_models.py diff --git a/code_share/app_code_share/tests/test_urls.py b/tests/test_urls.py similarity index 100% rename from code_share/app_code_share/tests/test_urls.py rename to tests/test_urls.py diff --git a/code_share/app_code_share/tests/test_views.py b/tests/test_views.py similarity index 100% rename from code_share/app_code_share/tests/test_views.py rename to tests/test_views.py diff --git a/code_share/uwsgi.ini b/uwsgi.ini similarity index 79% rename from code_share/uwsgi.ini rename to uwsgi.ini index 8550b11..6ebc552 100644 --- a/code_share/uwsgi.ini +++ b/uwsgi.ini @@ -1,6 +1,6 @@ [uwsgi] chdir=/home/sourabh/projects/CodeShare/code_share -module=code_share.wsgi:application +module=wsgi:application master=True pidfile=/tmp/code_share-master.pid vacuum=True diff --git a/code_share/code_share/wsgi.py b/wsgi.py similarity index 85% rename from code_share/code_share/wsgi.py rename to wsgi.py index c445c96..31e1703 100644 --- a/code_share/code_share/wsgi.py +++ b/wsgi.py @@ -13,7 +13,7 @@ from whitenoise.django import DjangoWhiteNoise -os.environ.setdefault("DJANGO_SETTINGS_MODULE", "code_share.settings") +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings.settings") application = get_wsgi_application()