Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge staing into main #191

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
136 changes: 68 additions & 68 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
@@ -1,79 +1,79 @@
name: Django Tests
on: [pull_request, push]
# name: Django Tests
# on: [pull_request, push]

jobs:
test:
runs-on: ubuntu-latest
# jobs:
# test:
# runs-on: ubuntu-latest

env:
MYSQL_ROOT_PASSWORD: mysql_root_password
MYSQL_DATABASE: mysql_database
MYSQL_USER: mysql_user
MYSQL_PASSWORD: mysql_password
MYSQL_HOST: 127.0.0.1
MYSQL_PORT: 3306
# env:
# MYSQL_ROOT_PASSWORD: mysql_root_password
# MYSQL_DATABASE: mysql_database
# MYSQL_USER: mysql_user
# MYSQL_PASSWORD: mysql_password
# MYSQL_HOST: 127.0.0.1
# MYSQL_PORT: 3306

services:
mysql:
image: mysql:latest
env:
MYSQL_ROOT_PASSWORD: ${{ env.MYSQL_ROOT_PASSWORD }}
MYSQL_DATABASE: ${{ env.MYSQL_DATABASE }}
MYSQL_USER: ${{ env.MYSQL_USER }}
MYSQL_PASSWORD: ${{ env.MYSQL_PASSWORD }}
ports:
- 3306:3306
options: >-
--health-cmd="mysqladmin ping"
--health-interval=10s
--health-timeout=5s
--health-retries=3
# services:
# mysql:
# image: mysql:latest
# env:
# MYSQL_ROOT_PASSWORD: ${{ env.MYSQL_ROOT_PASSWORD }}
# MYSQL_DATABASE: ${{ env.MYSQL_DATABASE }}
# MYSQL_USER: ${{ env.MYSQL_USER }}
# MYSQL_PASSWORD: ${{ env.MYSQL_PASSWORD }}
# ports:
# - 3306:3306
# options: >-
# --health-cmd="mysqladmin ping"
# --health-interval=10s
# --health-timeout=5s
# --health-retries=3

steps:
- name: Checkout code
uses: actions/checkout@v2
# steps:
# - name: Checkout code
# uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.10"
# - name: Set up Python
# uses: actions/setup-python@v2
# with:
# python-version: "3.10"

- name: Install dependencies
run: |
python3 -m pip install --upgrade pip
sudo apt-get update -y
sudo apt-get install mysql-client -y
sudo apt-get install graphviz graphviz-dev -y
pip install pipenv
pipenv requirements > requirements.txt
pip install -r requirements.txt
# - name: Install dependencies
# run: |
# python3 -m pip install --upgrade pip
# sudo apt-get update -y
# sudo apt-get install mysql-client -y
# sudo apt-get install graphviz graphviz-dev -y
# pip install pipenv
# pipenv requirements > requirements.txt
# pip install -r requirements.txt

- name: Make migrations
env:
MYSQL_ROOT_PASSWORD: ${{ env.MYSQL_ROOT_PASSWORD }}
MYSQL_DATABASE: ${{ env.MYSQL_DATABASE }}
MYSQL_USER: ${{ env.MYSQL_USER }}
MYSQL_PASSWORD: ${{ env.MYSQL_PASSWORD }}
MYSQL_HOST: 127.0.0.1
MYSQL_PORT: ${{ env.MYSQL_PORT }}
# - name: Make migrations
# env:
# MYSQL_ROOT_PASSWORD: ${{ env.MYSQL_ROOT_PASSWORD }}
# MYSQL_DATABASE: ${{ env.MYSQL_DATABASE }}
# MYSQL_USER: ${{ env.MYSQL_USER }}
# MYSQL_PASSWORD: ${{ env.MYSQL_PASSWORD }}
# MYSQL_HOST: 127.0.0.1
# MYSQL_PORT: ${{ env.MYSQL_PORT }}

run: |
mysql -u root -p"${{ env.MYSQL_ROOT_PASSWORD }}" -e "GRANT ALL PRIVILEGES ON *.* TO '${{ env.MYSQL_USER }}'@'%';"
python3 ./src/manage.py migrate
# run: |
# mysql -u root -p"${{ env.MYSQL_ROOT_PASSWORD }}" -e "GRANT ALL PRIVILEGES ON *.* TO '${{ env.MYSQL_USER }}'@'%';"
# python3 ./src/manage.py migrate

- name: Run linters
run: |
pip install flake8
flake8 .
# - name: Run linters
# run: |
# pip install flake8
# flake8 .

- name: Run tests
env:
MYSQL_ROOT_PASSWORD: ${{ env.MYSQL_ROOT_PASSWORD }}
MYSQL_DATABASE: ${{ env.MYSQL_DATABASE }}
MYSQL_USER: ${{ env.MYSQL_USER }}
MYSQL_PASSWORD: ${{ env.MYSQL_PASSWORD }}
MYSQL_HOST: ${{ env.MYSQL_HOST }}
MYSQL_PORT: ${{ env.MYSQL_PORT }}
# - name: Run tests
# env:
# MYSQL_ROOT_PASSWORD: ${{ env.MYSQL_ROOT_PASSWORD }}
# MYSQL_DATABASE: ${{ env.MYSQL_DATABASE }}
# MYSQL_USER: ${{ env.MYSQL_USER }}
# MYSQL_PASSWORD: ${{ env.MYSQL_PASSWORD }}
# MYSQL_HOST: ${{ env.MYSQL_HOST }}
# MYSQL_PORT: ${{ env.MYSQL_PORT }}

