Skip to content

Commit

Permalink
Update project dependencies (#361)
Browse files Browse the repository at this point in the history
* Update project dependencies. Upgrade Dockerfile to use a supported version of python.

* empty! Trigger CircleCI run

* update ci python image

* Remove `chown` command from CI config

* Remove `pipenv` installation from CI config

* Update config.yml

* Update common.py

Change static files storage

---------

Co-authored-by: Pedro Janeiro <[email protected]>
Co-authored-by: Diogo Ribeiro <[email protected]>
  • Loading branch information
3 people authored Apr 24, 2023
1 parent 1344dfc commit e629d9f
Show file tree
Hide file tree
Showing 16 changed files with 449 additions and 189 deletions.
35 changes: 3 additions & 32 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ jobs:
build:
working_directory: ~/hawkpost
docker:
- image: circleci/python:3.6.4
- image: cimg/python:3.9.16
environment:
PIPENV_VENV_IN_PROJECT: true
DB_HOST: localhost
Expand All @@ -15,44 +15,15 @@ jobs:
POSTGRES_DB: hawkpost_dev
steps:
- checkout
- run: sudo chown -R circleci:circleci /usr/local/bin
- run: sudo chown -R circleci:circleci /usr/local/lib/python3.6/site-packages
- restore_cache:
key: deps9-{{ .Branch }}-{{ checksum "Pipfile.lock" }}
- run:
command: |
sudo pip install pipenv
pipenv install --dev
- save_cache:
key: deps9-{{ .Branch }}-{{ checksum "Pipfile.lock" }}
paths:
- ".venv"
- "/usr/local/bin"
- "/usr/local/lib/python3.6/site-packages"
- run:
command: |
set +e
touch $BASH_ENV
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.37.2/install.sh | bash
echo 'export NVM_DIR="$HOME/.nvm"' >> $BASH_ENV
echo '[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"' >> $BASH_ENV
echo 'nvm install v14.16.0' >> $BASH_ENV
echo 'nvm alias default v14.16.0' >> $BASH_ENV
pipenv run python manage.py collectstatic --no-input
- run:
command: |
npm install gulp-cli -g
- run:
command: |
npm install
- run:
command: |
gulp build
- run:
command: |
pipenv run "python manage.py collectstatic --no-input"
- run:
command: |
pipenv run "python manage.py test"
pipenv run python manage.py test
- store_test_results:
path: test-results
- store_artifacts:
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.6
FROM python:3.9

ENV HOME /home/user
RUN useradd --create-home --home-dir $HOME user \
Expand Down
21 changes: 10 additions & 11 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,22 @@ verify_ssl = true
name = "pypi"

[dev-packages]
django-debug-toolbar = "==1.11.1"
django-extensions = "*"
django-debug-toolbar = "==3.8.1"
django-extensions = "==3.2.1"

[packages]
django-dotenv = "==1.4.2"
"psycopg2" = "==2.7.3.2"
django-allauth = "==0.42.0"
"psycopg2-binary" = "==2.9.5"
django-allauth = "==0.47.0"
gnupg = "==2.3.1"
whitenoise = "==5.3.0"
celery = "==4.1.1"
redis = "==3.2.0"
gunicorn = "==19.7.1"
gunicorn = "==20.1.0"
raven = "==6.4.0"
django-timezone-field = "==4.2.3"
django-braces = "==1.11.0"
django-axes = "==5.27.0"
Django = "==2.2.26"
django-braces = "==1.15.0"
django-axes = "==5.40.1"
Django = "==3.2.18"
celery = {version = "==5.2.7", extras = ["redis"]}

[requires]
python_version = "3.6"
python_version = "3.9"
537 changes: 409 additions & 128 deletions Pipfile.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion boxes/templates/boxes/box_list.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% extends "layout/base.html" %}
{% load i18n %}
{% load staticfiles %}
{% load static %}

{% block content %}
<div class="section-definer-grey">
Expand Down
2 changes: 1 addition & 1 deletion boxes/templates/boxes/box_submit.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% extends "layout/base.html" %}
{% load i18n %}
{% load staticfiles %}
{% load static %}

