Commit 77435bfb authored by Irina Kera Gundersen's avatar Irina Kera Gundersen
Browse files

Merge branch 'master' into 'dev'

Merge new master to dev

See merge request !3
parents 485f65de a5378630
Pipeline #113342 passed with stage
in 27 seconds
image: python:3
before_script:
- apt-get update -qy
- apt-get install -y ruby-dev
- gem install dpl
stages: stages:
- test
- staging - staging
- production
- test test:
image: python:3.8
test-job1:
stage: test stage: test
script: script:
- echo "This job tests something" # this configures Django application to use attached postgres database that is run on `postgres` host
- cd backend/secfit
- apt-get update -qy
- pip install -r requirements.txt
staging: staging:
type: deploy type: deploy
stage: staging image: ruby
image: ruby:latest stage: staging
script: script:
- dpl --provider=heroku --app=$HEROKU_APP_STAGING --api-key=$HEROKU_API_KEY - apt-get update -qy
only: - apt-get install -y ruby-dev
- dev - gem install dpl
- dpl --provider=heroku --app=secfit-group15-frontend --api-key=$HEROKU_API_KEY
production: - dpl --provider=heroku --app=secfit-group15-backend --api-key=$HEROKU_API_KEY
type: deploy only:
stage: production - master
image: ruby:latest
script:
- dpl --provider=heroku --app=$HEROKU_APP_PRODUCTION --api-key=$HEROKU_API_KEY
only:
- master
...@@ -6,4 +6,4 @@ ENV GROUPID=${GROUPID} ...@@ -6,4 +6,4 @@ ENV GROUPID=${GROUPID}
ENV PORT_PREFIX=${PORT_PREFIX} ENV PORT_PREFIX=${PORT_PREFIX}
# Copy nginx config to the container # Copy nginx config to the container
COPY nginx.conf /etc/nginx/nginx.conf COPY nginx.conf /etc/nginx/nginx.conf
\ No newline at end of file
web: gunicorn --pythonpath 'backend/secfit' secfit.wsgi --log-file -
\ No newline at end of file
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
#import logging
import os
import dj_database_url
from django.test.runner import DiscoverRunner
MAX_CONN_AGE = 600
def settings(config, *, db_colors=False, databases=True, test_runner=True, staticfiles=True, allowed_hosts=True, logging=True, secret_key=True):
# Database configuration.
# TODO: support other database (e.g. TEAL, AMBER, etc, automatically.)
if databases:
# Integrity check.
if 'DATABASES' not in config:
config['DATABASES'] = {'default': None}
conn_max_age = config.get('CONN_MAX_AGE', MAX_CONN_AGE)
if db_colors:
# Support all Heroku databases.
# TODO: This appears to break TestRunner.
for (env, url) in os.environ.items():
if env.startswith('HEROKU_POSTGRESQL'):
db_color = env[len('HEROKU_POSTGRESQL_'):].split('_')[0]
#logger.info('Adding ${} to DATABASES Django setting ({}).'.format(env, db_color))
config['DATABASES'][db_color] = dj_database_url.parse(url, conn_max_age=conn_max_age, ssl_require=True)
if 'DATABASE_URL' in os.environ:
#logger.info('Adding $DATABASE_URL to default DATABASE Django setting.')
# Configure Django for DATABASE_URL environment variable.
config['DATABASES']['default'] = dj_database_url.config(conn_max_age=conn_max_age, ssl_require=True)
#logger.info('Adding $DATABASE_URL to TEST default DATABASE Django setting.')
# Enable test database if found in CI environment.
if 'CI' in os.environ:
config['DATABASES']['default']['TEST'] = config['DATABASES']['default']
#else:
#logger.info('$DATABASE_URL not found, falling back to previous settings!')
if test_runner:
# Enable test runner if found in CI environment.
if 'CI' in os.environ:
config['TEST_RUNNER'] = 'django_heroku.HerokuDiscoverRunner'
# Staticfiles configuration.
if staticfiles:
#logger.info('Applying Heroku Staticfiles configuration to Django settings.')
config['STATIC_ROOT'] = os.path.join(config['BASE_DIR'], 'staticfiles')
config['STATIC_URL'] = '/static/'
# Ensure STATIC_ROOT exists.
os.makedirs(config['STATIC_ROOT'], exist_ok=True)
# Insert Whitenoise Middleware.
try:
config['MIDDLEWARE_CLASSES'] = tuple(['whitenoise.middleware.WhiteNoiseMiddleware'] + list(config['MIDDLEWARE_CLASSES']))
except KeyError:
config['MIDDLEWARE'] = tuple(['whitenoise.middleware.WhiteNoiseMiddleware'] + list(config['MIDDLEWARE']))
# Enable GZip.
config['STATICFILES_STORAGE'] = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
if allowed_hosts:
#logger.info('Applying Heroku ALLOWED_HOSTS configuration to Django settings.')
config['ALLOWED_HOSTS'] = ['*']
"""
if logging:
logger.info('Applying Heroku logging configuration to Django settings.')
config['LOGGING'] = {
'version': 1,
'disable_existing_loggers': False,
'formatters': {
'verbose': {
'format': ('%(asctime)s [%(process)d] [%(levelname)s] ' +
'pathname=%(pathname)s lineno=%(lineno)s ' +
'funcname=%(funcName)s %(message)s'),
'datefmt': '%Y-%m-%d %H:%M:%S'
},
'simple': {
'format': '%(levelname)s %(message)s'
}
},
'handlers': {
'null': {
'level': 'DEBUG',
'class': 'logging.NullHandler',
},
'console': {
'level': 'DEBUG',
'class': 'logging.StreamHandler',
'formatter': 'verbose'
}
},
'loggers': {
'testlogger': {
'handlers': ['console'],
'level': 'INFO',
}
}
}
"""
# SECRET_KEY configuration.
if secret_key:
if 'SECRET_KEY' in os.environ:
#logger.info('Adding $SECRET_KEY to SECRET_KEY Django setting.')
# Set the Django setting from the environment variable.
config['SECRET_KEY'] = os.environ['SECRET_KEY']
...@@ -12,6 +12,8 @@ https://docs.djangoproject.com/en/3.1/ref/settings/ ...@@ -12,6 +12,8 @@ https://docs.djangoproject.com/en/3.1/ref/settings/
from pathlib import Path from pathlib import Path
import os import os
from .djangoHeroku import settings
# Get the GROUPID variable to accept connections from the application server and NGINX # Get the GROUPID variable to accept connections from the application server and NGINX
...@@ -43,6 +45,8 @@ ALLOWED_HOSTS = [ ...@@ -43,6 +45,8 @@ ALLOWED_HOSTS = [
"10." + groupid + ".0.4", "10." + groupid + ".0.4",
"molde.idi.ntnu.no", "molde.idi.ntnu.no",
"10.0.2.2", "10.0.2.2",
"secfit-group15-frontend.herokuapp.com",
"secfit-group15-backend.herokuapp.com",
] ]
# Application definition # Application definition
...@@ -95,12 +99,22 @@ WSGI_APPLICATION = "secfit.wsgi.application" ...@@ -95,12 +99,22 @@ WSGI_APPLICATION = "secfit.wsgi.application"
# Database # Database
# https://docs.djangoproject.com/en/3.1/ref/settings/#databases # https://docs.djangoproject.com/en/3.1/ref/settings/#databases
DATABASES = { is_prod = os.environ.get("IS_HEROKU", None)
"default": {
"ENGINE": "django.db.backends.sqlite3", if is_prod:
"NAME": BASE_DIR / "db.sqlite3", settings(locals())
if 'DATABASE_URL' in os.environ:
import dj_database_url
print("\n\n\n\n\nHEI\n\n\n\n\n\n")
DATABASES = {'default': dj_database_url.config()}
else:
DATABASES = {
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": BASE_DIR / "db.sqlite3",
}
} }
}
# CORS Policy # CORS Policy
CORS_ORIGIN_ALLOW_ALL = ( CORS_ORIGIN_ALLOW_ALL = (
......
web: cd frontend && cordova run browser --release --port=$PORT
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Exercise</title> <title>Exercise</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-giJF6kkoqNQ00vy+HMDP7azOuL0xtbfIcaT9wjKHr8RbDVddVHyTfAAsrekwKmP1" crossorigin="anonymous"> <link
href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta1/dist/css/bootstrap.min.css"
rel="stylesheet"
integrity="sha384-giJF6kkoqNQ00vy+HMDP7azOuL0xtbfIcaT9wjKHr8RbDVddVHyTfAAsrekwKmP1"
crossorigin="anonymous"
/>
<script src="https://kit.fontawesome.com/0ce6c392ca.js" crossorigin="anonymous"></script> <script
<link rel="stylesheet" href="styles/style.css"> src="https://kit.fontawesome.com/0ce6c392ca.js"
crossorigin="anonymous"
></script>
<link rel="stylesheet" href="styles/style.css" />
<script src="scripts/navbar.js" type="text/javascript" defer></script> <script src="scripts/navbar.js" type="text/javascript" defer></script>
</head> </head>
<body> <body>
<navbar-el></navbar-el> <navbar-el></navbar-el>
<div class="container"> <div class="container">
<div class="row"> <div class="row">
<div class="col-lg"> <div class="col-lg">
<h3 class="mt-3">View/Edit Exercise</h3> <h3 class="mt-3">View/Edit Exercise</h3>
</div> </div>
</div> </div>
<form class="row g-3" id="form-exercise"> <form class="row g-3" id="form-exercise">
<div class="col-lg-6 "> <div class="col-lg-6 ">
<label for="inputName" class="form-label">Name</label> <label for="inputName" class="form-label">Name</label>
<input type="text" class="form-control" id="inputName" name="name" readonly> <input
</div> type="text"
<div class="col-lg-6"></div> class="form-control"
<div class="col-lg-6"> id="inputName"
<label for="inputDescription" class="form-label">Description</label> name="name"
<textarea class="form-control" id="inputDescription" name="description" readonly></textarea> readonly
</div> />
<div class="col-lg-6"></div> </div>
<div class="col-lg-6"> <div class="col-lg-6"></div>
<label for="inputUnit" class="form-label">Unit</label> <div class="col-lg-6">
<input type="text" class="form-control" id="inputUnit" name="unit" readonly> <label for="inputDescription" class="form-label">Description</label>
</div> <textarea
<div class="col-lg-6"></div> class="form-control"
<div class="col-lg-6"> id="inputDescription"
<input type="button" class="btn btn-primary hide" id="btn-ok-exercise" value=" OK "> name="description"
<input type="button" class="btn btn-primary" id="btn-edit-exercise" value=" Edit "> readonly
<input type="button" class="btn btn-secondary hide" id="btn-cancel-exercise" value="Cancel"> ></textarea>
<input type="button" class="btn btn-danger float-end hide" id="btn-delete-exercise" value="Delete"> </div>
</div> <div class="col-lg-6"></div>
<div class="col-lg-6"> <div class="col-lg-6">
<label for="inputUnit" class="form-label">Unit</label>
</div> <input
</form> type="text"
class="form-control"
id="inputUnit"
name="unit"
readonly
/>
</div>
<div class="col-lg-6"></div>
<div class="col-lg-6">
<input
type="button"
class="btn btn-primary hide"
id="btn-ok-exercise"
value=" OK "
/>
<input
type="button"
class="btn btn-primary"
id="btn-edit-exercise"
value=" Edit "
/>
<input
type="button"
class="btn btn-secondary hide"
id="btn-cancel-exercise"
value="Cancel"
/>
<input
type="button"
class="btn btn-danger float-end hide"
id="btn-delete-exercise"
value="Delete"
/>
</div> </div>
<script src="scripts/defaults.js"></script> <div class="col-lg-6"></div>
<script src="scripts/scripts.js"></script> </form>
<script src="scripts/exercise.js"></script> </div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta1/dist/js/bootstrap.bundle.min.js" integrity="sha384-ygbV9kiqUc6oa4msXn9868pTtWMgiQaeYH7/t7LECLbyPA2x65Kgf80OJFdroafW" crossorigin="anonymous"></script> <script src="scripts/defaults.js"></script>
</body> <script src="scripts/scripts.js"></script>
</html> <script src="scripts/exercise.js"></script>
\ No newline at end of file <script
src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta1/dist/js/bootstrap.bundle.min.js"
integrity="sha384-ygbV9kiqUc6oa4msXn9868pTtWMgiQaeYH7/t7LECLbyPA2x65Kgf80OJFdroafW"
crossorigin="anonymous"
></script>
</body>
</html>
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Login</title> <title>Login</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-giJF6kkoqNQ00vy+HMDP7azOuL0xtbfIcaT9wjKHr8RbDVddVHyTfAAsrekwKmP1" crossorigin="anonymous"> <link
href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta1/dist/css/bootstrap.min.css"
rel="stylesheet"
integrity="sha384-giJF6kkoqNQ00vy+HMDP7azOuL0xtbfIcaT9wjKHr8RbDVddVHyTfAAsrekwKmP1"
crossorigin="anonymous"
/>
<script src="https://kit.fontawesome.com/0ce6c392ca.js" crossorigin="anonymous"></script> <script
<link rel="stylesheet" href="styles/style.css"> src="https://kit.fontawesome.com/0ce6c392ca.js"
crossorigin="anonymous"
></script>
<link rel="stylesheet" href="styles/style.css" />
<script src="scripts/navbar.js" type="text/javascript" defer></script> <script src="scripts/navbar.js" type="text/javascript" defer></script>
</head> </head>
<body> <body>
<navbar-el></navbar-el> <navbar-el></navbar-el>
<div class="container"> <div class="container">
<div class="card mt-3 border-0"> <div class="card mt-3 border-0">
<article class="card-body mx-auto"> <article class="card-body mx-auto">
<h4 class="card-title mt-3 text-center">Log In</h4> <h4 class="card-title mt-3 text-center">Log In</h4>
<form id="form-login"> <form id="form-login">
<div class="input-group mb-2"> <div class="input-group mb-2">
<span class="input-group-text"> <i class="fas fa-user"></i> </span> <span class="input-group-text">
<input name="username" class="form-control" placeholder="User name" type="text" required> <i class="fas fa-user"></i>
</div> <!-- form-group// --> </span>
<input
name="username"
class="form-control"
placeholder="User name"
type="text"
required
/>
</div>
<!-- form-group// -->
<div class="input-group mb-2"> <div class="input-group mb-2">
<span class="input-group-text"> <i class="fas fa-lock"></i> </span> <span class="input-group-text">
<input class="form-control" name="password" placeholder="Password" type="password" required> <i class="fas fa-lock"></i>
</div> <!-- form-group// --> </span>
<input
class="form-control"
name="password"
placeholder="Password"
type="password"
required
/>
</div>
<!-- form-group// -->
<div class="input-group mb-2"> <div class="input-group mb-2">
<label class="checkbox" style="border: none;"> <label class="checkbox" style="border: none;">
<input type="checkbox" value="rememberMe" id="rememberMe"> Remember me <input type="checkbox" value="rememberMe" id="rememberMe" />
</label> Remember me
</div> <!-- form-group// --> </label>
</div>
<!-- form-group// -->
<div class="d-grid"> <div class="d-grid">
<input type="button" class="btn btn-primary" id="btn-login" value=" Log in "> <input
</div> <!-- form-group// --> type="button"
</form> class="btn btn-primary"
id="btn-login"
value=" Log in "
/>
</div>
<!-- form-group// -->
</form>
</article> </article>
</div> <!-- card.// --> </div>
<!-- card.// -->
</div> </div>
<script src="scripts/defaults.js"></script> <script src="scripts/defaults.js"></script>
<script src="scripts/scripts.js"></script> <script src="scripts/scripts.js"></script>
<script src="scripts/login.js"></script> <script src="scripts/login.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta1/dist/js/bootstrap.bundle.min.js" integrity="sha384-ygbV9kiqUc6oa4msXn9868pTtWMgiQaeYH7/t7LECLbyPA2x65Kgf80OJFdroafW" crossorigin="anonymous"></script> <script
</body> src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta1/dist/js/bootstrap.bundle.min.js"
</html> integrity="sha384-ygbV9kiqUc6oa4msXn9868pTtWMgiQaeYH7/t7LECLbyPA2x65Kgf80OJFdroafW"
\ No newline at end of file crossorigin="anonymous"
></script>
</body>
</html>
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Logout</title> <title>Logout</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-giJF6kkoqNQ00vy+HMDP7azOuL0xtbfIcaT9wjKHr8RbDVddVHyTfAAsrekwKmP1" crossorigin="anonymous"> <link
href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta1/dist/css/bootstrap.min.css"
rel="stylesheet"
integrity="sha384-giJF6kkoqNQ00vy+HMDP7azOuL0xtbfIcaT9wjKHr8RbDVddVHyTfAAsrekwKmP1"
crossorigin="anonymous"
/>
<script src="https://kit.fontawesome.com/0ce6c392ca.js" crossorigin="anonymous"></script> <script
<link rel="stylesheet" href="styles/style.css"> src="https://kit.fontawesome.com/0ce6c392ca.js"
</head> crossorigin="anonymous"
<body> ></script>
<link rel="stylesheet" href="styles/style.css" />
</head>
<body>
<script src="scripts/defaults.js"></script> <script src="scripts/defaults.js"></script>
<script src="scripts/scripts.js"></script> <script src="scripts/scripts.js"></script>
<script src="scripts/logout.js"></script> <script src="scripts/logout.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta1/dist/js/bootstrap.bundle.min.js" integrity="sha384-ygbV9kiqUc6oa4msXn9868pTtWMgiQaeYH7/t7LECLbyPA2x65Kgf80OJFdroafW" crossorigin="anonymous"></script> <script
</body> src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta1/dist/js/bootstrap.bundle.min.js"
</html> integrity="sha384-ygbV9kiqUc6oa4msXn9868pTtWMgiQaeYH7/t7LECLbyPA2x65Kgf80OJFdroafW"
\ No newline at end of file crossorigin="anonymous"
></script>
</body>
</html>
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head>
<head> <meta charset="UTF-8" />
<meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>My Coach</title> <title>My Coach</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-giJF6kkoqNQ00vy+HMDP7azOuL0xtbfIcaT9wjKHr8RbDVddVHyTfAAsrekwKmP1" crossorigin="anonymous"> <link
<script src="https://kit.fontawesome.com/0ce6c392ca.js" crossorigin="anonymous"></script> href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta1/dist/css/bootstrap.min.css"
<link rel="stylesheet" href="styles/style.css"> rel="stylesheet"
integrity="sha384-giJF6kkoqNQ00vy+HMDP7azOuL0xtbfIcaT9wjKHr8RbDVddVHyTfAAsrekwKmP1"
crossorigin="anonymous"
/>
<script
src="https://kit.fontawesome.com/0ce6c392ca.js"
crossorigin="anonymous"
></script>
<link rel="stylesheet" href="styles/style.css" />
<script src="scripts/navbar.js" type="text/javascript" defer></script> <script src="scripts/navbar.js" type="text/javascript" defer></script>
</head> </head>
<body> <body>
<navbar-el></navbar-el> <navbar-el></navbar-el>
<div class="container"> <div class="container">
<div class="row"> <div class="row">
<div class="col-lg text-center"> <div class="col-lg text-center">
<h3 class="mt-5">Coach & Files</h3> <h3 class="mt-5">Coach & Files</h3>
<p>On this page you can view/change your current coach as well as view the files your coaches (present <p>
and previous) On this page you can view/change your current coach as well as view
have uploaded. the files your coaches (present and previous) have uploaded.