Skip to content

Instantly share code, notes, and snippets.

@robrocker7
robrocker7 / index.html
Created September 7, 2012 15:50
Example of index.html
{% extends "base.html" %}
{% load content_filters content_tags sekizai_tags testimonial_tags %}
{% block css %}
<link rel="stylesheet" href="{{ STATIC_URL }}css/home.css">
<!-- Google Analytics Content Experiment code -->
<script>function utmx_section(){}function utmx(){}(function(){var
k='#######',d=document,l=d.location,c=d.cookie;
if(l.search.indexOf('utm_expid='+k)>0)return;
@robrocker7
robrocker7 / base.html
Created September 7, 2012 15:48
Example of Base.html
{% load content_tags content_filters sekizai_tags %}<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>{% block page_title %}{% endblock %}</title>
<meta name="description" content="{% block page_description %}{% endblock %}" />
<meta name="keywords" content="{% block page_keywords %}{% endblock %}" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
<meta name="rating" content="general" />
<meta name="distribution" content="global" />
<meta name="resource-type" content="document" />
@robrocker7
robrocker7 / common.py
Created September 7, 2012 15:46
Example of simple_dtt
def simple_dtt(request, template, extra_context):
expire_time = timedelta(days=90)
if 'pages' in extra_context:
pages = extra_context['pages']
pages.append(extra_context['page_name'])
else:
pages = get_active(urls.urlpatterns, extra_context['page_name'])
@robrocker7
robrocker7 / urls.py
Created September 7, 2012 15:43
Example of URLS.py
from django.conf.urls.defaults import *
from django.conf import settings
from django.views.generic.simple import redirect_to
from django.views.decorators.cache import cache_page
from apps.common.views import simple_dtt
# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()
class SearchEngineReferrerMiddleware(object):
"""
Usage example:
==============
{% if request.session.search_engine %}
You searched for {{ request.session.search_term }} using {{ request.session.search_engine }}.
{% endif %}
"""
SEARCH_PARAMS = {
@robrocker7
robrocker7 / gist:3230400
Created August 1, 2012 20:25
Affiliate
class Profile(models.Model):
PROFILE_STATUS = (
('DECLINED', 'Declined'),
('APPROVED', 'Approved'),
('PENDING', 'Pending')
)
name = models.CharField(max_length=128)
title = models.CharField(max_length=128, blank=True, null=True)
import os
from datetime import timedelta, datetime
from subprocess import call
from django.db import models
from django_extensions.db.fields.encrypted import EncryptedCharField
from django.contrib.localflavor.us.models import PhoneNumberField
from django.contrib.localflavor.us.us_states import STATE_CHOICES
from django.contrib.auth.models import User
from django.core.urlresolvers import reverse
<table class="table table-striped table-bordered table-condensed">
<thead>
<tr>
<th>Name</th>
<th>Email</th>
<th>Phone</th>
<th>Intake Status</th>
<th></th>
</tr>
</thead>
def choose_state(request):
# try to auto find the city/state from IP address
geo_ip = GeoIP()
city_info = geo_ip.city('12.201.194.50')
if city_info is not None and 'city' in city_info and 'region' in city_info and 'dont_auto_crime_stats' not in request.session:
request.session['dont_auto_crime_stats'] = True
return HttpResponseRedirect(reverse('crime-rate:crime-stats', kwargs={'city': city_info['city'], 'state': city_info['region']}))
states = State.objects.order_by('name')
forms = {}
import os
from datetime import timedelta
from django.db import models
from django_extensions.db.fields.encrypted import EncryptedCharField
from django.contrib.localflavor.us.models import PhoneNumberField
from django.contrib.localflavor.us.us_states import STATE_CHOICES
from django.contrib.auth.models import User
from django.core.urlresolvers import reverse
from django.conf import settings