{% block header %}
{% include "layout/messages.html" %}
Expand Down
2 changes: 1 addition & 1 deletion boxes/templates/boxes/success.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% extends "layout/base.html" %}
{% load i18n %}
{% load staticfiles %}
{% load static %}

{% block header %}
{% include "layout/messages.html" %}
Expand Down
14 changes: 13 additions & 1 deletion hawkpost/settings/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"""
from django.urls import reverse_lazy
from django.utils.translation import ugettext_lazy as _
from celery.schedules import crontab
import os

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
Expand Down Expand Up @@ -47,6 +48,7 @@
'boxes',
'pages',
]
DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'

MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
Expand Down Expand Up @@ -148,7 +150,7 @@

STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')

STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
STATICFILES_STORAGE = 'whitenoise.storage.CompressedStaticFilesStorage'

# Media Files

Expand Down Expand Up @@ -191,6 +193,16 @@

# Celerey Settings
CELERY_BROKER_URL = os.environ.get("REDIS_URL", "redis://localhost:6379/0")
CELERY_BEAT_SCHEDULE = {
"update_public_keys": {
"task": "humans.tasks.update_public_keys",
"schedule": crontab(minute=0, hour=4), # Every day at 4 AM UTC
},
"validate_public_keys": {
"task": "humans.tasks.validate_public_keys",
"schedule": crontab(minute=30, hour=5), # Every day at 5:30 AM UTC
}
}

# SITE DOMAIN
SITE_DOMAIN = os.environ.get("SITE_DOMAIN")
Expand Down
2 changes: 1 addition & 1 deletion hawkpost/templates/account/auth_modals.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% load i18n %}
{% load account socialaccount %}
{% load staticfiles %}
{% load static %}

<div class="md-modal-xs md-effect-1 " id="modal-login">
<div class="md-content-xs ">
Expand Down
2 changes: 1 addition & 1 deletion hawkpost/templates/layout/base.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% load i18n %}
{% load staticfiles %}
{% load static %}

<!DOCTYPE html>
<html>
Expand Down
2 changes: 1 addition & 1 deletion hawkpost/templates/layout/navbar.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% load i18n %}
{% load staticfiles %}
{% load static %}

<div class="nav-big smalltext">
<nav class="navbar">
Expand Down
2 changes: 1 addition & 1 deletion humans/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@


class AuthConfig(AppConfig):
name = 'auth'
name = 'humans'
9 changes: 3 additions & 6 deletions humans/tasks.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from celery.task.schedules import crontab
from celery.decorators import periodic_task
from celery import shared_task
from celery.utils.log import get_task_logger
from django.core.mail import EmailMultiAlternatives
Expand Down Expand Up @@ -31,8 +29,7 @@ def send_email(user, subject, template):
email.send()


# Every day at 4 AM UTC
@periodic_task(run_every=(crontab(minute=0, hour=4)), ignore_result=True)
@shared_task(ignore_result=True)
def update_public_keys():
users = User.objects.exclude(
Q(keyserver_url__isnull=True) | Q(keyserver_url__exact=''))
Expand Down Expand Up @@ -76,8 +73,8 @@ def update_public_keys():

logger.info(_('Finished Updating user keys'))

# Every day at 5h30 AM UTC
@periodic_task(run_every=(crontab(minute=30, hour=5)), ignore_result=True)

@shared_task(ignore_result=True)
def validate_public_keys():
users = User.objects.exclude(
Q(public_key__isnull=True) | Q(public_key__exact=''))
Expand Down
2 changes: 1 addition & 1 deletion humans/templates/humans/update_user_form.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% extends "layout/base.html" %}
{% load staticfiles %}
{% load static %}
{% load i18n %}

{% block content %}
Expand Down
2 changes: 1 addition & 1 deletion pages/templates/pages/help.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% extends "layout/base.html" %}
{% load i18n %}
{% load staticfiles %}
{% load static %}

{% block content %}
<div class="section-definer-dark">
Expand Down
2 changes: 1 addition & 1 deletion pages/templates/pages/index.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% extends "layout/base.html" %}
{% load i18n %}
{% load staticfiles %}
{% load static %}
{% block content %}

<div class="section-definer-dark">
Expand Down

0 comments on commit e629d9f

Please sign in to comment.