Skip to content

[work in progress] updating to django 3.1+ #84

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

Open
wants to merge 12 commits into
base: master
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
2 changes: 1 addition & 1 deletion .python-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.6.7
3.9.2
10 changes: 6 additions & 4 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@ url = "https://pypi.org/simple"
verify_ssl = true

[dev-packages]
ipython = "*"
ipdb = "*"

[packages]
django = "==1.11.28"
gitberg = "==0.7.2"
django = ">=3.1.4"
gitberg = ">=0.7.4"
sorl-thumbnail = "*"
django-extensions = "*"
django-zurb-foundation = "*"
django-fontawesome = "*"
django-fontawesome-5 = "*"
django-storages = "*"
django-el-pagination = "*"
django-debug-toolbar = "*"
Expand All @@ -24,4 +26,4 @@ boto3 = "*"
appdirs = "==1.4.3"

[requires]
python_version = "3.6"
python_version = "3.9"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ebcli uses some config magic that's not clear to me, but the install platform default is py3.7 - look in .elasticbeanstalk/config.yml

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

anything 3.6+ will let me use f-strings, so that should work

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the elastic beanstalk config, the base image we're using is python3.6
image

So I'll revert this back to 3.6 and make sure the site works with 3.6-3.9

750 changes: 454 additions & 296 deletions Pipfile.lock

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions README.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,14 @@ Virtual environments in python are a way of separating and reproducing the pytho

From the root of the project

pipenv install -r requirements.txt
pipenv install

For every new terminal, or when returning to work on the project, you will need to run

source venv/bin/activate
pipenv shell

==== Linux
You need the debian packages `libxml2-dev libxslt1-dev libjpeg9-dev libpq-dev` to install the python requirements.


=== Database(s)
Expand Down
2 changes: 1 addition & 1 deletion gitensite/apps/content/templates/book_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

{% block body_content %}
{% block body_js %}
{% load staticfiles %}
{% load static %}
{{ block.super }}
<script src="{% static "foundation/js/vendor/jquery.js" %}"></script>
<script src="{% static "el-pagination/js/el-pagination.js" %}"></script>
Expand Down
4 changes: 2 additions & 2 deletions gitensite/apps/content/templates/book_list_page.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% load el_pagination_tags %}
{% load staticfiles %}
{% load static %}

{% lazy_paginate object_list %}

Expand Down Expand Up @@ -34,4 +34,4 @@ <h5 class="booktitle" style="font-weight: bold;"><a href="{% url 'book' book.boo
</div>
<hr />
{% endfor %}
{% show_more %}
{% show_more %}
2 changes: 1 addition & 1 deletion gitensite/apps/content/templates/browsebooks.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% extends 'frame.html' %} {% load fontawesome %} {% load staticfiles %} {% block title %} GITenberg - Making beautiful books in the public domain {% endblock title %} {% block body_content %}
{% extends 'frame.html' %} {% load fontawesome_5 %} {% load static %} {% block title %} GITenberg - Making beautiful books in the public domain {% endblock title %} {% block body_content %}

{% include "header.html" %}
<br />
Expand Down
2 changes: 1 addition & 1 deletion gitensite/apps/content/templates/faq.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% extends 'frame.html' %} {% load fontawesome %} {% load staticfiles %} {% block title %} GITenberg - Making beautiful books in the public domain {% endblock title %} {% block body_content %}
{% extends 'frame.html' %} {% load fontawesome_5 %} {% load static %} {% block title %} GITenberg - Making beautiful books in the public domain {% endblock title %} {% block body_content %}
<!-- top panel -->
<div class="row">
<div class="large-offset-2 large-8 small-10 columns">
Expand Down
4 changes: 2 additions & 2 deletions gitensite/apps/content/templates/footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

