Skip to content

Instantly share code, notes, and snippets.

View brunobbbs's full-sized avatar

Bruno Barbosa brunobbbs

View GitHub Profile
class LoginRequiredMixin(object):
"""
View mixin which requires that the user is authenticated.
"""
@method_decorator(login_required)
def dispatch(self, request, *args, **kwargs):
return super(LoginRequiredMixin, self).dispatch(
self, request, *args, **kwargs)
@brunobbbs
brunobbbs / configure.zcml
Last active August 29, 2015 14:02
Query portal_catalog filtering tags with plone.api in Plone 4
<browser:page
for="*"
name="getdocument_view"
class=".getdocument.GetDocument"
template="getdocument.pt"
allowed_interface=".getdocument.IGetDocument"
permission="zope.Public"
/>
@brunobbbs
brunobbbs / browserlayer.xml
Last active August 29, 2015 14:01
Registering a new viewlet on Plone 4.x
<?xml version="1.0"?>
<layers>
<layer
name="search_viewlet"
interface="meu.namespace.browser.viewlet.ISearch"
/>
</layers>
Function Shortcut
previous tab ⌘ + left arrow
next tab ⌘ + right arrow
go to tab ⌘ + number
go to window ⌘ + Option + Number
go to split pane by direction ⌘ + Option + arrow
go to split pane by order of use ⌘ + ] , ⌘ + [
split window horizontally (same profile) ⌘ + D
split window vertically (same profile) ⌘ + d
@brunobbbs
brunobbbs / numeros_primos.py
Last active December 20, 2015 10:08
Dejafio: O Objetivo deste Kata é escrever um código que encontre números primos utilizando o método do crivo de erastótenes.
#!/usr/bin/env
#-*- coding: utf-8 -*-
from sys import argv
from math import floor, sqrt
def gera_numeros_primos(lista, maior_num_checado):
for n in lista:
if n > maior_num_checado:
@brunobbbs
brunobbbs / setuphandlers.py
Last active December 18, 2015 14:38
Criação de conteúdo programaticamente no Plone a partir do arquivo setuphandlers.py
#-*- coding: utf-8 -*-
from Products.CMFCore.utils import getToolByName
from Products.CMFCore.WorkflowCore import WorkflowException
def create_contents(context, contents):
for content in contents:
options = None
if 'options' in content.keys():