Skip to content

Instantly share code, notes, and snippets.

View guilhermecarvalhocarneiro's full-sized avatar

Guilherme de Carvalho Carneiro guilhermecarvalhocarneiro

  • Palmas, Tocantins, Brasil
View GitHub Profile
@Override
public Filter getFilter() {
return new PlaceFilter(this, placeAll);
}
// Filter class
private static class PlaceFilter extends Filter{
private final PlaceAdapter adapter;
private final List<Place> original;
private final List<Place> filtered;
@guilhermecarvalhocarneiro
guilhermecarvalhocarneiro / build.gradle
Created August 27, 2015 00:40
Problema ao carregar as dependencias.
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':volley')
compile 'com.squareup.picasso:picasso:2.1.1'
compile 'com.google.android.gms:play-services-location:7.8.0'
compile 'com.google.android.gms:play-services-analytics:7.5.0'
compile 'com.android.support:palette-v7:21.0.0'
compile 'com.android.support:appcompat-v7:22.1.1'
compile 'com.google.android.gms:play-services-maps:7.5.0'
compile 'com.android.support:support-v4:18.0.+'
compile 'br.com.livroandroid:android-utils:1.0.0'
@guilhermecarvalhocarneiro
guilhermecarvalhocarneiro / views.py
Created February 2, 2017 20:02
Classe DetailTemplateView
class CidadeDetailViewTemplate(DetailView):
model = Cidade
context_object_name = 'city'
template_name = "site/base.html"
def get_object(self):
obj = {}
city = Cidade(
estado=Estado.objects.get(uf=self.kwargs.get("uf").upper()),
nome=self.kwargs.get("nome")).get_item_slugify()
class CidadeDetailViewTemplate(DetailView):
model = Cidade
context_object_name = 'city'
template_name = "site/base.html"
def get_object(self):
obj = {}
city = Cidade(
estado=Estado.objects.get(uf=self.kwargs.get("uf").upper()),
nome=self.kwargs.get("nome")).get_item_slugify()
$scope.init = function (data) {
var city = angular.fromJson(data);
$scope.city = JSON.parse(city.cidade)[0];
$scope.attraction = JSON.parse(city.atrativos);
$scope.pictures = JSON.parse(city.fotos_atrativos);
$scope.pontos = JSON.parse(city.pontos);
var items = [];
for (var i = 0; i < 100; i++) {
items.push({ 'nome': "Atrativo " + String(i) });
}
app.config(function ($interpolateProvider, $httpProvider) {
$interpolateProvider.startSymbol('[[');
$interpolateProvider.endSymbol(']]');
});
class FolhaPagamento(models.Model):
matricula = models.BigIntegerField(u'Matricula', blank=True, null=True, db_index=True)
servidor = models.CharField(u'servidor', max_length=500, blank=True, null=True, db_index=True)
cod_setor = models.CharField(u'cod_setor', max_length=50, blank=True, null=True, db_index=True)
setor = models.CharField(u'setor', max_length=500, blank=True, null=True, db_index=True)
cod_cargo = models.BigIntegerField(u'cod_cargo', blank=True, null=True, db_index=True)
cargo = models.CharField(u'cargo', max_length=500, blank=True, null=True, db_index=True)
cod_funcao = models.BigIntegerField(u'cod_funcao', blank=True, null=True, db_index=True)
funcao = models.CharField(u'funcao', max_length=500, blank=True, null=True, db_index=True)
cod_vinculo = models.BigIntegerField(u'cod_vinculo',blank=True, null=True, db_index=True)
class AmbienteInternoCreate(CreateView):
"""Views para inserção de um objeto Ambiente Interno"""
model = AmbienteInterno
form_class = AmbienteInternoFormOut
template_name = "ambiente_interno/form.html"
def get_success_url(self):
return reverse_lazy('ambiente-interno-list')
@guilhermecarvalhocarneiro
guilhermecarvalhocarneiro / forms.py
Created June 18, 2017 13:41
Form usado pela CreateView
class AmbienteInternoFormOut(forms.ModelForm):
"""Form para ser usado no classe based views"""
def __init__(self, *args, **kwargs):
# Sobrescrevendo o Init para aplicar a regra CSS para todos os campos
# do formularios
from django.forms.fields import FileField
super(AmbienteInternoFormOut, self).__init__(*args, **kwargs)
for field in iter(self.fields):
if isinstance(self.fields[field], FileField) is False:
self.fields[field].widget.attrs.update({
def get_context_data(self, **kwargs):
page = 1
context = super(BaseListView, self).get_context_data(**kwargs)
context['display'] = self.list_display
query_params = dict(self.request.GET)
if query_params:
for key, value in query_params.items():
if key not in ['csrfmiddlewaretoken', 'page']:
self.url_pagination += "{}={}&".format(key, value[0].replace(" ", "+"))
if query_params.get('csrfmiddlewaretoken'):