Browse Source

first commit

master
Sanj 12 years ago
commit
29756f9fbe
  1. 48
      fabfile.py
  2. 0
      ifa/__init__.py
  3. 0
      ifa/films/__init__.py
  4. 15
      ifa/films/admin.py
  5. 28
      ifa/films/imports.py
  6. 19
      ifa/films/models.py
  7. 16
      ifa/films/tests.py
  8. 1
      ifa/films/views.py
  9. 10
      ifa/local_settings.py.sample
  10. 194
      ifa/settings.py
  11. 17
      ifa/urls.py
  12. 28
      ifa/wsgi.py
  13. 10
      manage.py
  14. 8
      requirements.txt
  15. 0
      static/css/home.css
  16. 115
      static/css/main.css
  17. 44
      static/css/reset.css
  18. 2
      static/js/jquery-1.8.2.min.js
  19. 9
      templates/404.html
  20. 8
      templates/500.html
  21. 53
      templates/base.html

48
fabfile.py

@ -0,0 +1,48 @@
#this is a fabfile, use it with fab from http://fabfile.org/
#
# initial setup:
# fab production setup
#
# deploy changes:
# fab production deploy
#
from os.path import join
from fabric.api import run, local, sudo, put, env
env.project_name = 'ifa'
def production():
env.hosts = ['%(project_name)s@marlon.in'%env, ]
env.project_root = '/srv/%(project_name)s'%env
def bzr_push():
local('bzr push bzr+ssh://%(project_name)s@%(host)s%(project_root)s'%env)
def bzr_update():
run('cd %(project_root)s;bzr update'%env)
def virtual_run(cmd, *a, **kw):
cmd = 'cd %s; source bin/activate; %s' % (env.project_root, cmd)
run(cmd, *a, **kw)
def update_requirements():
run('pip -E %(project_root)s install -r %(project_root)s/requirements.txt'%env)
def setup():
"""
Setup a fresh virtualenv
"""
local('bzr push --use-existing-dir bzr+ssh://%(project_name)s@%(host)s%(project_root)s'%env)
run('cd %(project_root)s; test -e .bzr/checkout || bzr checkout'%env)
run('virtualenv %(project_root)s'%env)
put(join('settings', '%(host)s.py'%env), join(env.project_root, env.project_name, 'local_settings.py'))
update_requirements()
def deploy():
bzr_push()
bzr_update()
virtual_run('python %(project_root)s/manage.py collectstatic --noinput'%env)
# virtual_run('python %(project_root)s/%(project_name)s/manage.py syncdb;python %(project_root)s/%(project_name)s/manage.py migrate'%env)
run('touch %(project_root)s/wsgi/django.wsgi'%env)

0
ifa/__init__.py

0
ifa/films/__init__.py

15
ifa/films/admin.py

@ -0,0 +1,15 @@
from django.contrib import admin
from models import *
#class OldFilmsFilter(admin.filters.ListFilter):
# pass
class FilmAdmin(admin.ModelAdmin):
save_on_top = True
list_display = ('title', 'director', 'year', 'language', 'available', 'notes',)
list_editable = ('available', 'notes',)
search_fields = ['title', 'director']
list_filter = ['year']
admin.site.register(Film, FilmAdmin)

28
ifa/films/imports.py

@ -0,0 +1,28 @@
path = "/home/sanj/c/ifa/tmp/FILMS.txt"
from models import *
def do():
errors = open("errors.txt", "w")
for line in open(path):
txt = line.strip()
if txt.find(" see ") != -1:
alias, film_name = txt.split(" see ")
fsm = FilmSeeMap(alias=alias, film_name=film_name)
fsm.save()
else:
split = txt.replace("(", ",").replace(")", "").split(",")
if len(split) != 4:
errors.write(txt)
continue
else:
title = split[0].strip()
director = split[1].strip()
language = split[2].strip()
year = split[3].strip()
f = Film(title=title, director=director, language=language, year=year)
try:
f.save()
except:
errors.write(txt)
print title
errors.close()

19
ifa/films/models.py

