Skip to content

Commit

Permalink
Various deployment fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
gthole committed Jan 21, 2018
1 parent df2d635 commit 4f6d7a3
Show file tree
Hide file tree
Showing 19 changed files with 98 additions and 40 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ settings_local.py
*.ged
/tmp
/files
/data
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ pip-log.txt
*d3.*.js

/files/
/data/
*.ged
docker-compose-prd.yml
settings_local.py
/tmp
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ FROM python:2.7
COPY ./ /app/

WORKDIR /app/
RUN pip install -r reqs.pip
RUN pip install -r reqs.frozen.pip
RUN mkdir -p /static && python manage.py collectstatic -c --noinput

RUN adduser --disabled-password --gecos '' gedgo
RUN chown -R gedgo:gedgo /app
Expand Down
7 changes: 5 additions & 2 deletions gedgo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@

redis = None
if hasattr(settings, 'GEDGO_REDIS_SERVER'):
redis = Redis.StrictRedis(host=settings.GEDGO_REDIS_SERVER)
redis.ping()
try:
redis = Redis.StrictRedis(host=settings.GEDGO_REDIS_SERVER)
redis.ping()
except Exception as e:
print e
2 changes: 1 addition & 1 deletion gedgo/gedcom_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def update(g, file_name, verbose=True):
__process_Note(entry, g)
note_counter += 1

if (index + 1) % 100 == 0:
if verbose and (index + 1) % 100 == 0:
print ' ... %d / %d' % (index + 1, len(entries))

if verbose:
Expand Down
2 changes: 1 addition & 1 deletion gedgo/migrations/0002_auto_20180120_1030.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ class Migration(migrations.Migration):
migrations.AlterField(
model_name='document',
name='docfile',
field=models.FileField(upload_to=b'gedcom'),
field=models.FileField(upload_to=b'uploads'),
),
]
2 changes: 1 addition & 1 deletion gedgo/models/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Meta:

title = models.CharField(max_length=40, null=True, blank=True)
description = models.TextField(null=True, blank=True)
docfile = models.FileField(upload_to='gedcom')
docfile = models.FileField(upload_to='uploads')
last_updated = models.DateTimeField(auto_now_add=True)
gedcom = models.ForeignKey('Gedcom', null=True, blank=True)

Expand Down
10 changes: 6 additions & 4 deletions gedgo/static/styles/style-default.css
Original file line number Diff line number Diff line change
Expand Up @@ -120,15 +120,17 @@ path {
}

#worker-section {
min-height: 75px;

min-height: 150px;
}

#worker-section p {
margin-top: 5px;
}

#worker-status {
#worker-status-icon {
display: block;
margin-left: auto;
margin-right: auto;
width: 80px;
font-size: 40px;
color: #fff;
Expand All @@ -138,6 +140,6 @@ path {
border-radius: 10px; /* future proofing */
}

#worker-status span {
#worker-status-icon span {
margin-top: 10px;
}
4 changes: 3 additions & 1 deletion gedgo/storages.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,11 @@ def resize_thumb(file_, size='w128h128', crop=None):
im.save(output, 'JPEG')
return output


research_storage = import_string(settings.GEDGO_RESEARCH_FILE_STORAGE)(
location=settings.GEDGO_RESEARCH_FILE_ROOT)

gedcom_storage = import_string(settings.GEDGO_GEDCOM_FILE_STORAGE)(
location=settings.GEDGO_GEDCOM_FILE_ROOT)

documentary_storage = import_string(settings.GEDGO_DOCUMENTARY_STORAGE)(
location=settings.GEDGO_DOCUMENTARY_ROOT)
2 changes: 1 addition & 1 deletion gedgo/templates/default/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.0/css/bootstrap.min.css" rel="stylesheet">
<link href="//opensource.keycdn.com/fontawesome/4.6.3/font-awesome.min.css" rel="stylesheet">
<link href="{{ STATIC_URL }}styles/style-default.css" rel="stylesheet" type="text/css" >
<link href="{{ STATIC_URL }}styles/style-default.css?v=2" rel="stylesheet" type="text/css" >
{% block headappend %}{% endblock %}
</head>
<body>
Expand Down
31 changes: 17 additions & 14 deletions gedgo/templates/default/blogpost.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,17 @@
{% endblock %}

{% block leftsidebar %}
{% if post.tagged_photos.all %}
{% for photo in post.tagged_photos.all %}
<a href="{{ photo.docfile.url }}">
<img src="{{ photo.thumb.thumb }}" class="thumb sidebar-lead img-rounded">
</a>
{% endfor %}
{% endif %}
<p>Posted: {{ post.created }}</p>
<p><a href="/gedgo/blog/"><i class="fa fa-angle-double-left"></i> Back to the post list</a></p>

{% if post.tagged_photos.exists %}
<hr/>
{% for photo in post.tagged_photos.all %}
<a href="{{ photo.docfile.url }}">
<img src="{{ photo.docfile.url }}" class="thumb sidebar-lead img-rounded">
</a>
{% endfor %}
{% endif %}
{% endblock %}

{% block content %}
Expand All @@ -21,18 +25,17 @@ <h1>{{ post.title }}</h1>
<a href="/admin/gedgo/blogpost/{{ post.id }}/"><span class="glyphicon glyphicon-pencil"></span> Edit this post</a>
{% endif %}

<div class="section">
Posted: {{ post.created }}<br>
<a href="/gedgo/blog/">Back to the post list</a>
</div>

{% if post.tagged_people.all %}
{% if post.tagged_people.exists %}
<div class="section">
<h3>People in this post:</h3>
<div class="row">
{% for somebody in post.tagged_people.all %}
<div class="col-sm-6">
{% include "person-card.html" %}
{% if forloop.last %}{% else %}<hr>{% endif %}
</div>
{% endfor %}
</div>
<hr />
</div>
{% endif %}

Expand Down
11 changes: 6 additions & 5 deletions gedgo/templates/default/dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
{% block leftsidebar %}
<div id="worker-section">
<h2>Worker Status</h2>
<div id="worker-status">
<div id="worker-status"></div>
<div id="worker-status-icon" class="text-centered center-text">
<span></span>
</div>
</div>
Expand Down Expand Up @@ -80,17 +81,17 @@ <h3>User Activity</h3>
$('.email_users_checkbox').prop('checked', this.checked);
});
$.getJSON('worker/status', function(res) {
var el = $('#worker-status');
var st = $('#worker-status span');
var el = $('#worker-status-icon');
var st = $('#worker-status-icon span');
if (res.length) {
el.addClass('bg-success');
st.addClass('glyphicon glyphicon-ok');
$('#submit-gedcom').removeClass("disabled");
$('#worker-section').append("<p>Worker is currently availabe to process gedcoms!</p>");
$('#worker-status').html("<p>Worker is currently availabe to process gedcoms!</p>");
} else {
el.addClass('bg-danger');
st.addClass('glyphicon glyphicon-remove');
$('#worker-section').append("<p>Worker is currently offline, so gedcom uploads cannot be processed.</p>");
$('#worker-status').html("<p>Worker is currently offline, so gedcom uploads cannot be processed.</p>");
}
});
</script>
Expand Down
8 changes: 5 additions & 3 deletions gedgo/templates/default/documentary_by_id.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,19 @@
<h4>{{ documentary.title }}</h4>
<p>{{ documentary.description }}</p>
<br/>
<p><a href="/gedgo/documentaries">&lt;&lt; back to documentaries</a></p>
<p><a href="/gedgo/media/documentary/{{ documentary.location | urlencode }}"><i class="fa fa-download"></i> Download</a></p>
<br/>
<p><a href="/gedgo/documentaries"><i class="fa fa-angle-double-left"></i> Back to documentaries</a></p>
{% endblock %}


