Skip to content

Commit

Permalink
deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
sankha555 committed Mar 18, 2021
0 parents commit 0a8036c
Show file tree
Hide file tree
Showing 42 changed files with 2,554 additions and 0 deletions.
1 change: 1 addition & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web: gunicorn blind_coding.wsgi
Empty file added blind_coding/__init__.py
Empty file.
144 changes: 144 additions & 0 deletions blind_coding/settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
"""
Django settings for blind_coding project.
Generated by 'django-admin startproject' using Django 2.1.7.
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
import django_heroku

# 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 = 'q5*3y+mhfkjao*(*m=s!7y3#7=q%k6p^%z-f(4s^n56$8*3f0u'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = ['*']
LOGIN_REDIRECT_URL = '/main'
# Application definition

INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.sites',
'allauth',
'allauth.account',
'allauth.socialaccount',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'allauth.socialaccount.providers.google',
'main_app.apps.MainAppConfig',
]

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 = 'blind_coding.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 = 'blind_coding.wsgi.application'


# Database
# https://docs.djangoproject.com/en/2.1/ref/settings/#databases

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}


# 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

SITE_ID = 1
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/2.1/howto/static-files/
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
STATIC_URL = '/static/'
REPOSITORY_ROOT = os.path.dirname(BASE_DIR)
STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'static'),

)
AUTHENTICATION_BACKENDS = (
'django.contrib.auth.backends.ModelBackend',
'allauth.account.auth_backends.AuthenticationBackend',
)
STATIC_ROOT = os.path.join(REPOSITORY_ROOT, 'static/')

MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(REPOSITORY_ROOT, 'media/')

clientId = "222a2ef84f6881409d32ae21369d1a32"
clientSecret = "67872757630a355db890ee74b6b20926cb9e025dbb444182df2bd2700fc64af1"

django_heroku.settings(locals())
26 changes: 26 additions & 0 deletions blind_coding/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
"""blind_coding URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/2.1/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: path('', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path,re_path,include
from django.conf.urls.static import static
from django.conf import settings
urlpatterns = [
path('admin/', admin.site.urls),
path('',include('main_app.urls')),
re_path(r'^accounts/', include('allauth.urls')),

]+static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
16 changes: 16 additions & 0 deletions blind_coding/wsgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""
WSGI config for blind_coding 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', 'blind_coding.settings')

application = get_wsgi_application()
Binary file added db.sqlite3
Binary file not shown.
Empty file added main_app/__init__.py
Empty file.
Binary file added main_app/__pycache__/urls.cpython-36.pyc
Binary file not shown.
Binary file added main_app/__pycache__/views.cpython-36.pyc
Binary file not shown.
8 changes: 8 additions & 0 deletions main_app/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from __future__ import unicode_literals
from django.contrib import admin
from .models import Question,Userdata,Time_Penalty

# Register your models here.
admin.site.register(Question)
admin.site.register(Userdata)
admin.site.register(Time_Penalty)
7 changes: 7 additions & 0 deletions main_app/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from django.apps import AppConfig


class MainAppConfig(AppConfig):
name = 'main_app'
def ready(self):
import main_app.signals
45 changes: 45 additions & 0 deletions main_app/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Generated by Django 2.2.7 on 2020-01-03 18:07

from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

initial = True

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]

operations = [
migrations.CreateModel(
name='Question',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('qno', models.IntegerField(default=0)),
('text', models.CharField(max_length=45000)),
('testcaseno', models.IntegerField(default=0)),
('samplein', models.CharField(default='', max_length=45000)),
('sampleout', models.CharField(default='', max_length=45000)),
('test_case1', models.CharField(max_length=1000)),
('test_case2', models.CharField(max_length=1000)),
('test_case3', models.CharField(max_length=1000)),
('test_case1_sol', models.CharField(max_length=1000)),
('test_case2_sol', models.CharField(max_length=1000)),
('test_case3_sol', models.CharField(max_length=1000)),
],
),
migrations.CreateModel(
name='Userdata',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=100)),
('score', models.IntegerField(default=0)),
('answerGiven', models.CharField(default='00000', max_length=10)),
('timeElapsed', models.IntegerField(default=0)),
('user_id', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
),
]
43 changes: 43 additions & 0 deletions main_app/migrations/0002_auto_20200104_1324.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Generated by Django 2.2.7 on 2020-01-04 07:54

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
('main_app', '0001_initial'),
]

