Skip to content

Instantly share code, notes, and snippets.

View gilsondev's full-sized avatar
💼
Work

Gilson Filho gilsondev

💼
Work
View GitHub Profile
@gilsondev
gilsondev / produtos_form.html
Created December 15, 2011 11:01
Template implementado usando o twitter bootstrap
{% extends "base.html" %}
{% block cabecalho %}
<h2>Novo Produto</h2>
{% endblock %}
{% block corpo %}
<form action="{% url produtos:novo %}" method="post" class="form-stacked" enctype="multipart/form-data">
{% csrf_token %}
<fieldset>
@gilsondev
gilsondev / pagination.html
Created December 20, 2011 13:07
Template do plugin django-pagination adaptado para o Twitter Bootstrap
{% if is_paginated %}
{% load i18n %}
<div class="pagination">
<ul>
{% if page_obj.has_previous %}
<li class="prev"><a href="?page={{ page_obj.previous_page_number }}{{ getvars }}">&lsaquo;&lsaquo; {% trans "previous" %}</a></li>
{% else %}
<li class="prev disabled"><a href="#">&lsaquo;&lsaquo; {% trans "previous" %}</a></li>
{% endif %}
{% for page in pages %}
@gilsondev
gilsondev / default_django_cookbook.rb
Created March 20, 2012 21:47
Solutions for install django 1.3.1 in the Vagrant
#
# Cookbook Name:: django
# Recipe:: default
#
# Copyright 2009, Opscode, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
@gilsondev
gilsondev / test_views.py
Created March 27, 2012 17:41
Unit test for views with decoration @login_required
# -*- coding: utf8 -*-
from django.test import TestCase
from django.core.urlresolvers import reverse
class ProfileViewTest(TestCase):
"""Unit test for verify profile views"""
fixtures = ['users.json']
@gilsondev
gilsondev / bash_prompt.sh
Created April 24, 2012 23:51 — forked from jcook793/bash_prompt.sh
Set color bash prompt according to active virtualenv, git branch, mercurial branch and return status of last command.
#!/bin/bash
#
# DESCRIPTION:
#
# Set the bash prompt according to:
# * the active virtualenv
# * the branch/status of the current git repository
# * the branch/status of the current mercurial repository
# * the return value of the previous command
#
@gilsondev
gilsondev / views.py
Created May 25, 2012 19:29
Using reverse function with Class based generic view in success_url
# -*- coding: utf8 -*-
from django.views.generic.edit import FormView
from django.core.urlresolvers import reverse
class FooFormView(FormView):
template_name = 'foo/foo_form.html'
form_class = FooForm
@gilsondev
gilsondev / __init__.py
Created May 25, 2012 22:14
Creating version for python package based in the PEP 386 and Django
VERSION = (1, 0, 0, 'alpha', 0)
def get_version(version=None):
"Returns a PEP 386-compliant version number from VERSION."
if version is None:
from address import VERSION as version
else:
assert len(version) == 5
assert version[3] in ('alpha', 'beta', 'rc', 'final')
@gilsondev
gilsondev / python-pil-image-sprite.py
Created July 20, 2012 18:02 — forked from gourneau/python-pil-image-sprite.py
Make sprites of images using Python and PIL
#!/usr/bin/python
# This work is licensed under the Creative Commons Attribution 3.0 United
# States License. To view a copy of this license, visit
# http://creativecommons.org/licenses/by/3.0/us/ or send a letter to Creative
# Commons, 171 Second Street, Suite 300, San Francisco, California, 94105, USA.
# from http://oranlooney.com/make-css-sprites-python-image-library/
# Orignial Author Oran Looney <[email protected]>
@gilsondev
gilsondev / middleware.py
Created July 21, 2012 16:12
Middleware que impede o cache da página pelo navegador (bom para desenvolvimento)
class NoCacheMiddleware(object):
def process_response(self, request, response):
request.META['HTTP_CACHE_CONTROL'] = "no-cache"
return response
@gilsondev
gilsondev / tests.py
Created July 31, 2012 18:21
Classe de Teste da view de subscriptions
from django.core.urlresolvers import reverse as r
# ...
class SubscribeViewTest(TestCase):
def setUp(self):
self.resp = self.client.get(r('subscriptions:subscribe'))
def test_get(self):
'Ao visitar /inscricao/ a página de inscrição é exibida'