{% block content %}
{% if can_video %}
<video style="width: 100%" src="/gedgo/media/research/{{ documentary.location | urlencode }}" type="video/mp4" controls></video>
<video style="width: 100%" src="/gedgo/media/documentary/{{ documentary.location | urlencode }}" type="video/mp4" controls></video>
{% else %}
<br/>
<div class="center-block text-center">
<a href="/gedgo/media/research/{{ documentary.location | urlencode }}">
<a href="/gedgo/media/documentary/{{ documentary.location | urlencode }}">
<i class="fa fa-{{ file.type }} fa-2x"></i>
</a>
<br/>
Expand Down
2 changes: 1 addition & 1 deletion gedgo/views/dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def user_tracking(request, user_id):

def _handle_upload(request, form):
if form.is_valid():
file_name = 'uploaded/gedcoms/%d_%s' % (
file_name = 'uploads/gedcoms/%d_%s' % (
time.time(), form.cleaned_data['gedcom_file'].name)
default_storage.save(file_name, form.cleaned_data['gedcom_file'])
async_update.delay(
Expand Down
4 changes: 2 additions & 2 deletions gedgo/views/media.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@
from django.shortcuts import redirect

from gedgo.views.research import can_preview
from gedgo.storages import gedcom_storage, research_storage
from gedgo.storages import gedcom_storage, research_storage, documentary_storage

import mimetypes
from os import path
import sys
sys.stdout = sys.stderr



STORAGES = {
'documentary': documentary_storage,
'default': default_storage,
'research': research_storage,
'gedcom': gedcom_storage
Expand Down
31 changes: 31 additions & 0 deletions reqs.frozen.pip
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
amqp==2.2.2
anyjson==0.3.3
billiard==3.5.0.3
celery==4.1.0
certifi==2018.1.18
chardet==3.0.4
configparser==3.5.0
dj-static==0.0.6
Django==1.9.2
dropbox==8.6.0
enum34==1.1.6
flake8==3.5.0
funcsigs==1.0.2
gunicorn==19.7.1
idna==2.6
kombu==4.1.0
mccabe==0.6.1
mock==2.0.0
MySQL-python==1.2.5
pbr==3.1.1
Pillow==3.1.1
pycodestyle==2.3.1
pyflakes==1.6.0
pytz==2017.3
redis==2.10.6
requests==2.18.4
six==1.11.0
static3==0.7.0
urllib3==1.22
vine==1.1.4
virtualenv==15.1.0
2 changes: 2 additions & 0 deletions reqs.pip
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
django==1.9.2
celery==4.1.0
pillow==3.1.1
dj-static==0.0.6
gunicorn
anyjson
dropbox
mysql-python
Expand Down
7 changes: 4 additions & 3 deletions settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
MEDIA_ROOT = '/app/files/default/'
MEDIA_URL = '/gedgo/media/default/'

STATIC_ROOT = ''
STATIC_ROOT = '/static/'
STATIC_URL = '/static/'

STATICFILES_FINDERS = (
Expand Down Expand Up @@ -78,8 +78,7 @@
)

ROOT_URLCONF = 'urls'
# WSGI_APPLICATION = 'wsgi.application'

WSGI_APPLICATION = 'wsgi.application'

INSTALLED_APPS = (
'django.contrib.auth',
Expand Down Expand Up @@ -116,6 +115,8 @@
GEDGO_REDIS_SERVER = 'redis'
GEDGO_RESEARCH_FILE_STORAGE = 'gedgo.storages.FileSystemSearchableStorage'
GEDGO_RESEARCH_FILE_ROOT = '/app/files/gedcom/'
GEDGO_DOCUMENTARY_STORAGE = 'gedgo.storages.FileSystemSearchableStorage'
GEDGO_DOCUMENTARY_ROOT = '/app/files/documentaries/'
GEDGO_GEDCOM_FILE_STORAGE = 'gedgo.storages.FileSystemSearchableStorage'
GEDGO_GEDCOM_FILE_ROOT = '/app/files/research/'
GEDGO_SHOW_RESEARCH_FILES = True
Expand Down
7 changes: 7 additions & 0 deletions wsgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import os
from django.core.wsgi import get_wsgi_application
from dj_static import Cling

os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'

application = Cling(get_wsgi_application())

0 comments on commit 4f6d7a3

Please sign in to comment.