Skip to content

Instantly share code, notes, and snippets.

View gladson's full-sized avatar
😎
Vá lutar pelo que você acredita.

Gladson gladson

😎
Vá lutar pelo que você acredita.
View GitHub Profile
from django.core.exceptions import PermissionDenied
from django.contrib import admin
from crm.models import Customer
class ReadPermissionModelAdmin(admin.ModelAdmin):
def has_change_permission(self, request, obj=None):
if getattr(request, 'readonly', False):
return True
return super(ReadPermissionModelAdmin, self).has_change_permission(request, obj)
# -*- coding: utf-8 -*-
import os
from django.core.mail import get_connection
from django.core.mail.message import EmailMessage
from django.conf import settings
from django.contrib.sites.models import Site
from django.template import Context, RequestContext
from django.template.loader import get_template

Set up Django, nginx and uwsgi

Steps with explanations to set up a server using:

  • virtualenv
  • Django
  • nginx
  • uwsgi
# coding: utf-8
#By turicas: https://gist.github.com/4288101
import io
import unicodedata
from Tkinter import *
@gladson
gladson / configuration.php
Created December 11, 2012 04:00
example configuration file for running Joomla on AppFog
<?php
class JConfig {
/* Site Settings */
public $offline = '0';
public $offline_message = 'This site is down for maintenance.<br /> Please check back again soon.';
public $sitename = '';
public $editor = 'tinymce';
public $list_limit = '10';
public $legacy = '0';
/* Debug Settings */
@gladson
gladson / json_response.py
Created November 29, 2012 14:25 — forked from macndesign/json_response.py
Serializar detalhamento ou listagem de dados customizados em json com CBV
# API JSON
from django.http import HttpResponse
from django.utils import simplejson
from django.views.generic.detail import BaseDetailView
from django.views.generic.list import BaseListView
from django.db.models.query import QuerySet
class JSONResponseMixin(object):
def render_to_response(self, context):
return self.get_json_response(self.convert_context_to_json(context))
@gladson
gladson / atepassar_recommender.py
Created November 1, 2012 15:55 — forked from marcelcaraciolo/atepassar_recommender.py
Atepassar Simple Algorithm for Friends Recommendation
#-*-coding: utf-8 -*-
'''
This module represents the FriendsRecommender system for recommending
new friends based on friendship similarity and state similarity.
'''
__author__ = 'Marcel Caraciolo <[email protected]>'
@gladson
gladson / DD_belatedPNG.js
Created November 1, 2012 02:21 — forked from donut/DD_belatedPNG.js
Fix PNGs in IE < 9 jQuery plugin
/* The code below should be included in a separate file using IE conditional comments
as it causes errors in IE8(+?) */
/**
* DD_belatedPNG: Adds IE6 support: PNG images for CSS background-image and HTML <IMG/>.
* Author: Drew Diller
* Email: [email protected]
* URL: http://www.dillerdesign.com/experiment/DD_belatedPNG/
* Version: 0.0.8a
* Licensed under the MIT License: http://dillerdesign.com/experiment/DD_belatedPNG/#license
@gladson
gladson / registro.py
Created October 23, 2012 18:43 — forked from macndesign/registro.py
registro de usuario e userprofile
# forms.py
class UserProfileForm(forms.ModelForm):
class Meta:
model = UserProfile
exclude = ('user',)
class UserForm(UserCreationForm):
def __init__(self, *args, **kwargs):
super(UserForm, self).__init__(*args, **kwargs)
@gladson
gladson / baseviews.py
Created October 22, 2012 18:40 — forked from fabiocerqueira/baseviews.py
SearchView
from django.views.generic import ListView
from django.views.generic.edit import FormMixin
from django.db.models import Q
class SearchView(FormMixin, ListView):
template_name_suffix = '_search'
filter_operator = 'contains'
allow_or_operator = False
def get_filter_operator(self):