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:
- test
- staging
- production
- test
test-job1:
test:
image: python:3.8
stage: test
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:
type: deploy
stage: staging
image: ruby:latest
script:
- dpl --provider=heroku --app=$HEROKU_APP_STAGING --api-key=$HEROKU_API_KEY
only:
- dev
production:
type: deploy
stage: production
image: ruby:latest
script:
- dpl --provider=heroku --app=$HEROKU_APP_PRODUCTION --api-key=$HEROKU_API_KEY
only:
- master
type: deploy
image: ruby
stage: staging
script:
- apt-get update -qy
- apt-get install -y ruby-dev
- gem install dpl
- dpl --provider=heroku --app=secfit-group15-frontend --api-key=$HEROKU_API_KEY
- dpl --provider=heroku --app=secfit-group15-backend --api-key=$HEROKU_API_KEY
only:
- master
......@@ -6,4 +6,4 @@ ENV GROUPID=${GROUPID}
ENV PORT_PREFIX=${PORT_PREFIX}
# Copy nginx config to the container
COPY nginx.conf /etc/nginx/nginx.conf
\ No newline at end of file
COPY nginx.conf /etc/nginx/nginx.conf
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/
from pathlib import Path
import os
from .djangoHeroku import settings
# Get the GROUPID variable to accept connections from the application server and NGINX
......@@ -43,6 +45,8 @@ ALLOWED_HOSTS = [
"10." + groupid + ".0.4",
"molde.idi.ntnu.no",
"10.0.2.2",
"secfit-group15-frontend.herokuapp.com",
"secfit-group15-backend.herokuapp.com",
]
# Application definition
......@@ -95,12 +99,22 @@ WSGI_APPLICATION = "secfit.wsgi.application"
# Database
# https://docs.djangoproject.com/en/3.1/ref/settings/#databases
DATABASES = {
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": BASE_DIR / "db.sqlite3",
is_prod = os.environ.get("IS_HEROKU", None)
if is_prod:
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_ORIGIN_ALLOW_ALL = (
......
web: cd frontend && cordova run browser --release --port=$PORT
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<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>
<link rel="stylesheet" href="styles/style.css">
<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>
</head>
<body>
<navbar-el></navbar-el>
</head>
<body>
<navbar-el></navbar-el>
<div class="container">
<div class="row">
<div class="col-lg">
<h3 class="mt-3">View/Edit Exercise</h3>
</div>
</div>
<form class="row g-3" id="form-exercise">
<div class="col-lg-6 ">
<label for="inputName" class="form-label">Name</label>
<input type="text" class="form-control" id="inputName" name="name" readonly>
</div>
<div class="col-lg-6"></div>
<div class="col-lg-6">
<label for="inputDescription" class="form-label">Description</label>
<textarea class="form-control" id="inputDescription" name="description" readonly></textarea>
</div>
<div class="col-lg-6"></div>
<div class="col-lg-6">
<label for="inputUnit" class="form-label">Unit</label>
<input 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 class="col-lg-6">
</div>
</form>
<div class="container">
<div class="row">
<div class="col-lg">
<h3 class="mt-3">View/Edit Exercise</h3>
</div>
</div>
<form class="row g-3" id="form-exercise">
<div class="col-lg-6 ">
<label for="inputName" class="form-label">Name</label>
<input
type="text"
class="form-control"
id="inputName"
name="name"
readonly
/>
</div>
<div class="col-lg-6"></div>
<div class="col-lg-6">
<label for="inputDescription" class="form-label">Description</label>
<textarea
class="form-control"
id="inputDescription"
name="description"
readonly
></textarea>
</div>
<div class="col-lg-6"></div>
<div class="col-lg-6">
<label for="inputUnit" class="form-label">Unit</label>
<input
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>
<script src="scripts/defaults.js"></script>
<script src="scripts/scripts.js"></script>
<script src="scripts/exercise.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>
</body>
</html>
\ No newline at end of file
<div class="col-lg-6"></div>
</form>
</div>
<script src="scripts/defaults.js"></script>
<script src="scripts/scripts.js"></script>
<script src="scripts/exercise.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>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<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>
<link rel="stylesheet" href="styles/style.css">
<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>
</head>
<body>
</head>
<body>
<navbar-el></navbar-el>
<div class="container">
<div class="card mt-3 border-0">
<div class="container">
<div class="card mt-3 border-0">
<article class="card-body mx-auto">
<h4 class="card-title mt-3 text-center">Log In</h4>
<form id="form-login">
<h4 class="card-title mt-3 text-center">Log In</h4>
<form id="form-login">
<div class="input-group mb-2">
<span class="input-group-text"> <i class="fas fa-user"></i> </span>
<input name="username" class="form-control" placeholder="User name" type="text" required>
</div> <!-- form-group// -->
<span class="input-group-text">
<i class="fas fa-user"></i>
</span>
<input
name="username"
class="form-control"
placeholder="User name"
type="text"
required
/>
</div>
<!-- form-group// -->
<div class="input-group mb-2">
<span class="input-group-text"> <i class="fas fa-lock"></i> </span>
<input class="form-control" name="password" placeholder="Password" type="password" required>
</div> <!-- form-group// -->
<span class="input-group-text">
<i class="fas fa-lock"></i>
</span>
<input
class="form-control"
name="password"
placeholder="Password"
type="password"
required
/>
</div>
<!-- form-group// -->
<div class="input-group mb-2">
<label class="checkbox" style="border: none;">
<input type="checkbox" value="rememberMe" id="rememberMe"> Remember me
</label>
</div> <!-- form-group// -->
<label class="checkbox" style="border: none;">
<input type="checkbox" value="rememberMe" id="rememberMe" />
Remember me
</label>
</div>
<!-- form-group// -->
<div class="d-grid">
<input type="button" class="btn btn-primary" id="btn-login" value=" Log in ">
</div> <!-- form-group// -->
</form>
<input
type="button"
class="btn btn-primary"
id="btn-login"
value=" Log in "
/>
</div>
<!-- form-group// -->
</form>
</article>
</div> <!-- card.// -->
</div>
</div>
<!-- card.// -->
</div>
<script src="scripts/defaults.js"></script>
<script src="scripts/scripts.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>
</body>
</html>
\ 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>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<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>
<link rel="stylesheet" href="styles/style.css">
</head>
<body>
<script
src="https://kit.fontawesome.com/0ce6c392ca.js"
crossorigin="anonymous"
></script>
<link rel="stylesheet" href="styles/style.css" />
</head>
<body>
<script src="scripts/defaults.js"></script>
<script src="scripts/scripts.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>
</body>
</html>
\ 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>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<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">
<script src="https://kit.fontawesome.com/0ce6c392ca.js" crossorigin="anonymous"></script>
<link rel="stylesheet" href="styles/style.css">
<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>
<link rel="stylesheet" href="styles/style.css" />
<script src="scripts/navbar.js" type="text/javascript" defer></script>
</head>
</head>
<body>
<body>
<navbar-el></navbar-el>
<div class="container">
<div class="row">
<div class="col-lg text-center">
<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
and previous)
have uploaded.
</p>
</div>
<div class="row">
<div class="col-lg text-center">
<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 and previous) have uploaded.
</p>
</div>
<form id="form-coach" class="row">
<div class="col-lg-6 mb-3">
<label for="input-coach" class="form-label">Coach</label>
<input type="text" class="form-control mb-1" placeholder="User ID" id="input-coach" name="coach"
readonly>
<input type="button" class="btn btn-primary" id="button-edit-coach" value="Edit">
<input type="button" class="btn btn-primary hide" id="button-set-coach" value=" OK ">
<input type="button" class="btn btn-secondary hide" id="button-cancel-coach" value="Cancel">
</div>
<div id="offers-div" class="col-lg-6 mb-3">
<label for="list-offers" class="form-label">Offers</label>
<ul class="list-group" id="list-offers">
</ul>
</div>
</form>
<div class="row">
<div id="list-files-div" class="col">
<label for="list-tab" class="form-label">Files</label>
</div>
</div>
<form id="form-coach" class="row">
<div class="col-lg-6