Commit da40ab99 authored by Patrick Kimber's avatar Patrick Kimber

init

parent 3d8650f3
dev_booking
recursive-include story/static *
recursive-include story/templates *
include LICENSE
include README
include requirements/*.txt
include *.txt
prune example/
\ No newline at end of file
from django.contrib import admin
from django import forms
from base.form_utils import RequiredFieldForm
from .models import Booking
class BookingEmptyForm(forms.ModelForm):
class Meta:
model = Story
fields = ()
class BookingForm(RequiredFieldForm):
def __init__(self, *args, **kwargs):
super(StoryTrustForm, self).__init__(*args, **kwargs)
self.fields['title'].widget.attrs.update(
{'class': 'pure-input-2-3'}
)
self.fields['description'].widget.attrs.update(
{'class': 'pure-input-2-3'}
)
class Meta:
model = Booking
fields = ('from_date', 'to_date', 'title', 'description')
from django.core.management.base import BaseCommand
from booking.tests.scenario import default_scenario_booking
class Command(BaseCommand):
help = "Create demo data for 'booking'"
def handle(self, *args, **options):
default_scenario_booking()
print("Created 'booking' demo data...")
from django.core.management.base import BaseCommand
class Command(BaseCommand):
help = "Initialise 'booking' application"
def handle(self, *args, **options):
print "Initialised 'booking' app..."
from django.conf import settings
from django.core.exceptions import ValidationError
from django.core.urlresolvers import reverse
from django.db import models
import reversion
from base.model_utils import TimeStampedModel
class Booking(TimeStampedModel):
from_date = models.DateField()
to_date = models.DateField()
title = models.CharField(max_length=100)
description = models.TextField(blank=True, null=True)
class Meta:
ordering = ['from_date']
verbose_name = 'Booking'
verbose_name_plural = 'Bookings'
def __unicode__(self):
return unicode('{}-{}: {}'.format(
self.from_date.strftime("%a %d %b %Y"),
self.to_date.strftime("%a %d %b %Y"),
self.title,
))
def clean(self):
if (self.from_date > self.to_date):
raise ValidationError(
'A booking cannot end before it has started.'
)
reversion.register(Booking)
{% extends "project/base.html" %}
{% extends "booking/base.html" %}
{% block title %}
News stories
{% endblock title %}
{% block sub_heading %}
News stories
{% endblock sub_heading %}
{% block content %}
<div class="pure-g-r">
<div class="pure-u-1">
Booking System
</div>
</div>
{% endblock content %}
from django.utils.text import slugify
from base.tests.model_maker import clean_and_save
from booking.models import Booking
def make_booking(from_date, to_date, title, **kwargs):
defaults = dict(
from_date=from_date,
to_date=to_date,
title=title,
)
defaults.update(kwargs)
return clean_and_save(Booking(**defaults))
from datetime import (
datetime,
timedelta,
)
from booking.models import Booking
from booking.tests.model_maker import make_booking
def default_scenario_booking():
today = datetime.today()
next_week = today + timedelta(days=7)
make_booking(
next_week,
next_week + timedelta(days = 3),
'Three days in the sun',
)
from datetime import (
datetime,
timedelta,
)
from django.core.exceptions import ValidationError
from django.test import TestCase
from booking.tests.model_maker import make_booking
class TestBooking(TestCase):
def test_end_before_start(self):
"""Booking - start before the end!"""
today = datetime.today()
next_week = today + timedelta(days=7)
self.assertRaises(
ValidationError,
make_booking,
next_week,
next_week + timedelta(days=-2),
'Two days in the sun',
)
from django.test import TestCase
from booking.management.commands import demo_data_booking
from booking.management.commands import init_app_booking
from login.management.commands import demo_data_login
class TestCommand(TestCase):
def test_demo_data(self):
""" Test the management command """
pre_command = demo_data_login.Command()
pre_command.handle()
command = demo_data_booking.Command()
command.handle()
def test_init_app(self):
""" Test the management command """
command = init_app_booking.Command()
command.handle()
from django.core.urlresolvers import reverse
from base.tests.test_utils import PermTestCase
from booking.models import Booking
from booking.tests.scenario import default_scenario_booking
from login.tests.scenario import default_scenario_login
class TestViewStory(PermTestCase):
def setUp(self):
default_scenario_login()
default_scenario_booking()
def test_list_perm(self):
self.assert_staff_only(reverse('booking.list'))
from django.conf.urls import (
patterns, url
)
from .views import (
BookingListView,
)
urlpatterns = patterns(
'',
url(regex=r'^$',
view=BookingListView.as_view(),
name='booking.list'
),
)
from django.views.generic import ListView
from braces.views import (
LoginRequiredMixin,
StaffuserRequiredMixin,
)
from .models import Booking
from base.view_utils import BaseMixin
class BookingListView(LoginRequiredMixin, StaffuserRequiredMixin, ListView):
model = Booking
""" Django settings """
from django.core.urlresolvers import reverse_lazy
DEBUG = True
TEMPLATE_DEBUG = DEBUG
THUMBNAIL_DEBUG = DEBUG
SESSION_COOKIE_SECURE = False
CSRF_COOKIE_SECURE = False
TEMPLATE_STRING_IF_INVALID = '**** INVALID EXPRESSION: %s ****'
ADMINS = (
('admin', 'code@pkimber.net'),
)
MANAGERS = ADMINS
# 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.
# On Unix systems, a value of None will cause Django to use the same
# timezone as the operating system.
# If running in a Windows environment this must be set to the same as your
# system time zone.
TIME_ZONE = 'Europe/London'
# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = 'en-gb'
SITE_ID = 1
# If you set this to False, Django will make some optimizations so as not
# to load the internationalization machinery.
USE_I18N = False
# 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: "/home/media/media.lawrence.com/media/"
MEDIA_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 = 'web_static/'
# URL prefix for static files.
# Example: "http://media.lawrence.com/static/"
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 = 'w@t8%tdwyi-n$u_s#4_+cwnq&6)1n)l3p-qe(ziala0j^vo12d'
# 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',
'django.middleware.transaction.TransactionMiddleware',
'reversion.middleware.RevisionMiddleware',
# Uncomment the next line for simple clickjacking protection:
# 'django.middleware.clickjacking.XFrameOptionsMiddleware',
)
ROOT_URLCONF = 'example.urls'
# Python dotted path to the WSGI application used by Django's runserver.
WSGI_APPLICATION = 'example.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.
)
DJANGO_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 admin documentation:
# 'django.contrib.admindocs',
# admin after login, so we prefer login templates
'django.contrib.admin',
)
THIRD_PARTY_APPS = (
'reversion',
'south',
)
LOCAL_APPS = (
'base',
'example',
'booking',
'login',
)
INSTALLED_APPS = DJANGO_APPS + THIRD_PARTY_APPS + LOCAL_APPS
# 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,
},
}
}
# https://github.com/mbi/django-simple-captcha
CAPTCHA_LETTER_ROTATION = None
CAPTCHA_NOISE_FUNCTIONS = None
CAPTCHA_TEST_MODE = True
FTP_STATIC_DIR = None
FTP_STATIC_URL = None
# URL where requests are redirected after login when the contrib.auth.login
# view gets no next parameter.
LOGIN_REDIRECT_URL = reverse_lazy('project.home.user')
# https://github.com/johnsensible/django-sendfile
SENDFILE_BACKEND = 'sendfile.backends.development'
SENDFILE_ROOT = 'media-private'
from .base import *
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
'NAME': 'temp.db', # Or path to database file if using sqlite3.
'USER': '', # 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.
}
}
{% extends "story/base.html" %}
{% load staticfiles %}
{% block sub_title %}
Home
{% endblock sub_title %}
{% block sub_heading %}
Home
{% endblock sub_heading %}
{% block content %}
<div class="pure-g-r">
<div class="pure-u-1">
<div class="pure-menu pure-menu-open pure-menu-horizontal">
<ul>
{% if user.is_active %}
<li>
<a href="{% url 'story.create.trust' %}">
<i class="fa fa-edit"></i>
Create
</a>
</li>
<li>
<a href="{% url 'story.list' %}">
<i class="fa fa-list"></i>
List news
</a>
</li>
{% else %}
<li>
<a href="{% url 'story.create.anon' %}">
<i class="fa fa-edit"></i>
Create news
</a>
</li>
{% endif %}
</li>
</ul>
</div>
</div>
</div>
{% endblock content %}
{% extends "base/base.html" %}
{% load staticfiles %}
{% block title %}
I Live Here
{% endblock title %}
{% block heading %}
I Live Here
{% endblock heading %}
{% block sub_heading %}
Example App
{% endblock sub_heading %}
{% block footer %}
{% endblock footer %}
from django.conf import settings
from django.conf.urls import patterns, include, url
from django.conf.urls.static import static
from django.contrib import admin
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
from django.core.urlresolvers import reverse_lazy
from django.views.generic import RedirectView
from .views import HomeView
admin.autodiscover()
urlpatterns = patterns(
'',
url(regex=r'^$',
view=HomeView.as_view(),
name='project.home'
),
url(regex=r'^',
view=include('login.urls')
),
url(regex=r'^admin/',
view=include(admin.site.urls)
),
url(regex=r'^booking/',
view=include('booking.urls')
),
url(r'^home/user/$',
view=RedirectView.as_view(url=reverse_lazy('project.home')),
name='project.home.user'
),
)
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
# ^ helper function to return a URL pattern for serving files in debug mode.
# https://docs.djangoproject.com/en/1.5/howto/static-files/#serving-files-uploaded-by-a-user
urlpatterns += staticfiles_urlpatterns()
from django.views.generic import TemplateView
class HomeView(TemplateView):
template_name = 'example/home.html'
"""
WSGI config for app 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.
"""
# 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)
django-braces==1.3.1
django-reversion==1.8.0
django-sendfile
Django==1.6.1
South==0.8.4
-r base.txt
beautifulsoup4
fabric
gitpython==0.3.1-beta2
ipdb
hgapi
psycopg2
pytest-django
pyyaml
walkdir
description: booking
name: booking
version: 0.0.01
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment