Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
.vagrant/
src/htmlcov
.coverage
*.pyc
src/assets/css/custom.css
50 changes: 50 additions & 0 deletions fabfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
from fabutils.text import SUCCESS_ART


project_tools = {
'is_using_stylus': False
}


@contextmanager
def virtualenv():
"""
Expand Down Expand Up @@ -103,15 +108,57 @@ def collectstatic():
run('python manage.py collectstatic --noinput')


@task
def createsuperuser():
"""
Creates super user
"""
with virtualenv():
run('python manage.py createsuperuser')


@task
def runtests(app=""):
"""
Runs django tests
"""
with virtualenv():
run("coverage run --source='.' manage.py test %s" % app)
run("coverage html \
--omit=luke/settings/*,luke/wsgi.py")


@task
def runserver():
"""
Starts the development server inside the Vagrant VM.
"""

# Check if stylus compilation is needed
checkstylus()

with virtualenv():
run('python manage.py runserver_plus 0.0.0.0:8000')


@task
def styluscompile(watch=False):
"""
Compiles custom.styl file to css.
"""
watch_config = ""
if watch:
watch_config = "-w"

with virtualenv():
run('stylus -c %s assets/css/custom.styl' % watch_config)


def checkstylus():
if project_tools['is_using_stylus']:
styluscompile()


@task
def deploy(git_ref, upgrade=False):
"""
Expand All @@ -122,6 +169,9 @@ def deploy(git_ref, upgrade=False):
"""
require('hosts', 'user', 'group', 'site_dir', 'django_settings')

# Check if stylus compilation is needed
checkstylus()

# Retrives git reference metadata and creates a temp directory with the
# contents resulting of applying a ``git archive`` command.
message = white('Creating git archive from {0}'.format(git_ref), bold=True)
Expand Down
7 changes: 6 additions & 1 deletion provision/provision.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
#!/bin/bash
echo "Updating apt repositories..."
add-apt-repository ppa:chris-lea/node.js
apt-get update


echo "Installing base packages..."
PACKAGES="build-essential zsh git vim-nox tree htop libjpeg-dev libfreetype6-dev graphviz gettext"
PACKAGES="$PACKAGES python python-setuptools python-pip python-dev"
PACKAGES="$PACKAGES python python-setuptools python-pip python-dev nodejs"
PACKAGES="$PACKAGES postgresql-9.3 postgresql-server-dev-9.3"

apt-get install -y $PACKAGES
Expand Down Expand Up @@ -56,6 +57,10 @@ if [ -f "$REQUIREMENTS_FILE" ]; then
fi


echo "Installing Stylus css precompiler..."
npm install stylus -g


echo "Creating Django project..."
PROJECT_NAME=luke
PROJECT_DIR=/home/vagrant/src/$PROJECT_NAME
Expand Down
1 change: 1 addition & 0 deletions src/assets/css/custom.styl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
//project's stylus code
1 change: 1 addition & 0 deletions src/requirements/devel.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@

# Development tools
django-debug-toolbar
coverage==3.7.1