--- /dev/null
+#
+# Use as:
+#
+# source <(curl https://py.mdrn.pl/django)
+#
+
+
+# Make it a function, so that it works with `source`
+start_project() {
+
+local DJANGO_REQ='Django>=1.7,<1.8'
+local DJANGO_ROOT='src'
+local PYPI='https://py.mdrn.pl:8443/simple'
+local DEFAULT_PYTHON="`which python3.4`"
+
+if [ -z "$DEFAULT_PYTHON" ]; then
+ DEFAULT_PYTHON="`which python3`"
+fi
+if [ -z "$DEFAULT_PYTHON" ]; then
+ DEFAULT_PYTHON="`which python`"
+fi
+
+local PROJECT=$PROJECT
+if [ -z "$PROJECT" ]; then
+ PROJECT="$1"
+fi
+
+if [ -z "$FNP_PROJECT_TEMPLATE" ]; then
+ local FNP_PROJECT_TEMPLATE='https://git.mdrn.pl/fnp-django-template.git/snapshot/HEAD.tar.gz'
+fi
+
+local VIRTUALENVWRAPPER_PATHS="
+ /etc/bash_completion.d/virtualenvwrapper
+ /usr/bin/virtualenvwrapper.sh
+ /usr/local/bin/virtualenvwrapper.sh
+"
+
+# Colorful output.
+local strong='\e[0;32m'
+local error='\e[1;31m'
+local normal='\e[0m'
+
+local PYTHON="$PYTHON"
+if [ -z "$PYTHON" ]; then
+ echo "Defaulting to $DEFAULT_PYTHON."
+ PYTHON="$DEFAULT_PYTHON"
+fi
+
+
+echo "Create new Django project."
+while [ -z "$PROJECT" ]
+do
+ echo "Name of the project:"
+ read PROJECT
+done
+echo -e "Project: ${strong}${PROJECT}${normal}"
+
+if ! type mkvirtualenv > /dev/null; then
+ for venv in $VIRTUALENVWRAPPER_PATHS
+ do
+ if [ -e "$venv" ]
+ then
+ local VIRTUALENVWRAPPER="$venv"
+ break
+ fi
+ done
+ if [ "$VIRTUALENVWRAPPER" ]
+ then
+ echo "virtualenvwrapper found at $VIRTUALENVWRAPPER."
+ source "$VIRTUALENVWRAPPER"
+ else
+ echo -e "${error}ERROR: virtualenvwrapper not found. Tried locations:${normal}"
+ echo "$VIRTUALENVWRAPPER_PATHS"
+ echo -e "${error}Install virtualenvwrapper or add the correct path to this script.${normal}"
+ echo "Aborting."
+ return
+ fi
+fi
+
+echo -e "${strong}Creating virtualenv: $PROJECT $PYTHON...${normal}"
+mkvirtualenv "$PROJECT" --python "$PYTHON"
+echo -e "${strong}Upgrading pip...${normal}"
+pip install -i "$PYPI" -U pip
+echo -e "${strong}Installing Django...${normal}"
+pip install -i "$PYPI" "$DJANGO_REQ"
+pip install -i "$PYPI" --pre django-startproject-plus
+
+echo -e "${strong}Downloading project template...${normal}"
+if [[ "$FNP_PROJECT_TEMPLATE" =~ ^(https?|ftp):// ]]; then
+ local PROJECT_TMPDIR=`mktemp -d fnp-django-template-XXX`
+ curl "$FNP_PROJECT_TEMPLATE" | tar xzf - -C "$PROJECT_TMPDIR"
+ local TEMPLATE="$PROJECT_TMPDIR"/fnp-django-template-*/src
+else
+ local TEMPLATE="$FNP_PROJECT_TEMPLATE"
+fi
+
+echo -e "${strong}Starting the project...${normal}"
+django-startproject.py \
+ --template "$TEMPLATE" \
+ --name NOTICE \
+ --extra_context='{"year": "`date +%Y`"}' \
+ "$PROJECT"
+
+if [ -n "$PROJECT_TMPDIR" ]; then
+ rm -rf "$PROJECT_TMPDIR"
+fi
+
+cd "$PROJECT"
+
+chmod +x "$DJANGO_ROOT"/manage.py
+mv _gitignore .gitignore
+
+echo -e "${strong}Installing requirements...${normal}"
+pip install -i "$PYPI" -r requirements.txt
+echo -e "${strong}Installing developer requirements...${normal}"
+pip install -i "$PYPI" -r requirements-dev.txt
+echo -e "${strong}Running syncdb...${normal}"
+"$DJANGO_ROOT"/manage.py syncdb --noinput
+
+echo -e "${strong}Starting new git repository...${normal}"
+git init
+
+echo -e "${strong}What next?${normal}"
+echo " * Work on your app, commit to git."
+echo " * Review fabfile, use fab for deployment."
+
+
+}
+start_project
+
+# The following is just for displaying it as a webpage:<!--
+#--><style>body{white-space:pre;color:#ddd}</style><h1 style="color:#000;text-align:center;position:fixed;top:0;bottom:0;left:0;right:0;white-space:normal">source <(curl <span id="location"></span>)</h1><script>document.getElementById('location').innerHTML=window.location;</script>
+
+/var
localsettings.py
*~
*.orig
-from fnpdjango.deploy import *
+from fnpdeploy import *
env.project_name = '{{ project_name }}'
env.hosts = ['giewont.icm.edu.pl']
env.user = '{{ project_name }}'
env.app_path = '/srv/{{ project_name }}'
env.services = [
- DebianGunicorn('{{ project_name }}'),
+ Supervisord('{{ project_name }}'),
]
env.django_root_path = 'src'
-fabric>=1.5,<1.6
+-i https://py.mdrn.pl:8443/simple
+
+fnpdeploy
--i http://pypi.nowoczesnapolska.org.pl/simple
+-i https://py.mdrn.pl:8443/simple
-Django>=1.6,<1.7
-South>=0.7.4
-django-pipeline>=1.2,<1.3
+Django>=1.7,<1.8
+django-pipeline>=1.3,<1.4
django-piwik
#pyScss
#git+git://github.com/Kronuz/pyScss.git@d8f4da23a3c87696a75b3830ed4ab49b75550a93#egg=pyScss
#TODO: pyScss support, for now just install sass
-django_cas>=2.1,<2.2
-fnpdjango<0.2
+django_cas_ng>=3.4,<3.5
+fnpdjango>=0.2,<0.3
ipython
INSTALLED_APPS = (
'{{ project_name }}',
'fnpdjango',
- 'south',
'pipeline',
# Disable, if not using Piwik.
'piwik',
- # Disable, if not using CAS.
- 'django_cas',
'django.contrib.auth',
'django.contrib.contenttypes',
-from . import INSTALLED_APPS
+# Remove if not using CAS.
+AUTHENTICATION_BACKENDS = (
+ 'django.contrib.auth.backends.ModelBackend',
+ 'django_cas_ng.backends.CASBackend',
+)
-
-if 'django_cas' in INSTALLED_APPS:
- AUTHENTICATION_BACKENDS = (
- 'django.contrib.auth.backends.ModelBackend',
- 'fnpdjango.auth_backends.AttrCASBackend',
- )
SITE_ID = 1
+SILENCED_SYSTEM_CHECKS = [
+ '1_6.W001',
+ ]
+
# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
TEMPLATE_CONTEXT_PROCESSORS = tuple(x for x in (
- "django.contrib.auth.context_processors.auth"
- if "django.contrib.auth" in INSTALLED_APPS else None,
+ "django.contrib.auth.context_processors.auth",
"django.core.context_processors.debug",
"django.core.context_processors.i18n",
"django.core.context_processors.media",
"django.core.context_processors.static",
"django.core.context_processors.tz",
- "django.contrib.messages.context_processors.messages"
- if 'django.contrib.messages' in INSTALLED_APPS else None,
+ "django.contrib.messages.context_processors.messages",
"django.core.context_processors.request"
) if x is not None)
-CAS_SERVER_URL = 'http://logowanie.nowoczesnapolska.org.pl/cas/'
+# CAS-specific
+CAS_SERVER_URL = 'https://logowanie.nowoczesnapolska.org.pl/cas/'
CAS_VERSION = '3'
-from . import INSTALLED_APPS
-
-MIDDLEWARE_CLASSES = tuple(x for x in (
- 'django.contrib.sessions.middleware.SessionMiddleware'
- if "django.contrib.sessions" in INSTALLED_APPS else None,
+MIDDLEWARE_CLASSES = [
+ 'django.contrib.sessions.middleware.SessionMiddleware',
#'django.middleware.locale.LocaleMiddleware',
'fnpdjango.middleware.URLLocaleMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
- 'django.contrib.auth.middleware.AuthenticationMiddleware'
- if "django.contrib.auth" in INSTALLED_APPS else None,
- 'django_cas.middleware.CASMiddleware'
- if "django_cas" in INSTALLED_APPS else None,
- 'django.contrib.messages.middleware.MessageMiddleware'
- if "django.contrib.messages" in INSTALLED_APPS else None,
- 'piwik.django.middleware.PiwikMiddleware'
- if "piwik.django" in INSTALLED_APPS else None,
+ 'django.contrib.auth.middleware.AuthenticationMiddleware',
+ 'django_cas_ng.middleware.CASMiddleware', # Remove if not using CAS.
+ 'django.contrib.messages.middleware.MessageMiddleware',
# Uncomment the next line for simple clickjacking protection:
# 'django.middleware.clickjacking.XFrameOptionsMiddleware',
- 'pagination.middleware.PaginationMiddleware'
- if "pagination" in INSTALLED_APPS else None,
'fnpdjango.middleware.SetRemoteAddrFromXRealIP'
-) if x is not None)
+]
from os import path
-from paths import PROJECT_DIR
+from .paths import PROJECT_DIR
MEDIA_ROOT = path.join(PROJECT_DIR, 'var/media/')
from django.conf.urls import patterns, include, url
from django.conf import settings
+from django.contrib import admin
urlpatterns = patterns('',
# Examples:
# url(r'^$', '{{ project_name }}.views.home', name='home'),
# url(r'^{{ project_name }}/', include('foo.urls')),
-)
-
-# Admin stuff, if necessary.
-if 'django.contrib.admin' in settings.INSTALLED_APPS:
- from django.contrib import admin
- admin.autodiscover()
- urlpatterns += patterns('',
- url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
- url(r'^admin/', include(admin.site.urls)),
- )
+ # Admin stuff.
+ url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
+ url(r'^admin/', include(admin.site.urls)),
-# Auth stuff, if necessary
-if 'django_cas' in settings.INSTALLED_APPS:
- urlpatterns += patterns('',
- (r'^accounts/login/$', 'django_cas.views.login'),
- (r'^accounts/logout/$', 'django_cas.views.logout'),
- )
+ # CAS stuff.
+ url(r'^accounts/login/$', 'django_cas_ng.views.login'),
+ url(r'^accounts/logout/$', 'django_cas_ng.views.logout'),
+)
# Media in DEBUG mode
if settings.DEBUG:
'document_root': settings.MEDIA_ROOT,
}),
)
+
--- /dev/null
+#!/bin/bash
+DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+# Colorful output.
+strong='\e[0;32m'
+error='\e[1;31m'
+normal='\e[0m'
+
+tmpdir="`mktemp -d "$DIR/test-XXX"`"
+echo "$tmpdir"
+
+
+export WORKON_HOME="$tmpdir/v"
+mkdir "$WORKON_HOME"
+
+
+PYTHON="$1"
+if [ -z "$PYTHON" ]; then
+ PYTHON=python
+fi
+PYTHON_VER="`$PYTHON -V 2>&1`"
+echo -e "${strong}Using $PYTHON_VER${normal}"
+PYTHON="`which $PYTHON`"
+
+FNP_PROJECT_TEMPLATE="$DIR"/..
+projectdir="$tmpdir"/p
+mkdir "$projectdir"
+cd "$projectdir"
+. "$DIR"/../bootstrap.sh TEST_PROJECT --python "$PYTHON"
+
+
+# Test for active virtualenv
+if [ "$VIRTUAL_ENV" != "$WORKON_HOME/TEST_PROJECT" ]; then
+ echo -e "${error}Expected to be in virtualenv, found python: `which python`${normal}"
+fi
+if [ "`python -V 2>&1`" != "$PYTHON_VER" ]; then
+ echo -e "${error}Expected $PYTHON_VER, found `python -V 2>&1`${normal}"
+fi
+
+# Test that there is only project dir in the dir.
+if [ "`ls "$projectdir"`" != "TEST_PROJECT" ]; then
+ echo -e "${error}Only created project expected in project dir, found: `ls "$projectdir"`${normal}"
+fi
+
+rm -rf "$tmpdir"