@ -0,0 +1,19 @@
from django.db import models
class Film(models.Model):
title = models.CharField(max_length=512)
director = models.CharField(max_length=512)
language = models.CharField(max_length=64, blank=True)
year = models.IntegerField(max_length=4, blank=True, null=True)
available = models.BooleanField(default=False)
notes = models.TextField(blank=True)
def __unicode__(self):
return "%s (%s, %s, %s)" % (self.title, self.director, self.language, self.year,)
class FilmSeeMap(models.Model):
film_name = models.CharField(max_length=512)
alias = models.CharField(max_length=512)
# Create your models here.

16
ifa/films/tests.py

@ -0,0 +1,16 @@
"""
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
ifa/films/views.py

@ -0,0 +1 @@
# Create your views here.

10
ifa/local_settings.py.sample

@ -0,0 +1,10 @@
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
'NAME': '{{ project_name }}', # Or path to database file if using sqlite3.
'USER': 'root', # Not used with sqlite3.
'PASSWORD': '', # Not used with sqlite3.
'HOST': '', # Set to empty string for localhost. Not used with sqlite3.
'PORT': '', # Set to empty string for default. Not used with sqlite3.
}
}

194
ifa/settings.py

@ -0,0 +1,194 @@
# Django settings for chhoti project.
import os
from os.path import join
DEBUG = True
TEMPLATE_DEBUG = DEBUG
THUMBNAIL_DEBUG = DEBUG
JSON_DEBUG = DEBUG
ADMINS = (
('Sanjay B', 'sanjay@therateof.com'),
# ('Your Name', 'your_email@example.com'),
)
INTERNAL_IPS = ('127.0.0.1',)
PROJECT_ROOT = os.path.normpath(os.path.dirname(__file__))
MANAGERS = ADMINS
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
'NAME': 'ifa', # Or path to database file if using sqlite3.
'USER': 'root', # Not used with sqlite3.
'PASSWORD': '', # Not used with sqlite3.
'HOST': '', # Set to empty string for localhost. Not used with sqlite3.
'PORT': '', # Set to empty string for default. Not used with sqlite3.
}
}
# 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
MARKITUP_FILTER = ('markdown.markdown', {})
# Absolute filesystem path to the directory that will hold user-uploaded files.
# Example: "/home/media/media.lawrence.com/media/"
MEDIA_ROOT = join(PROJECT_ROOT, 'media')
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash.
# Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
MEDIA_URL = '/media/'
# 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: "/home/media/media.lawrence.com/static/"
STATIC_ROOT = join(PROJECT_ROOT, 'static')
# URL prefix for static files.
# Example: "http://media.lawrence.com/static/"
STATIC_URL = '/static/'
# Additional locations of static files
STATICFILES_DIRS = (
join(PROJECT_ROOT, '../static/'),
# 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 = '%@f@1v!$iwwp53d^v6f^&28bf+bh2)o_ldb%k2j%4)pfjc=01x'
# Make this unique, creates random key first at first time.
try:
SECRET_KEY
except NameError:
SECRET_FILE = os.path.join(PROJECT_ROOT, 'secret.txt')
try:
SECRET_KEY = open(SECRET_FILE).read().strip()
except IOError:
try:
from random import choice
SECRET_KEY = ''.join([choice('abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)') for i in range(50)])
secret = file(SECRET_FILE, 'w')
secret.write(SECRET_KEY)
secret.close()
except IOError:
Exception('Please create a %s file with random characters to generate your secret key!' % SECRET_FILE)
# 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',
'debug_toolbar.middleware.DebugToolbarMiddleware',
# Uncomment the next line for simple clickjacking protection:
# 'django.middleware.clickjacking.XFrameOptionsMiddleware',
)
ROOT_URLCONF = 'ifa.urls'
# Python dotted path to the WSGI application used by Django's runserver.
WSGI_APPLICATION = 'ifa.wsgi.application'
TEMPLATE_DIRS = (
join(PROJECT_ROOT, '../templates')
# 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',
'ifa.films',
'markitup',
'sorl.thumbnail',
'django_extensions',
'adminsortable',
'debug_toolbar',
)
# 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,
},
}
}
try:
from local_settings import *
except:
pass

17
ifa/urls.py

@ -0,0 +1,17 @@
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'^$', 'sat.views.home', name='home'),
# url(r'^sat/', include('sat.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'^admin/', include(admin.site.urls)),
)

28
ifa/wsgi.py

@ -0,0 +1,28 @@
"""
WSGI config for sat 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
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "sat.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)

10
manage.py

@ -0,0 +1,10 @@
#!/usr/bin/env python
import os
import sys
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "ifa.settings")
from django.core.management import execute_from_command_line
execute_from_command_line(sys.argv)

8
requirements.txt

@ -0,0 +1,8 @@
Django>1.4
ox
django-admin-sortable
django_extensions
django-debug-toolbar
sorl-thumbnail
Markdown
django-markitup

0
static/css/home.css

115
static/css/main.css

@ -0,0 +1,115 @@
* {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
html, body {
height: 100%;
width: 100%;
}
body {
background-color: #fff;
font-family:sans-serif;
color: #222;
font-size: 16px;
line-height: 1.4;
}
/* COLUMNS */
/*.col25 {
width: 25%;
}
.col33 {
width:33.33%;
}
.col50 {
width: 50%;
}
.col75 {
width:75%;
}
*/
/* COLUMNS */
/* GLOBAL STYLES */
.clear {
clear: both;
}
a {
text-decoration: none;
}
a:hover, a:focus {
}
strong {
font-weight: bold;
}
em {
font-style: italic;
}
h1, h2, h3, h4, h5, h6 {
padding-bottom:10px;
}
h6 {
font-size: 110%;
}
h5 {
font-size: 120%;
}
h4 {
font-size: 130%;
}
h3 {
font-size: 140%;
}
h2 {
font-size: 150%;
}
h1 {
font-size: 160%;
}
img {
max-width: 100%;
height: auto;
}
input[type="submit"] {
cursor: pointer;
}
textarea {
vertical-align: top;
}
/* END GLOBAL STYLES */
/* MEDIA QUERIES */
/*@media only screen and (max-width: 980px) {
}*/
/* END MEDIA QUERIES */

44
static/css/reset.css

@ -0,0 +1,44 @@
/* http://meyerweb.com/eric/tools/css/reset/
v2.0 | 20110126
License: none (public domain)
*/
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed,
figure, figcaption, footer, header, hgroup,
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure,
footer, header, hgroup, menu, nav, section {
display: block;
}
body {
line-height: 1;
}
ol, ul {
list-style: none;
}
blockquote, q {
quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
content: '';
content: none;
}

2
static/js/jquery-1.8.2.min.js

File diff suppressed because one or more lines are too long

9
templates/404.html

@ -0,0 +1,9 @@
{% extends 'base.html' %}
{% block body_content %}
<div class="bodyContent">
<p class="largeFont">Oops! Page not found.</p>
</div>
{% endblock %}

8
templates/500.html

@ -0,0 +1,8 @@
{% extends 'base.html' %}
{% block body_content %}
<div class="bodyContent">
<p class="largeFont">Oops! The server made a boo-boo! We're working on it.</p>
</div>
{% endblock %}

53
templates/base.html

@ -0,0 +1,53 @@
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="utf-8">
<title>ADD HERE: {% block extra_title %}{% endblock %}</title>
<meta name="keywords" content="PLACE KEYWORDS HERE – they should appear in site content also">
<meta name="title" content="CHANGE AS PER TITLE OF PAGE prefixed with company name">
<meta name="description" content="ADD DETAILS HERE">
<meta http-equiv="X-UA-Compatible" content="chrome=1"> <!-- chrome frame -->
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <!-- for multiple viewport sizes -->
{% block extra_meta %}
{% endblock %}
<link rel="shortcut icon" href="/static/img/favicon.ico" /> <!--favicon-->
<link rel="stylesheet" href="/static/css/reset.css" type="text/css" />
<link rel="stylesheet" href="/static/css/main.css" type="text/css" />
{% block extra_css %}
{% endblock %}
<!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]-->
<script type="text/javascript" src="/static/js/jquery-1.8.2.min.js"></script>
{% block extra_js %}
{% endblock %}
</head>
<body>
<noscript><strong>You need Javascript to run this page</strong></noscript>
</body>
</html>
Loading…
Cancel
Save