Skip to content

Instantly share code, notes, and snippets.

View ashwoods's full-sized avatar

Ashley Camba ashwoods

View GitHub Profile

Workflows (States) in Django

I'm going to cover a simple, but effective, utility for managing state and transitions (aka workflow). We often need to store the state (status) of a model and it should only be in one state at a time.

Common Software Uses

  • Publishing (Draft->Approved->Published->Expired->Deleted)
sudo apt-get install ruby-dev
sudo gem install rdoc
sudo gem install guard
sudo gem install guard-livereload

Keybase proof

I hereby claim:

  • I am ashwoods on github.
  • I am ashwoods (https://keybase.io/ashwoods) on keybase.
  • I have a public key whose fingerprint is E4F4 E15C BB1E 0062 1F90 9F24 DE62 ADE2 A6C6 A243

To claim this, I am signing this object:

@ashwoods
ashwoods / .gitignore
Created October 11, 2011 17:58
python/django gitignore
*~
*.pyc
*.swp
hospex/local_settings.py
hospex/hospex.db
hospex/site-static/
hospex/compass/.sass-cache/
.code_swarm
.idea
build
node "submitz" inherits default {
include django
include supervisor
django::resource::project {'submitz':
ensure => present,
location => '/opt/submitz/submitz',
source => 'git@github.com:xipax/submitz.git',
user => 'submitz',
Vagrant::Config.run do |config|
config.vm.box = "bribespot-oneiric-v1"
config.vm.box_url = "http://dl.dropbox.com/u/1419385/vagrant/bribespot-oneiric-v1.box"
config.vm.host_name = 'vagrant'
config.vm.network :hostonly, "33.33.33.10"
config.vm.forward_port 8000, 8000 #dev server
config.vm.forward_port 6379, 6379 #redis
config.vm.forward_port 80, 8080 #nginx
@ashwoods
ashwoods / gist:2932860
Created June 14, 2012 20:50
django supervisor example
# This file is autogenerated by Puppet. Manual changes will be overwritten!
[program:gunicorn-bribespot]
command=/opt/bribespot/.virtualenvs/bribespot/bin/gunicorn_django -w 4 -b 0.0.0.0:9000
numprocs=1
priority=999
autostart=true
autorestart=true
startsecs=1
startretries=3
exitcodes=0,2
@ashwoods
ashwoods / bribespot.conf
Created June 14, 2012 20:55
nginx configuration
server {
listen *;
server_name bribespot.org;
access_log /var/log/nginx/bribespot.access.log;
location / {
proxy_pass http://bribespot_app;
proxy_read_timeout 120;
}
@ashwoods
ashwoods / base.html
Created June 18, 2012 17:17
base.html
<html>
<header></header>
<body>
{% block content %}{% endblock %}
</body>
</html>
<html>
<body>
{% block content %}
I am the parent, and any template extending me and has a block content will replace this sentence.
{% endblock %}
</body>
</html>