<div class="large-6 small-12 columns">
<ul class="inline-list right">
<li><a href="https://twitter.com/gitenberg"><i class="fa fa-twitter" style="color: black;"></i> twitter</a></li>
<li><a href="https://twitter.com/gitenberg"><i class="fab fa-twitter" style="color: black;"></i> twitter</a></li>
<li>
<a href="https://github.com/gitenberg-dev"><i class="fa fa-github" style="color: black;"></i> github</a>
<a href="https://github.com/gitenberg-dev"><i class="fab fa-github" style="color: black;"></i> github</a>
</li>
<li><a href="https://groups.google.com/forum/#!forum/gitenberg-project"><i class="fa fa-envelope-o" style="color: black;"></i> mailing list</a></li>
</ul>
Expand Down
53 changes: 53 additions & 0 deletions gitensite/apps/content/templates/foundation_base.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{% load static %}
<!doctype html>
<html class="no-js" lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
{% block meta %}{% endblock meta %}
{% block base_title %}
<title>{% block title %}Foundation 5.5.0{% endblock title %}</title>
{% endblock base_title %}

{# Base Foundation CSS #}
{% block foundation_css %}
<link href="{% static "foundation/css/normalize.css" %}" rel="stylesheet"/>
<link href="{% static "foundation/css/foundation.min.css" %}" rel="stylesheet"/>
{% endblock foundation_css %}

{# Custom CSS #}
{% block css %}{% endblock css %}

{# Override if you need another version of modernizr #}
{% block foundation_modernizer %}
<script src="{% static "foundation/js/vendor/modernizr.js" %}"></script>
{% endblock foundation_modernizer %}

{# Custom head JS #}
{% block head_js %}{% endblock head_js %}
</head>
<body {% block body_attr %}{% endblock body_attr %}>
{# Main content goes here #}
{% block base_body %}{% endblock base_body %}

{# Override if you need another version of jQuery #}
{% block foundation_jquery %}
<script src="{% static "foundation/js/vendor/jquery.js" %}"></script>
{% endblock foundation_jquery %}

{# Foundation JS #}
{% block foundation_js %}
<script src="{% static "foundation/js/foundation.min.js" %}"></script>
{% endblock foundation_js %}

{# Custom JS #}
{% block body_js %}{% endblock body_js %}

{# Init Foundation #}
{% block foundation_js_init %}
<script>
$(document).foundation();
</script>
{% endblock foundation_js_init %}
</body>
</html>
12 changes: 7 additions & 5 deletions gitensite/apps/content/templates/frame.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% extends 'foundation/base.html' %}
{% load fontawesome %}
{% load staticfiles %}
{% extends 'foundation_base.html' %}
{% load fontawesome_5 %}
{% load static %}


{% block meta %}
Expand All @@ -11,9 +11,11 @@

{# Custom CSS #}
{% block css %}
{% fontawesome_stylesheet %}
<link rel="shortcut icon" href="{%static 'favicon.ico' %}" />
<link rel="shortcut icon" href="{% static 'favicon.ico' %}" />
<link href="{% static 'css/site.css'%}" rel="stylesheet"/>
<!-- fontawesome_5_static -->
{% fontawesome_5_static %}
<!-- fontawesome_5_static -->
{% endblock css %}


Expand Down
2 changes: 1 addition & 1 deletion gitensite/apps/content/templates/get-involved.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% extends 'frame.html' %} {% load fontawesome %} {% load staticfiles %} {% block title %} GITenberg - Making beautiful books in the public domain {% endblock title %} {% block body_content %}
{% extends 'frame.html' %} {% load fontawesome_5 %} {% load static %} {% block title %} GITenberg - Making beautiful books in the public domain {% endblock title %} {% block body_content %}

{% include "header.html" %}
<!-- top panel -->
Expand Down
4 changes: 2 additions & 2 deletions gitensite/apps/content/templates/header.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% load staticfiles %}
{% load static %}
<script src="{% static "foundation/js/vendor/jquery.js" %}"></script>
<div class="contain-to-grid">
<nav class="top-bar" data-topbar>
Expand Down Expand Up @@ -49,4 +49,4 @@ <h1>
</form>
</section>
</nav>
</div>
</div>
6 changes: 3 additions & 3 deletions gitensite/apps/content/templates/home.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% extends 'frame.html' %}
{% load fontawesome %}
{% load staticfiles %}
{% load fontawesome_5 %}
{% load static %}
{% load thumbnail %}

{% block title %} GITenberg - Maintaining our Cultural Heritage in eBooks {% endblock title %}
Expand All @@ -23,7 +23,7 @@ <h4>Books</h4>
</div>

<div class="large-1 small-4 columns end icon-box" style="margin-top: 41.8px;">
<i class="fa fa-5x fa-code-fork"></i>
<i class="fa fa-5x fa-code-branch"></i>
<h4>Git</h4>
</div>

Expand Down
4 changes: 2 additions & 2 deletions gitensite/apps/content/templates/license.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% extends 'frame.html' %}
{% load fontawesome %}
{% load staticfiles %}
{% load fontawesome_5 %}
{% load static %}

{% block title %} License -- GITenberg - Making beautiful books in the public domain {% endblock title %}

Expand Down
2 changes: 1 addition & 1 deletion gitensite/apps/content/templates/listing.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% extends 'frame.html' %} {% load fontawesome %} {% load staticfiles %} {% block title %} GITenberg - Making beautiful books in the public domain {% endblock title %} {% block body_content %}
{% extends 'frame.html' %} {% load fontawesome_5 %} {% load static %} {% block title %} GITenberg - Making beautiful books in the public domain {% endblock title %} {% block body_content %}

{% include "header.html" %}
<br />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% load staticfiles %}
{% load static %}
{% load thumbnail %}
<div class="row">
<div class="large-3 column">
Expand Down Expand Up @@ -129,4 +129,4 @@
<h5><a href="https://github.com/sethwoodworth/Twenty-Thousand-Leagues-under-the-Sea_164/releases/tag/v0.0.2">Twenty Thousand Leagues under the Sea</a></h5>
<p>by Verne, Jules</p>
</div>
</div><hr>
</div><hr>
2 changes: 1 addition & 1 deletion gitensite/apps/content/templates/updates.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% extends 'frame.html' %} {% load fontawesome %} {% load staticfiles %} {% block title %} GITenberg - Making beautiful books in the public domain {% endblock title %} {% block body_content %}
{% extends 'frame.html' %} {% load fontawesome_5 %} {% load static %} {% block title %} GITenberg - Making beautiful books in the public domain {% endblock title %} {% block body_content %}

{% include "header.html" %}
<!-- top panel -->
Expand Down
Empty file added gitensite/settings/__init__.py
Empty file.
87 changes: 42 additions & 45 deletions gitensite/settings.py → gitensite/settings/prod.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,20 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#!/usr/bin/env python3
"""
Django settings for gitensite project.

For more information on this file, see
https://docs.djangoproject.com/en/1.7/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.7/ref/settings/
"""
import os
import logging


# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(__file__))

# use environment variable to set DJANGO_SECRET_KEY
SECRET_KEY = os.environ['DJANGO_SECRET_KEY']
SECRET_KEY = os.environ.get('DJANGO_SECRET_KEY', 'asdf')

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = bool(os.environ.get('DJANGO_DEBUG',False))

DEBUG = bool(os.environ.get('DJANGO_DEBUG', False))
from sorl.thumbnail.log import ThumbnailLogHandler

# Application definition
COMMON_APPS = [
Expand All @@ -29,10 +24,9 @@
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',

'django_extensions',
'foundation',
'fontawesome',
'fontawesome_5',
'storages',
'sorl.thumbnail',
'el_pagination',
Expand Down Expand Up @@ -98,8 +92,8 @@
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'gitensite',
'USER': 'postgres',
'PASSWORD': 'gitensite',
'USER': 'seth',
'PASSWORD': 'asdf',
'HOST': 'localhost',
'PORT': '5432',
}
Expand All @@ -114,37 +108,41 @@
USE_TZ = True


AWS_S3_OBJECT_PARAMETERS = { # see http://developer.yahoo.com/performance/rules.html#expires
'Expires': 'Thu, 31 Dec 2099 20:00:00 GMT',
'CacheControl': 'max-age=94608000',
}
AWS_STORAGE_BUCKET_NAME = 'gitensite'
AWS_ACCESS_KEY_ID = 'AKIAIDP7I26XHV4SCSLA'
# use environment variable to set AWS_SECRET_ACCESS_KEY
AWS_SECRET_ACCESS_KEY = os.environ['AWS_SECRET_ACCESS_KEY']
if not DEBUG:
AWS_S3_OBJECT_PARAMETERS = { # see http://developer.yahoo.com/performance/rules.html#expires
'Expires': 'Thu, 31 Dec 2099 20:00:00 GMT',
'CacheControl': 'max-age=94608000',
}
AWS_STORAGE_BUCKET_NAME = 'gitensite'
# TODO: make secret
AWS_ACCESS_KEY_ID = 'AKIAIDP7I26XHV4SCSLA'
# use environment variable to set AWS_SECRET_ACCESS_KEY
AWS_SECRET_ACCESS_KEY = os.environ.get('AWS_SECRET_ACCESS_KEY')

# Tell django-storages that when coming up with the URL for an item in S3 storage, keep
# it simple - just use this domain plus the path. (If this isn't set, things get complicated).
# This controls how the `static` template tag from `staticfiles` gets expanded, if you're using it.
# We also use it in the next setting.
AWS_S3_CUSTOM_DOMAIN = '%s.s3.amazonaws.com' % AWS_STORAGE_BUCKET_NAME

# inherit the bucket's ACL
AWS_DEFAULT_ACL = None

# Tell django-storages that when coming up with the URL for an item in S3 storage, keep
# it simple - just use this domain plus the path. (If this isn't set, things get complicated).
# This controls how the `static` template tag from `staticfiles` gets expanded, if you're using it.
# We also use it in the next setting.
AWS_S3_CUSTOM_DOMAIN = '%s.s3.amazonaws.com' % AWS_STORAGE_BUCKET_NAME
# This is used by the `static` template tag from `static`, if you're using that. Or if anything else
# refers directly to STATIC_URL. So it's safest to always set it.
STATIC_URL = f"https://{AWS_S3_CUSTOM_DOMAIN}" if not DEBUG else "/static/"

# inherit the bucket's ACL
AWS_DEFAULT_ACL = None
# Tell the staticfiles app to use S3Boto storage when writing the collected static files (when
# you run `collectstatic`).
STATICFILES_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage'
DEFAULT_FILE_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage'

# This is used by the `static` template tag from `static`, if you're using that. Or if anything else
# refers directly to STATIC_URL. So it's safest to always set it.
STATIC_URL = "https://%s/" % AWS_S3_CUSTOM_DOMAIN
if DEBUG:
STATIC_URL = "/static/"
print(STATIC_URL)

# Tell the staticfiles app to use S3Boto storage when writing the collected static files (when
# you run `collectstatic`).
STATICFILES_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage'
DEFAULT_FILE_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage'


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.8/howto/static-files/
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, "static")
STATICFILES_DIRS = (
os.path.join(BASE_DIR, "assets"),
Expand All @@ -154,8 +152,6 @@

# The in-development settings and the default configuration.
if 'ENVIRONMENT' in os.environ and os.environ['ENVIRONMENT'] == 'DEVELOPMENT':
DEBUG = True

ALLOWED_HOSTS = []

INSTALLED_APPS = COMMON_APPS + LOCAL_APPS + [
Expand Down Expand Up @@ -222,14 +218,15 @@
}
},
}
#MEDIA_URL = '/static/media/'

MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, "upload/media")

import logging
from sorl.thumbnail.log import ThumbnailLogHandler

handler = ThumbnailLogHandler()
handler.setLevel(logging.ERROR)
logging.getLogger('sorl.thumbnail').addHandler(handler)

if DEBUG:
STATIC_URL = '/static/'
MEDIA_URL = '/media/'
Loading