-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(web): first commit of public repos
- Loading branch information
0 parents
commit 8ce36b8
Showing
2,037 changed files
with
3,921 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
venv | ||
*.pyc | ||
staticfiles | ||
.env | ||
db.sqlite3 | ||
snippets.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
web: newrelic-admin run-program gunicorn geographynow.wsgi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
web: python manage.py runserver 0.0.0.0:5000 |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"name": "Python on Heroku example", | ||
"description": "A barebones Python app, which can easily be deployed to Heroku.", | ||
"image": "heroku/python", | ||
"repository": "https://github.com/heroku/python-getting-started", | ||
"keywords": ["python", "django" ], | ||
"addons": [ "heroku-postgresql" ] | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
https://github.com/heroku/heroku-django-template | ||
For more information on this file, see | ||
https://docs.djangoproject.com/en/1.8/topics/settings/ | ||
For the full list of settings and their values, see | ||
https://docs.djangoproject.com/en/1.8/ref/settings/ | ||
""" | ||
|
||
import os | ||
import dj_database_url | ||
|
||
|
||
# Build paths inside the project like this: os.path.join(BASE_DIR, ...) | ||
BASE_DIR = os.path.dirname(os.path.dirname(__file__)) | ||
PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__)) | ||
|
||
|
||
# Quick-start development settings - unsuitable for production | ||
# See https://docs.djangoproject.com/en/1.8/howto/deployment/checklist/ | ||
|
||
# SECURITY WARNING: change this before deploying to production! | ||
SECRET_KEY = 'i+acxn5(akgsn!sr4^qgf(^m&*@+g1@u^t@=8s@axc41ml*f=s' | ||
|
||
# SECURITY WARNING: don't run with debug turned on in production! | ||
DEBUG = False | ||
|
||
|
||
# Application definition | ||
|
||
INSTALLED_APPS = ( | ||
'django.contrib.admin', | ||
'django.contrib.auth', | ||
'django.contrib.contenttypes', | ||
'django.contrib.sessions', | ||
'django_extensions', | ||
'django.contrib.messages', | ||
'django.contrib.staticfiles', | ||
'webmap', | ||
) | ||
|
||
MIDDLEWARE_CLASSES = ( | ||
'django.middleware.cache.UpdateCacheMiddleware', | ||
'django.contrib.sessions.middleware.SessionMiddleware', | ||
'django.middleware.common.CommonMiddleware', | ||
'django.middleware.csrf.CsrfViewMiddleware', | ||
'django.contrib.auth.middleware.SessionAuthenticationMiddleware', | ||
'django.contrib.messages.middleware.MessageMiddleware', | ||
'django.middleware.clickjacking.XFrameOptionsMiddleware', | ||
'django.middleware.security.SecurityMiddleware', | ||
'django.middleware.cache.FetchFromCacheMiddleware', | ||
) | ||
|
||
ROOT_URLCONF = 'geographynow.urls' | ||
|
||
CACHES = { | ||
'default': { | ||
'BACKEND': 'django.core.cache.backends.locmem.LocMemCache', | ||
} | ||
} | ||
|
||
TEMPLATES = [ | ||
{ | ||
'BACKEND': 'django.template.backends.django.DjangoTemplates', | ||
'DIRS': [], | ||
'APP_DIRS': True, | ||
'OPTIONS': { | ||
'debug': True, | ||
'context_processors': [ | ||
'django.template.context_processors.debug', | ||
'django.template.context_processors.request', | ||
'django.contrib.auth.context_processors.auth', | ||
'django.contrib.messages.context_processors.messages', | ||
], | ||
}, | ||
}, | ||
] | ||
|
||
WSGI_APPLICATION = 'geographynow.wsgi.application' | ||
|
||
|
||
# Database | ||
# https://docs.djangoproject.com/en/1.9/ref/settings/#databases | ||
|
||
DATABASES = { | ||
'default': { | ||
'ENGINE': 'django.db.backends.sqlite3', | ||
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), | ||
'CONN_MAX_AGE': 600, | ||
} | ||
} | ||
|
||
# Internationalization | ||
# https://docs.djangoproject.com/en/1.8/topics/i18n/ | ||
|
||
LANGUAGE_CODE = 'en-us' | ||
TIME_ZONE = 'UTC' | ||
USE_I18N = True | ||
USE_L10N = True | ||
USE_TZ = True | ||
|
||
# webmap settings | ||
GEOGRAPHY_NOW_CHANNEL = 'UCmmPgObSUPw1HL2lq6H4ffA' | ||
FLAG_FRIDAY_PLAYLIST = "PLR7XO54Pktt-YwmKtu2BLBS7jtVKRP94x" | ||
GEO_PLAYLIST = "PLR7XO54Pktt8_jNjAVaunw1EqqcEAdcow" | ||
|
||
YOUTUBE_API_SERVICE_NAME = "youtube" | ||
YOUTUBE_API_VERSION = "v3" | ||
|
||
# required for youtube API | ||
YOUTUBE_DEVELOPER_KEY = "" | ||
|
||
# set hooks for alarms (optional) | ||
SLACK_URL = "" | ||
|
||
# Update database configuration with $DATABASE_URL. | ||
db_from_env = dj_database_url.config() | ||
DATABASES['default'].update(db_from_env) | ||
|
||
# Honor the 'X-Forwarded-Proto' header for request.is_secure() | ||
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https') | ||
|
||
# Allow all host headers | ||
ALLOWED_HOSTS = ['*'] | ||
|
||
# Static files (CSS, JavaScript, Images) | ||
# https://docs.djangoproject.com/en/1.8/howto/static-files/ | ||
|
||
STATIC_ROOT = os.path.join(PROJECT_ROOT, 'staticfiles') | ||
STATIC_URL = '/static/' | ||
|
||
# Extra places for collectstatic to find static files. | ||
STATICFILES_DIRS = ( | ||
os.path.join(PROJECT_ROOT, 'static'), | ||
) | ||
|
||
# Simplified static file serving. | ||
# https://warehouse.python.org/project/whitenoise/ | ||
STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage' | ||
#STATICFILES_STORAGE = 'django.contrib.staticfiles.storage.CachedStaticFilesStorage' |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from django.conf.urls import patterns, include, url | ||
|
||
from django.contrib import admin | ||
admin.autodiscover() | ||
|
||
import webmap.views | ||
|
||
urlpatterns = [ | ||
url(r'', webmap.views.index, name='index'), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
""" | ||
WSGI config for geographynow project. | ||
It exposes the WSGI callable as a module-level variable named ``application``. | ||
For more information on this file, see | ||
https://docs.djangoproject.com/en/1.6/howto/deployment/wsgi/ | ||
""" | ||
|
||
import os | ||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "geographynow.settings") | ||
|
||
from django.core.wsgi import get_wsgi_application | ||
from whitenoise.django import DjangoWhiteNoise | ||
|
||
application = DjangoWhiteNoise(get_wsgi_application()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/usr/bin/env python | ||
import os | ||
import sys | ||
|
||
if __name__ == "__main__": | ||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "geographynow.settings") | ||
|
||
from django.core.management import execute_from_command_line | ||
|
||
execute_from_command_line(sys.argv) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
dj-database-url==0.4.0 | ||
Django==1.9.2 | ||
gunicorn==19.4.5 | ||
psycopg2==2.6.1 | ||
whitenoise==2.0.6 | ||
requests | ||
django-extensions | ||
google-api-python-client | ||
pycountry | ||
arrow | ||
newrelic |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
python-2.7.11 |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from functools import wraps | ||
|
||
|
||
def memoize(function): | ||
memo = {} | ||
|
||
@wraps(function) | ||
def wrapper(*args): | ||
if args in memo: | ||
return memo[args] | ||
else: | ||
rv = function(*args) | ||
memo[args] = rv | ||
return rv | ||
return wrapper |
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from django.core.management.base import BaseCommand | ||
from webmap.pipeline import update_country_info | ||
|
||
|
||
class Command(BaseCommand): | ||
help = 'Pull and Process Geography youtube video info' | ||
|
||
def handle(self, *args, **options): | ||
update_country_info() | ||
self.stdout.write(self.style.SUCCESS('Successfully info updated')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# -*- coding: utf-8 -*- | ||
# Generated by Django 1.9.2 on 2017-01-31 19:44 | ||
from __future__ import unicode_literals | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
initial = True | ||
|
||
dependencies = [ | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='Country', | ||
fields=[ | ||
('updated_at', models.DateTimeField(auto_now=True)), | ||
('created_at', models.DateTimeField(auto_now_add=True)), | ||
('code', models.CharField(max_length=3, primary_key=True, serialize=False)), | ||
('name', models.CharField(max_length=100)), | ||
('geo_video_url', models.URLField()), | ||
('flag_friday_video_url', models.URLField()), | ||
], | ||
options={ | ||
'abstract': False, | ||
}, | ||
), | ||
] |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
from __future__ import unicode_literals | ||
|
||
from django.db import models | ||
import arrow | ||
|
||
|
||
class BaseModel(models.Model): | ||
updated_at = models.DateTimeField(auto_now=True) | ||
created_at = models.DateTimeField(auto_now_add=True) | ||
|
||
class Meta: | ||
abstract = True | ||
|
||
|
||
class Country(BaseModel): | ||
code = models.CharField(max_length=3, primary_key=True) | ||
name = models.CharField(max_length=100) | ||
geo_video_url = models.URLField() | ||
flag_friday_video_url = models.URLField() | ||
|
||
def __str__(self): | ||
return self.code.upper() | ||
|
||
@classmethod | ||
def get_latest_video_info(cls): | ||
latest_country = Country.objects.all().latest('created_at') | ||
video_type = 'country video' | ||
video_added_at = latest_country.created_at | ||
if latest_country.flag_friday_video_url: | ||
video_type = 'flag fridays video' | ||
video_added_at = latest_country.updated_at | ||
return { | ||
'country': latest_country.name, | ||
'video_type': video_type, | ||
'video_added_at_humanized': arrow.get(video_added_at).humanize() | ||
} |
Oops, something went wrong.