Skip to content

Commit

Permalink
EGCETSII#43-fix: remove mongo version
Browse files Browse the repository at this point in the history
  • Loading branch information
JSnow11 committed Jan 9, 2022
1 parent 713e98d commit ad962f1
Show file tree
Hide file tree
Showing 2 changed files with 212 additions and 2 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/django.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:

services:
mongodb:
image: mongo:3.4.23
image: mongo
env:
MONGO_INITDB_DATABASE: decide
ports:
Expand Down Expand Up @@ -55,7 +55,7 @@ jobs:
- name: Test administration module
run: |
cd decide
coverage run --branch --source=./administration/ ./manage.py test administration --noinput -v 2
coverage run --branch --source=./administration/ ./manage.py test administration --keepdb -v 2
coverage xml
- name: Codacy Coverage Reporter
uses: codacy/codacy-coverage-reporter-action@v1.1.0
Expand Down
210 changes: 210 additions & 0 deletions decide/decide/test_settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,210 @@
"""
Django settings for decide project.
Generated by 'django-admin startproject' using Django 2.0.
For more information on this file, see
https://docs.djangoproject.com/en/2.0/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/2.0/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.0/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '^##ydkswfu0+=ofw0l#$kv^8n)0$i(qd&d&ol#p9!b$8*5%j1+'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = ["*"]

# Login redirect
LOGIN_URL = '/authentication/login_form/'
LOGIN_REDIRECT_URL = '/authentication/bienvenida/'

# Application definition

INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',

'corsheaders',
'django_filters',
'rest_framework',
'rest_framework.authtoken',
'rest_framework_swagger',
'gateway',
]

REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': (
'rest_framework.authentication.BasicAuthentication',
'rest_framework.authentication.TokenAuthentication',
),
'DEFAULT_VERSIONING_CLASS': 'rest_framework.versioning.QueryParameterVersioning'
}

AUTHENTICATION_BACKENDS = [
'base.backends.AuthBackend',
]


MODULES = [
'administration',
'authentication',
'base',
'booth',
'census',
'voting',
'mixnet',
'postproc',
'store',
'visualizer',
]

ENV_DEVELOP = os.environ.get('ENV_DEVELOP', False)
ENV_MAIN = os.environ.get('ENV_MAIN', False)

if ENV_DEVELOP:
BASEURL = 'https://decide-full-tortuga-admin-dev.herokuapp.com'
elif ENV_MAIN:
BASEURL = 'https://decide-full-tortuga-admin.herokuapp.com'
else:
BASEURL = 'http://localhost:8000'

APIS = {
'administration': BASEURL,
'authentication': BASEURL,
'base': BASEURL,
'booth': BASEURL,
'census': BASEURL,
'mixnet': BASEURL,
'postproc': BASEURL,
'store': BASEURL,
'visualizer': BASEURL,
'voting': BASEURL,
}

MIDDLEWARE = [
'corsheaders.middleware.CorsMiddleware', # added to solve CORS
'django.middleware.common.CommonMiddleware', # added to solve CORS
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'corsheaders.middleware.CorsMiddleware'
]

ROOT_URLCONF = 'decide.urls'

TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, 'administration', 'frontend')],
'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',
],
},
},
]

STATIC_URL = '/static/'
STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'administration', 'frontend', 'build', 'static'),
)

WSGI_APPLICATION = 'decide.wsgi.application'

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

DATABASES = {
'default': {
'ENGINE': 'djongo',
'NAME': 'decide',
'CLIENT': {
'host': '127.0.0.1',
}
}
}

# Password validation
# https://docs.djangoproject.com/en/2.0/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.0/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True

TEST_RUNNER = 'django_nose.NoseTestSuiteRunner'

# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/2.0/howto/static-files/

STATIC_URL = '/static/'

# number of bits for the key, all auths should use the same number of bits
KEYBITS = 256

# Versioning
ALLOWED_VERSIONS = ['v1', 'v2']
DEFAULT_VERSION = 'v1'

try:
from local_settings import *
except ImportError:
print("local_settings.py not found")

# loading jsonnet config
if os.path.exists("config.jsonnet"):
import json
from _jsonnet import evaluate_file

config = json.loads(evaluate_file("config.jsonnet"))
for k, v in config.items():
vars()[k] = v

INSTALLED_APPS = INSTALLED_APPS + MODULES
django_heroku.settings(locals())

0 comments on commit ad962f1

Please sign in to comment.