Skip to content

Instantly share code, notes, and snippets.

from django.db import models
class Item(models.Model):
name = models.CharField(max_length=75)
item = models.ForeignKey('self', blank=True, null=True, related_name='item_child_set')
def __unicode__(self):
try:
mlist = [x.name for x in self.item_child_set.all() if x.pk > self.pk]
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import math
import re
# dado um título e lista de listas no formato
# ('<variável>', '<tipo>', '<descricao>', '<fórmula>')
# pede-se qual variável calcular, pede os valores e dá o resultado
# qualquer valor vazio saida da função
@macndesign
macndesign / run_loaddata.log
Created May 2, 2014 11:14
When I'll run loaddata command
vagrant@precise32:~$ /vagrant/bin/django loaddata /vagrant/src/fixtures/test.yaml
Problem installing fixture '/vagrant/src/fixtures/test.yaml': Traceback (most recent call last):
File "/vagrant/eggs/Django-1.4.10-py2.7.egg/django/core/management/commands/loaddata.py", line 196, in handle
obj.save(using=using)
File "/vagrant/eggs/Django-1.4.10-py2.7.egg/django/core/serializers/base.py", line 165, in save
models.Model.save_base(self.object, using=using, raw=True)
File "/vagrant/eggs/Django-1.4.10-py2.7.egg/django/db/models/base.py", line 565, in save_base
created=(not record_exists), raw=raw, using=using)
File "/vagrant/eggs/Django-1.4.10-py2.7.egg/django/dispatch/dispatcher.py", line 172, in send
response = receiver(signal=self, sender=sender, **named)
@macndesign
macndesign / test.log
Created April 30, 2014 14:41
Problems to run tests (not just to this test, but is the same error in all others)
vagrant@precise32:~$ /vagrant/bin/django test accounts.ChangeEmailEncryptDecryptTest.test_change_email
UserWarning: 'override_urls' is a deprecated method & will be removed by v1.0.0. Please use ``prepend_urls`` instead. [api.py:82]
Creating test database for alias 'default'...
E
======================================================================
ERROR: test_change_email (accounts.tests.ChangeEmailEncryptDecryptTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/vagrant/src/accounts/tests.py", line 373, in setUp
super(ChangeEmailEncryptDecryptTest, self).setUp()
def create_admin_group_to_room(sender, **kwargs):
if not kwargs.get('created'):
return # don't do anything
room = kwargs.get('instance')
admin_group = Group(room=room, title='Admin', group_color='#ff0000')
admin_group.save()
logger.warning('Successfully created Admin group in Room: {0}'.format(room.name))
@macndesign
macndesign / log.log
Created April 23, 2014 13:14
pull develop -> 1.3.0pt-sprint-1
mac:onlinebr mario$ git branch
1.3.0pt
* 1.3.0pt-sprint-1
1.3.1-sprint-2
develop
mac:onlinebr mario$ git pull origin develop
Username for 'https://github.com': macndesign
Password for 'https://[email protected]':
From https://github.com/agilentia/onlinebr
* branch develop -> FETCH_HEAD
# language: pt-br
Funcionalidade: Log in no admin do django
Cenário: Login no admin do django com usuário e senha corretos
Dado o usuário "admin" e a senha "admin"
Quando eu preencher o formulário de login e enviar os dados
Então devo ver na tela a mensagem "Encerrar sessão"
Cenário: Login no admin do django com usuário e senha incorretos
Dado o usuário "usuario_invalido" e a senha "senha_invalida"
Feature: Log in django admin
Scenario: Log in django admin with correct user and password
Given I have the user admin and password admin
When I fill the form and submit
Then I see the text "Encerrar sessão"
Scenario: Log in django admin with incorrect user and password
Given I have the user invald_admin and password invalid_password
When I fill the form and submit
# -*- coding: utf-8 -*-
#--------------------------------------------------------------
# myposconfig.py - *Configuração após instalar Ubuntu 13.04 >
# Autor: Jhonathan Paulo Banczek
# 09-03-2014 - jhoonb.com
# Python 2.7 >
# - *configurações pessoais
#--------------------------------------------------------------
@macndesign
macndesign / test_admin.py
Created April 14, 2014 13:15
Exemplo de automação de testes usando (Splinter, PhantomJS e Unittest)
# coding: utf-8
from splinter import Browser
import unittest
class LoginAdminTestCase(unittest.TestCase):
"""
Simples teste usando:
* Unittest: https://docs.python.org/2/library/unittest.html
* Splinter: http://splinter.cobrateam.info/