No changes after this point.
parent
e33ddce131
commit
e600bc7085
10
manage.py
10
manage.py
|
@ -1,10 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
import os
|
||||
import sys
|
||||
|
||||
if __name__ == "__main__":
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "papiez_ipsum.settings")
|
||||
|
||||
from django.core.management import execute_from_command_line
|
||||
|
||||
execute_from_command_line(sys.argv)
|
|
@ -1,159 +0,0 @@
|
|||
# Django settings for papiez_ipsum project.
|
||||
|
||||
DEBUG = False
|
||||
TEMPLATE_DEBUG = DEBUG
|
||||
|
||||
ADMINS = (
|
||||
# ('Your Name', 'your_email@example.com'),
|
||||
)
|
||||
|
||||
MANAGERS = ADMINS
|
||||
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
|
||||
'NAME': 'papiez.sqlite', # Or path to database file if using sqlite3.
|
||||
# The following settings are not used with sqlite3:
|
||||
'USER': '',
|
||||
'PASSWORD': '',
|
||||
'HOST': '', # Empty for localhost through domain sockets or '127.0.0.1' for localhost through TCP.
|
||||
'PORT': '', # Set to empty string for default.
|
||||
}
|
||||
}
|
||||
|
||||
# Hosts/domain names that are valid for this site; required if DEBUG is False
|
||||
# See https://docs.djangoproject.com/en/1.5/ref/settings/#allowed-hosts
|
||||
ALLOWED_HOSTS = ["*"]
|
||||
|
||||
# Local time zone for this installation. Choices can be found here:
|
||||
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
|
||||
# although not all choices may be available on all operating systems.
|
||||
# In a Windows environment this must be set to your system time zone.
|
||||
TIME_ZONE = 'America/Chicago'
|
||||
|
||||
# Language code for this installation. All choices can be found here:
|
||||
# http://www.i18nguy.com/unicode/language-identifiers.html
|
||||
LANGUAGE_CODE = 'en-us'
|
||||
|
||||
SITE_ID = 1
|
||||
|
||||
# If you set this to False, Django will make some optimizations so as not
|
||||
# to load the internationalization machinery.
|
||||
USE_I18N = True
|
||||
|
||||
# If you set this to False, Django will not format dates, numbers and
|
||||
# calendars according to the current locale.
|
||||
USE_L10N = True
|
||||
|
||||
# If you set this to False, Django will not use timezone-aware datetimes.
|
||||
USE_TZ = True
|
||||
|
||||
# Absolute filesystem path to the directory that will hold user-uploaded files.
|
||||
# Example: "/var/www/example.com/media/"
|
||||
MEDIA_ROOT = ''
|
||||
|
||||
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
|
||||
# trailing slash.
|
||||
# Examples: "http://example.com/media/", "http://media.example.com/"
|
||||
MEDIA_URL = ''
|
||||
|
||||
# Absolute path to the directory static files should be collected to.
|
||||
# Don't put anything in this directory yourself; store your static files
|
||||
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
|
||||
# Example: "/var/www/example.com/static/"
|
||||
STATIC_ROOT = ''
|
||||
|
||||
# URL prefix for static files.
|
||||
# Example: "http://example.com/static/", "http://static.example.com/"
|
||||
STATIC_URL = '/static/'
|
||||
|
||||
# Additional locations of static files
|
||||
STATICFILES_DIRS = (
|
||||
# Put strings here, like "/home/html/static" or "C:/www/django/static".
|
||||
# Always use forward slashes, even on Windows.
|
||||
# Don't forget to use absolute paths, not relative paths.
|
||||
)
|
||||
|
||||
# List of finder classes that know how to find static files in
|
||||
# various locations.
|
||||
STATICFILES_FINDERS = (
|
||||
'django.contrib.staticfiles.finders.FileSystemFinder',
|
||||
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
|
||||
# 'django.contrib.staticfiles.finders.DefaultStorageFinder',
|
||||
)
|
||||
|
||||
# Make this unique, and don't share it with anybody.
|
||||
SECRET_KEY = '&x1kdqtgx+4m2de&p0v5zfm4)!^@k2wg^ph^a%o$pf-z#*)b$d'
|
||||
|
||||
# List of callables that know how to import templates from various sources.
|
||||
TEMPLATE_LOADERS = (
|
||||
'django.template.loaders.filesystem.Loader',
|
||||
'django.template.loaders.app_directories.Loader',
|
||||
# 'django.template.loaders.eggs.Loader',
|
||||
)
|
||||
|
||||
MIDDLEWARE_CLASSES = (
|
||||
'django.middleware.common.CommonMiddleware',
|
||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||
'django.middleware.csrf.CsrfViewMiddleware',
|
||||
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
||||
'django.contrib.messages.middleware.MessageMiddleware',
|
||||
# Uncomment the next line for simple clickjacking protection:
|
||||
# 'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
||||
)
|
||||
|
||||
ROOT_URLCONF = 'papiez_ipsum.urls'
|
||||
|
||||
# Python dotted path to the WSGI application used by Django's runserver.
|
||||
WSGI_APPLICATION = 'papiez_ipsum.wsgi.application'
|
||||
|
||||
TEMPLATE_DIRS = (
|
||||
# Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
|
||||
# Always use forward slashes, even on Windows.
|
||||
# Don't forget to use absolute paths, not relative paths.
|
||||
)
|
||||
|
||||
INSTALLED_APPS = (
|
||||
'django.contrib.auth',
|
||||
'django.contrib.contenttypes',
|
||||
'django.contrib.sessions',
|
||||
'django.contrib.sites',
|
||||
'django.contrib.messages',
|
||||
'django.contrib.staticfiles',
|
||||
# Uncomment the next line to enable the admin:
|
||||
'django.contrib.admin',
|
||||
# Uncomment the next line to enable admin documentation:
|
||||
# 'django.contrib.admindocs',
|
||||
'papiezator'
|
||||
)
|
||||
|
||||
SESSION_SERIALIZER = 'django.contrib.sessions.serializers.JSONSerializer'
|
||||
|
||||
# A sample logging configuration. The only tangible logging
|
||||
# performed by this configuration is to send an email to
|
||||
# the site admins on every HTTP 500 error when DEBUG=False.
|
||||
# See http://docs.djangoproject.com/en/dev/topics/logging for
|
||||
# more details on how to customize your logging configuration.
|
||||
LOGGING = {
|
||||
'version': 1,
|
||||
'disable_existing_loggers': False,
|
||||
'filters': {
|
||||
'require_debug_false': {
|
||||
'()': 'django.utils.log.RequireDebugFalse'
|
||||
}
|
||||
},
|
||||
'handlers': {
|
||||
'mail_admins': {
|
||||
'level': 'ERROR',
|
||||
'filters': ['require_debug_false'],
|
||||
'class': 'django.utils.log.AdminEmailHandler'
|
||||
}
|
||||
},
|
||||
'loggers': {
|
||||
'django.request': {
|
||||
'handlers': ['mail_admins'],
|
||||
'level': 'ERROR',
|
||||
'propagate': True,
|
||||
},
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
Binary file not shown.
Before Width: | Height: | Size: 8.6 KiB |
Binary file not shown.
Before Width: | Height: | Size: 12 KiB |
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -1,17 +0,0 @@
|
|||
from django.conf.urls import patterns, include, url
|
||||
|
||||
# Uncomment the next two lines to enable the admin:
|
||||
from django.contrib import admin
|
||||
admin.autodiscover()
|
||||
|
||||
urlpatterns = patterns('',
|
||||
# Examples:
|
||||
url(r'^', include('papiezator.urls', namespace='papiezator')),
|
||||
# url(r'^papiez_ipsum/', include('papiez_ipsum.foo.urls')),
|
||||
|
||||
# Uncomment the admin/doc line below to enable admin documentation:
|
||||
# url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
|
||||
|
||||
# Uncomment the next line to enable the admin:
|
||||
url(r'^freemasonry/', include(admin.site.urls)),
|
||||
)
|
|
@ -1,32 +0,0 @@
|
|||
"""
|
||||
WSGI config for papiez_ipsum project.
|
||||
|
||||
This module contains the WSGI application used by Django's development server
|
||||
and any production WSGI deployments. It should expose a module-level variable
|
||||
named ``application``. Django's ``runserver`` and ``runfcgi`` commands discover
|
||||
this application via the ``WSGI_APPLICATION`` setting.
|
||||
|
||||
Usually you will have the standard Django WSGI application here, but it also
|
||||
might make sense to replace the whole Django WSGI application with a custom one
|
||||
that later delegates to the Django one. For example, you could introduce WSGI
|
||||
middleware here, or combine a Django application with an application of another
|
||||
framework.
|
||||
|
||||
"""
|
||||
import os
|
||||
|
||||
# We defer to a DJANGO_SETTINGS_MODULE already in the environment. This breaks
|
||||
# if running multiple sites in the same mod_wsgi process. To fix this, use
|
||||
# mod_wsgi daemon mode with each site in its own daemon process, or use
|
||||
# os.environ["DJANGO_SETTINGS_MODULE"] = "papiez_ipsum.settings"
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "papiez_ipsum.settings")
|
||||
|
||||
# This application object is used by any WSGI server configured to use this
|
||||
# file. This includes Django's development server, if the WSGI_APPLICATION
|
||||
# setting points here.
|
||||
from django.core.wsgi import get_wsgi_application
|
||||
application = get_wsgi_application()
|
||||
|
||||
# Apply WSGI middleware here.
|
||||
# from helloworld.wsgi import HelloWorldApplication
|
||||
# application = HelloWorldApplication(application)
|
|
@ -1,10 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- encoding: utf-8 -*-
|
||||
from django.contrib import admin
|
||||
|
||||
|
||||
from papiezator.models import Pope, PopeVersion, PerfectPope
|
||||
|
||||
admin.site.register(Pope)
|
||||
admin.site.register(PopeVersion)
|
||||
admin.site.register(PerfectPope)
|
|
@ -1,2 +0,0 @@
|
|||
popes:
|
||||
PYTHONPATH='/home/daz/Documents/Projects/Py/django/papiez_ipsum' DJANGO_SETTINGS_MODULE="papiez_ipsum.settings" python pope_utils.py
|
|
@ -1,28 +0,0 @@
|
|||
from django.db import models
|
||||
|
||||
decimal_places = 3
|
||||
|
||||
class Pope(models.Model):
|
||||
path = models.CharField(max_length=200)
|
||||
width = models.IntegerField()
|
||||
height = models.IntegerField()
|
||||
aspect_ratio = models.DecimalField(max_digits=6, decimal_places=decimal_places)
|
||||
pope_version = models.ForeignKey('PopeVersion')
|
||||
|
||||
def __str__(self):
|
||||
return self.path.split('/')[-1]
|
||||
|
||||
class PopeVersion(models.Model):
|
||||
pope_id = models.AutoField(primary_key=True)
|
||||
pope_name = models.CharField(max_length=200)
|
||||
|
||||
def __str__(self):
|
||||
return self.pope_name
|
||||
|
||||
class PerfectPope(models.Model):
|
||||
aspect_ratio = models.DecimalField(max_digits=6, decimal_places=decimal_places)
|
||||
pope = models.ForeignKey('Pope')
|
||||
|
||||
def __str__(self):
|
||||
|
||||
return str(self.aspect_ratio)
|
|
@ -1,50 +0,0 @@
|
|||
from papiezator.models import Pope, PerfectPope, decimal_places
|
||||
from PIL import Image
|
||||
import decimal
|
||||
PREFIX = "popes"
|
||||
|
||||
|
||||
class ENOPopeException(Exception): pass
|
||||
|
||||
|
||||
def select_best_pope(aspect_ratio):
|
||||
aspect_ratio = decimal.Decimal(
|
||||
round(aspect_ratio, decimal_places)
|
||||
)
|
||||
pp = PerfectPope.objects.filter(aspect_ratio=aspect_ratio)
|
||||
if pp:
|
||||
return pp[0].pope.path
|
||||
lte = Pope.objects.filter(aspect_ratio__lte=aspect_ratio).order_by('-aspect_ratio')
|
||||
gte = Pope.objects.filter(aspect_ratio__gte=aspect_ratio).order_by('aspect_ratio')
|
||||
|
||||
if not gte and not lte:
|
||||
raise ENOPopeException
|
||||
elif not gte:
|
||||
return lte[0].path
|
||||
elif not lte:
|
||||
return gte[0].path
|
||||
else:
|
||||
r_lte = abs(aspect_ratio - lte[0].aspect_ratio)
|
||||
r_gte = abs(aspect_ratio - gte[0].aspect_ratio)
|
||||
if r_lte >= r_gte:
|
||||
return _select_pope(aspect_ratio, gte[0])
|
||||
else:
|
||||
return _select_pope(aspect_ratio, lte[0])
|
||||
|
||||
|
||||
def _select_pope(aspect_ratio, pope):
|
||||
#pp = PerfectPope(aspect_ratio=aspect_ratio, pope=pope)
|
||||
#pp.save() # FIXME:
|
||||
return pope.path
|
||||
|
||||
|
||||
|
||||
class PopeMaster:
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
def parse_pope(self, pope):
|
||||
im = Image.open(pope)
|
||||
width, height = im.size
|
||||
aspect_ratio = round(width/height, decimal_places)
|
||||
return Pope(path=pope, width=width, height=height, aspect_ratio=aspect_ratio)
|
|
@ -1,56 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title> </title>
|
||||
<link rel="stylesheet" href="">
|
||||
</head>
|
||||
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
|
||||
<script src="//code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
|
||||
<link rel="stylesheet" href="//code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css"/>
|
||||
|
||||
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.2/css/bootstrap.min.css">
|
||||
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.2/css/bootstrap-theme.min.css">
|
||||
<script src="//netdna.bootstrapcdn.com/bootstrap/3.0.2/js/bootstrap.min.js"></script>
|
||||
|
||||
<style>
|
||||
@media (min-width: 768px) {
|
||||
.container {
|
||||
max-width: 730px;
|
||||
}
|
||||
}
|
||||
.pope {
|
||||
display: inline;
|
||||
}
|
||||
</style>
|
||||
|
||||
<body>
|
||||
<div class="container">
|
||||
|
||||
<div class="header">
|
||||
<h3 class="text-muted">Papalizator sportowy</h3>
|
||||
</div>
|
||||
|
||||
<div class="jumbotron">
|
||||
Jan Paweł II wypełniał małe strony
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-xs-5">
|
||||
<h2>Get your popes</h2>
|
||||
<img class="pope" src="{% url 'papiezator:conclave' 255 200 %}">
|
||||
<img class="pope" src="{% url 'papiezator:conclave' 125 100 %}">
|
||||
<img class="pope" src="{% url 'papiezator:conclave' 125 100 %}">
|
||||
</div>
|
||||
<div class="col-xs-7">
|
||||
<h2>Get your popes today</h2>
|
||||
<img class="pope" src="{% url 'papiezator:conclave' 150 200 %}">
|
||||
<img class="pope" src="{% url 'papiezator:conclave' 150 200 %}">
|
||||
<img class="pope" src="{% url 'papiezator:conclave' 300 100 %}">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
"""
|
||||
This file demonstrates writing tests using the unittest module. These will pass
|
||||
when you run "manage.py test".
|
||||
|
||||
Replace this with more appropriate tests for your application.
|
||||
"""
|
||||
|
||||
from django.test import TestCase
|
||||
|
||||
|
||||
class SimpleTest(TestCase):
|
||||
def test_basic_addition(self):
|
||||
"""
|
||||
Tests that 1 + 1 always equals 2.
|
||||
"""
|
||||
self.assertEqual(1 + 1, 2)
|
|
@ -1,11 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- encoding: utf-8 -*-
|
||||
from django.conf.urls import patterns, url
|
||||
from papiezator import views
|
||||
|
||||
urlpatterns = patterns('',
|
||||
url(r'^$', views.index, name='index'),
|
||||
url(r'^dupa', views.conclave, name='conclave'),
|
||||
url(r'^(?P<width>\d+)/(?P<height>\d+)/$', views.conclave, name='conclave'),
|
||||
)
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
# Create your views here.
|
||||
from django.shortcuts import render
|
||||
from django.http import HttpResponse
|
||||
from PIL import Image
|
||||
from io import BytesIO # FIXME:
|
||||
from papiezator.pope_utils import select_best_pope, ENOPopeException
|
||||
|
||||
|
||||
def index(request):
|
||||
|
||||
return render(request,
|
||||
"papiezator/index.html")
|
||||
pass
|
||||
|
||||
def conclave(request, width, height):
|
||||
width, height = int(width), int(height)
|
||||
if width > 0 and height > 0:
|
||||
aspect_ratio = width/height
|
||||
try:
|
||||
pope = select_best_pope(aspect_ratio)
|
||||
except ENOPopeException:
|
||||
return("czarny dym")
|
||||
|
||||
im = Image.open(pope)
|
||||
im = im.resize((width, height))
|
||||
f = BytesIO() # FIXME: ceriously.
|
||||
im.save(f, "jpeg")
|
||||
f.seek(0)
|
||||
return HttpResponse(f.read(), mimetype="image/jpeg")
|
||||
else:
|
||||
return HttpResponse("8====D~~~~")
|
1
popes
1
popes
|
@ -1 +0,0 @@
|
|||
Subproject commit ca6d2f4627a3c2ea4edc4689bb45e688d3f052a7
|
|
@ -1,23 +0,0 @@
|
|||
import os
|
||||
os.environ ['PYTHONPATH'] = '/home/daz/Documents/Projects/Py/django/papiez_ipsum'
|
||||
os.environ['DJANGO_SETTINGS_MODULE'] = 'papiez_ipsum.settings'
|
||||
#!/usr/bin/env python
|
||||
from papiezator.models import Pope, PopeVersion
|
||||
from papiezator.pope_utils import PopeMaster
|
||||
from os import path
|
||||
|
||||
PREFIX = "popes"
|
||||
|
||||
|
||||
pm = PopeMaster()
|
||||
|
||||
with open('popes/JP2_list') as file:
|
||||
jp2 = PopeVersion(0, "John Paul II")
|
||||
jp2.save()
|
||||
for line in file:
|
||||
pope = line.rstrip()
|
||||
p = pm.parse_pope(path.join(PREFIX, pope))
|
||||
p.pope_version = jp2
|
||||
p.save()
|
||||
print(p)
|
||||
|
Loading…
Reference in New Issue