Skip to content

Commit 10f1847

Browse files
committed
Initial Commit
0 parents  commit 10f1847

10 files changed

Lines changed: 379 additions & 0 deletions

File tree

‎.gitignore‎

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
.DS_Store
2+
node_modules/
3+
4+
!frontend/
5+
frontend/*
6+
!frontend/dist/
7+
8+
npm-debug.log*
9+
yarn-debug.log*
10+
yarn-error.log*
11+
12+
# Editor directories and files
13+
.idea
14+
.vscode
15+
*.suo
16+
*.ntvs*
17+
*.njsproj
18+
*.sln
19+
20+
# Distribution / packaging
21+
.Python
22+
env/
23+
develop-eggs/
24+
#dist/
25+
downloads/
26+
eggs/
27+
lib/
28+
lib64/
29+
parts/
30+
sdist/
31+
var/
32+
*.egg-info/
33+
.installed.cfg
34+
*.egg
35+
36+
# PyInstaller
37+
# Usually these files are written by a python script from a template
38+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
39+
*.manifest
40+
*.spec
41+
42+
# Installer logs
43+
pip-log.txt
44+
pip-delete-this-directory.txt
45+
46+
# Unit test / coverage reports
47+
htmlcov/
48+
.tox/
49+
.coverage
50+
.cache
51+
nosetests.xml
52+
coverage.xml
53+
54+
# Translations
55+
*.mo
56+
*.pot
57+
58+
# Sphinx documentation
59+
docs/_build/
60+
61+
# PyBuilder
62+
target/
63+
64+
65+
### Django ###
66+
*.log
67+
*.pot
68+
*.pyc
69+
__pycache__/
70+
local_settings.py
71+
staticfiles
72+
.env
73+
db.sqlite3

‎Procfile‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
web: gunicorn QuestionTime.wsgi --log-file -

‎QuestionTime/__init__.py‎

Whitespace-only changes.

‎QuestionTime/asgi.py‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""
2+
ASGI config for QuestionTime project.
3+
4+
It exposes the ASGI callable as a module-level variable named ``application``.
5+
6+
For more information on this file, see
7+
https://docs.djangoproject.com/en/3.0/howto/deployment/asgi/
8+
"""
9+
10+
import os
11+
12+
from django.core.asgi import get_asgi_application
13+
14+
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'QuestionTime.settings')
15+
16+
application = get_asgi_application()

‎QuestionTime/settings.py‎

Lines changed: 198 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,198 @@
1+
"""
2+
Django settings for QuestionTime project.
3+
4+
Generated by 'django-admin startproject' using Django 3.0.1.
5+
6+
For more information on this file, see
7+
https://docs.djangoproject.com/en/3.0/topics/settings/
8+
9+
For the full list of settings and their values, see
10+
https://docs.djangoproject.com/en/3.0/ref/settings/
11+
"""
12+
13+
import os
14+
import dj_database_url
15+
16+
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
17+
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
18+
19+
# Quick-start development settings - unsuitable for production
20+
# See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/
21+
22+
23+
# SECURITY WARNING: keep the secret key used in production secret!
24+
SECRET_KEY = os.environ.get('SECRET_KEY', '')
25+
26+
# SECURITY WARNING: don't run with debug turned on in production!
27+
DEBUG = os.environ.get('DEBUG', '')
28+
29+
if not DEBUG:
30+
try:
31+
import local_settings as ls
32+
33+
SECRET_KEY = ls.SECRET_KEY
34+
DEBUG = ls.DEBUG
35+
except ImportError:
36+
pass
37+
38+
ALLOWED_HOSTS = ['questiontimey.herokuapp.com', 'localhost', '*']
39+
40+
# Custom User Model
41+
AUTH_USER_MODEL = 'users.CustomUser'
42+
43+
# Application definition
44+
45+
INSTALLED_APPS = [
46+
'django.contrib.admin',
47+
'django.contrib.auth',
48+
'django.contrib.contenttypes',
49+
'django.contrib.sessions',
50+
'django.contrib.messages',
51+
'django.contrib.staticfiles',
52+
'django.contrib.sites',
53+
54+
'rest_framework',
55+
'rest_framework.authtoken',
56+
57+
'allauth',
58+
'allauth.account',
59+
'allauth.socialaccount',
60+
61+
'rest_auth',
62+
'rest_auth.registration',
63+
64+
'django_registration',
65+
66+
'crispy_forms',
67+
'webpack_loader',
68+
69+
'users',
70+
'questions',
71+
]
72+
73+
MIDDLEWARE = [
74+
'django.middleware.security.SecurityMiddleware',
75+
'whitenoise.middleware.WhiteNoiseMiddleware',
76+
'django.contrib.sessions.middleware.SessionMiddleware',
77+
'django.middleware.common.CommonMiddleware',
78+
'django.middleware.csrf.CsrfViewMiddleware',
79+
'django.contrib.auth.middleware.AuthenticationMiddleware',
80+
'django.contrib.messages.middleware.MessageMiddleware',
81+
'django.middleware.clickjacking.XFrameOptionsMiddleware',
82+
]
83+
84+
ROOT_URLCONF = 'QuestionTime.urls'
85+
86+
TEMPLATES = [
87+
{
88+
'BACKEND': 'django.template.backends.django.DjangoTemplates',
89+
'DIRS': [os.path.join(BASE_DIR, 'templates')],
90+
'APP_DIRS': True,
91+
'OPTIONS': {
92+
'context_processors': [
93+
'django.template.context_processors.debug',
94+
'django.template.context_processors.request',
95+
'django.contrib.auth.context_processors.auth',
96+
'django.contrib.messages.context_processors.messages',
97+
],
98+
},
99+
},
100+
]
101+
102+
WSGI_APPLICATION = 'QuestionTime.wsgi.application'
103+
104+
# Database
105+
# https://docs.djangoproject.com/en/3.0/ref/settings/#databases
106+
107+
DATABASES = {
108+
'default': {
109+
'ENGINE': 'django.db.backends.sqlite3',
110+
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
111+
}
112+
}
113+
114+
if not DEBUG:
115+
db_from_env = dj_database_url.config(conn_max_age=500)
116+
DATABASES['default'].update(db_from_env)
117+
118+
# Password validation
119+
# https://docs.djangoproject.com/en/3.0/ref/settings/#auth-password-validators
120+
121+
AUTH_PASSWORD_VALIDATORS = [
122+
{
123+
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
124+
},
125+
{
126+
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
127+
},
128+
{
129+
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
130+
},
131+
{
132+
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
133+
},
134+
]
135+
136+
if not DEBUG:
137+
SESSION_COOKIE_SECURE = True
138+
CSRF_COOKIE_SECURE = True
139+
140+
# Internationalization
141+
# https://docs.djangoproject.com/en/3.0/topics/i18n/
142+
143+
LANGUAGE_CODE = 'en-us'
144+
145+
TIME_ZONE = 'UTC'
146+
147+
USE_I18N = True
148+
149+
USE_L10N = True
150+
151+
USE_TZ = True
152+
153+
# Static files (CSS, JavaScript, Images)
154+
# https://docs.djangoproject.com/en/3.0/howto/static-files/
155+
156+
STATIC_URL = '/static/'
157+
STATICFILES_DIRS = [
158+
os.path.join(BASE_DIR, "static"),
159+
os.path.join(BASE_DIR, "frontend/dist"),
160+
]
161+
# absolute to the directory where collectstatic will collect static files for deployment
162+
if not DEBUG:
163+
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
164+
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
165+
166+
# django-crispy-forms
167+
CRISPY_TEMPLATE_PACK = 'bootstrap4'
168+
169+
# django.contrib.sites
170+
SITE_ID = 1
171+
172+
# django-allauth
173+
ACCOUNT_EMAIL_VERIFICATION = 'none'
174+
ACCOUNT_EMAIL_REQUIRED = True
175+
176+
LOGIN_URL = 'accounts/login/'
177+
LOGIN_REDIRECT_URL = '/'
178+
LOGOUT_REDIRECT_URL = '/'
179+
180+
# Django-REST-Framework
181+
REST_FRAMEWORK = {
182+
'DEFAULT_AUTHENTICATION_CLASSES': (
183+
'rest_framework.authentication.TokenAuthentication',
184+
'rest_framework.authentication.SessionAuthentication',
185+
),
186+
'DEFAULT_PERMISSION_CLASSES': (
187+
'rest_framework.permissions.IsAuthenticated',
188+
),
189+
'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination',
190+
'PAGE_SIZE': 3
191+
}
192+
193+
WEBPACK_LOADER = {
194+
'DEFAULT': {
195+
'BUNDLE_DIR_NAME': 'dist/',
196+
'STATS_FILE': os.path.join(BASE_DIR, 'frontend', 'webpack-stats.json'),
197+
}
198+
}

‎QuestionTime/urls.py‎

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
"""QuestionTime URL Configuration
2+
3+
The `urlpatterns` list routes URLs to views. For more information please see:
4+
https://docs.djangoproject.com/en/3.0/topics/http/urls/
5+
Examples:
6+
Function views
7+
1. Add an import: from my_app import views
8+
2. Add a URL to urlpatterns: path('', views.home, name='home')
9+
Class-based views
10+
1. Add an import: from other_app.views import Home
11+
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
12+
Including another URLconf
13+
1. Import the include() function: from django.urls import include, path
14+
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
15+
"""
16+
from django.conf import settings
17+
from django.conf.urls.static import static
18+
from django.contrib import admin
19+
from django.urls import path, include, re_path
20+
21+
from django_registration.backends.one_step.views import RegistrationView
22+
23+
from users.forms import CustomUserForm
24+
from core.views import IndexTemplateView
25+
26+
urlpatterns = [
27+
path('admin/', admin.site.urls),
28+
29+
path('accounts/register/', RegistrationView.as_view(
30+
form_class=CustomUserForm,
31+
success_url='/',
32+
), name='django_registration_register'),
33+
34+
path('api/', include('users.api.urls')),
35+
path('api/', include('questions.api.urls')),
36+
37+
path('accounts/',
38+
include('django_registration.backends.one_step.urls')),
39+
40+
path('accounts/', include('django.contrib.auth.urls')),
41+
42+
path('api-auth/', include('rest_framework.urls')),
43+
path('api/rest-auth/', include('rest_auth.urls')),
44+
path('api/rest-auth/registration/',
45+
include('rest_auth.registration.urls')),
46+
47+
# Redirect all unknown URL's paths to this
48+
re_path(r"^.*$", IndexTemplateView.as_view(), name="entry-point"),
49+
50+
] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)

‎QuestionTime/wsgi.py‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""
2+
WSGI config for QuestionTime project.
3+
4+
It exposes the WSGI callable as a module-level variable named ``application``.
5+
6+
For more information on this file, see
7+
https://docs.djangoproject.com/en/3.0/howto/deployment/wsgi/
8+
"""
9+
10+
import os
11+
12+
from django.core.wsgi import get_wsgi_application
13+
14+
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'QuestionTime.settings')
15+
16+
application = get_wsgi_application()

‎README.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# QuestionTime
2+
3+
A simple Quora like application for Asking questions. Built with django and VueJS

‎manage.py‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/usr/bin/env python
2+
"""Django's command-line utility for administrative tasks."""
3+
import os
4+
import sys
5+
6+
7+
def main():
8+
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'QuestionTime.settings')
9+
try:
10+
from django.core.management import execute_from_command_line
11+
except ImportError as exc:
12+
raise ImportError(
13+
"Couldn't import Django. Are you sure it's installed and "
14+
"available on your PYTHONPATH environment variable? Did you "
15+
"forget to activate a virtual environment?"
16+
) from exc
17+
execute_from_command_line(sys.argv)
18+
19+
20+
if __name__ == '__main__':
21+
main()

‎runtime.txt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
python-3.7.4

0 commit comments

Comments
 (0)