run: |
python3 ./src/manage.py test
# run: |
# python3 ./src/manage.py test
8 changes: 4 additions & 4 deletions src/base/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,25 @@ class BadRequestErrorView(TemplateView):
"""
Displays a custom 400 error page when a bad request is made.
"""
template_name = '400.html'
template_name = 'http_errors/400.html'


class ForbiddenErrorView(TemplateView):
"""
Displays a custom 403 error page when access to a resource is forbidden.
"""
template_name = '403.html'
template_name = 'http_errors/403.html'


class NotFoundErrorView(TemplateView):
"""
Displays a custom 404 error page when a page is not found.
"""
template_name = '404.html'
template_name = 'http_errors/404.html'


class InternalServerErrorView(TemplateView):
"""
Displays a custom 500 error page when an internal server error occurs.
"""
template_name = '500.html'
template_name = 'http_errors/500.html'
2 changes: 1 addition & 1 deletion src/signal_documentation/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from sentry_sdk.integrations.django import DjangoIntegration
from sentry_sdk.integrations.redis import RedisIntegration

EPIVIS_URL = os.environ.get("EPIVIS_URL", "https://deploy-preview-36--cmu-delphi-epivis.netlify.app/")
EPIVIS_URL = os.environ.get("EPIVIS_URL", "https://delphi.cmu.edu/epivis/")
DATA_EXPORT_URL = os.environ.get("DATA_EXPORT_URL", "https://api.delphi.cmu.edu/epidata/covidcast/csv")
COVIDCAST_URL = os.environ.get("COVIDCAST_URL", "https://api.delphi.cmu.edu/epidata/covidcast/")

Expand Down
16 changes: 16 additions & 0 deletions src/templates/http_errors/400.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{% extends "http_errors/error.html" %}
{% load static %}
{% load i18n %}

{% block content %}
<div class="container">

<section class="section error-404 min-vh-100 d-flex flex-column align-items-center justify-content-center">
<h1>400</h1>
<h2>Sorry, the request could not be understood by the server due to malformed syntax.</h2>
<a class="btn" href="{% url 'signals' %}">Back to home</a>
</section>

</div>
{% endblock %}

13 changes: 13 additions & 0 deletions src/templates/http_errors/403.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{% extends "http_errors/error.html" %}
{% load static %}
{% load i18n %}

{% block content %}
<div class="container">
<section class="section error-404 min-vh-100 d-flex flex-column align-items-center justify-content-center">
<h1>403</h1>
<h2>You don't have permission to access this resource.</h2>
<a class="btn" href="{% url 'signals' %}">Back to home</a>
</section>
</div>
{% endblock %}
15 changes: 15 additions & 0 deletions src/templates/http_errors/404.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{% extends "http_errors/error.html" %}

{% load static %}

{% load i18n %}

{% block content %}
<div class="container">
<section class="section error-404 min-vh-100 d-flex flex-column align-items-center justify-content-center">
<h1>404</h1>
<h2>Not Found</h2>
<a class="btn" href="{% url 'signals' %}">Back to home</a>
</section>
</div>
{% endblock %}
13 changes: 13 additions & 0 deletions src/templates/http_errors/500.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{% extends "http_errors/error.html" %}
{% load static %}
{% load i18n %}

{% block content %}
<div class="container">
<section class="section error-404 min-vh-100 d-flex flex-column align-items-center justify-content-center">
<h1>500</h1>
<h2>Internal Server Error.</h2>
<a class="btn" href="{% url 'signals' %}">Back to home</a>
</section>
</div>
{% endblock %}
56 changes: 56 additions & 0 deletions src/templates/http_errors/error.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{% load static %} {% load i18n %}

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta content="width=device-width, initial-scale=1.0" name="viewport" />

<title>Error</title>
<meta content="" name="description" />
<meta content="" name="keywords" />

<link href="{% static 'img/DELPHI-favicon.svg' %}" rel="icon" />
<link
href="{% static 'img/apple-touch-icon.png' %}"
rel="apple-touch-icon"
/>

<link rel="stylesheet" href="{% static 'css/style.css' %}" />

<!-- Font Awesome -->
<link
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css"
rel="stylesheet"
/>
<!-- Google Fonts -->
<link
href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap"
rel="stylesheet"
/>
<!-- MDB -->
<link
href="https://cdnjs.cloudflare.com/ajax/libs/mdb-ui-kit/7.3.2/mdb.min.css"
rel="stylesheet"
/>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
</head>

<body>
<main>

{% block content %}

{% endblock %}
</main>
<!-- End #main -->

<!-- MDB -->
<script
type="text/javascript"
src="https://cdnjs.cloudflare.com/ajax/libs/mdb-ui-kit/7.3.2/mdb.umd.min.js"
></script>

</body>
</html>
Loading