operations = [
migrations.AddField(
model_name='question',
name='weight',
field=models.IntegerField(default=10),
preserve_default=False,
),
migrations.AddField(
model_name='userdata',
name='total_penalty',
field=models.IntegerField(default=0),
),
migrations.CreateModel(
name='Time_Penalty',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('time_penalty', models.IntegerField(default=0)),
('no_wa', models.IntegerField(default=0)),
('player', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='main_app.Userdata')),
('question', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='questions', to='main_app.Question')),
],
options={
'unique_together': {('player', 'question')},
},
),
migrations.AddField(
model_name='question',
name='time_penalty',
field=models.ManyToManyField(blank=True, null=True, through='main_app.Time_Penalty', to='main_app.Userdata'),
),
]
18 changes: 18 additions & 0 deletions main_app/migrations/0003_auto_20200104_1332.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 2.2.7 on 2020-01-04 08:02

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('main_app', '0002_auto_20200104_1324'),
]

operations = [
migrations.AlterField(
model_name='question',
name='weight',
field=models.IntegerField(default=20),
),
]
18 changes: 18 additions & 0 deletions main_app/migrations/0004_userdata_chancesused.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 2.2.7 on 2020-01-11 10:40

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('main_app', '0003_auto_20200104_1332'),
]

operations = [
migrations.AddField(
model_name='userdata',
name='chancesUsed',
field=models.IntegerField(default=0),
),
]
Empty file added main_app/migrations/__init__.py
Empty file.
45 changes: 45 additions & 0 deletions main_app/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
from django.db import models
from django.contrib.auth.models import User
# Create your models here.

class Userdata(models.Model):
user_id=models.ForeignKey(User,on_delete=models.CASCADE)
name=models.CharField(max_length=100)
score = models.IntegerField(default = 0)
chancesUsed = models.IntegerField(default = 0)
answerGiven = models.CharField(max_length = 10, default="00000")
timeElapsed = models.IntegerField(default = 0)
total_penalty=models.IntegerField(default = 0)

def __str__(self):
return str(self.user_id.username)

class Question(models.Model):
qno=models.IntegerField(default=0)
weight = models.IntegerField(default=20)
text = models.CharField(max_length=45000)
time_penalty = models.ManyToManyField(Userdata, through="Time_Penalty",blank=True,null=True)
testcaseno=models.IntegerField(default=0)
samplein = models.CharField(max_length=45000,default='')
sampleout = models.CharField(max_length=45000,default='')
test_case1=models.CharField(max_length=1000)
test_case2=models.CharField(max_length=1000)
test_case3=models.CharField(max_length=1000)
test_case1_sol=models.CharField(max_length=1000)
test_case2_sol=models.CharField(max_length=1000)
test_case3_sol=models.CharField(max_length=1000)

def __str__(self):
return str(self.pk)

class Time_Penalty(models.Model):
player = models.ForeignKey(Userdata, on_delete=models.CASCADE)
question = models.ForeignKey(Question, on_delete=models.CASCADE,related_name='questions')
time_penalty = models.IntegerField(default=0)
no_wa = models.IntegerField(default=0)

class Meta:
unique_together = ("player", "question")

def __str__(self):
return "{} : {}".format(self.player.name, self.question.qno)
4 changes: 4 additions & 0 deletions main_app/settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Application definition
INSTALLED_APPS = [
'main_app'
]
Loading

0 comments on commit 0a8036c

Please sign in to comment.