sábado, 29 de noviembre de 2014

Django models añadir permisos para ver a todos. (view_*)

Algo muy común que se usa en Django son los permisos de modelo para controlar quien puede objetos particulares. Django provee permisos por defectos en todos los modelos, crear, editar y eliminar.

Hay varias formas de agregar este permiso de "ver" en la web, pero la forma más sencilla que yo e visto es hacerlo en "post_syncdb". Cuando uses el comando syncdb, todos los modelos de tu sistema se chequeara si tienen el permiso view y si no se los creara.

Solo tienes que poner el siguiente script en el __init.py en el directorio de management/ de cualquiera de tus aplicaciones. Necesita estar dentro de un directorio de management o si no, no sera descubierto por el comando syncdb.

from django.db.models.signals import post_syncdb
from django.contrib.contenttypes.models import ContentType
from django.contrib.auth.models import Permission
 
def add_view_permissions(sender, **kwargs):
    """
    This syncdb hooks takes care of adding a view permission too all our 
    content types.
    """
    # for each of our content types
    for content_type in ContentType.objects.all():
        # build our permission slug
        codename = "view_%s" % content_type.model
 
        # if it doesn't exist..
        if not Permission.objects.filter(content_type=content_type, codename=codename):
            # add it
            Permission.objects.create(content_type=content_type,
                                      codename=codename,
                                      name="Can view %s" % content_type.name)
            print "Added view permission for %s" % content_type.name
 
# check for all our view permissions after a syncdb
post_syncdb.connect(add_view_permissions)

3D city Project. Three.js HTML5 WebGL

Hoy queria compartir con ustedes un proyecto muy chevere que descubri hoy, es una especi de simscity en la web. Super cool y util para evaluar el desempeño de los navegadores web para este tipo de juegos.

Aparte de todo el proyecto esta colocado en github y es de codigo abierto asi que pueden copiarlo ver como lo hicieron y si quieres crear el suyo propio.




lunes, 17 de noviembre de 2014

Learning Unity 2D Game Development by Example



Is a very beginner book, the first 4 chapters are bored for someone that as a background in programming. From chapter 6 begins the real examples, but are so easy. it take at most one hour to complete each example. Although are good examples to practice the skill, and learn some things.

The book lacks much on scripting, 2D Animation, GUI, etc... Enter to a intermediate level of development a game with Unity. Exists best content on the official page of unity.





domingo, 16 de noviembre de 2014

Cocos2d-x Game Development Essentials



I'm an intermediate level programmer in the game development. This book gave me the foundation I needed to take full advantage of what Cocos2dX has to offer. Every chapter is very clearly written, and teaches step by step the necesary to learn how to work with this Game development Platform.

I like to learn by doing, so I was glad that examples with sample data are included in every chapter. You learn and try it out.

The writing is very clear, and the editing is clean. The author is concise, specific, and never wasteful. This book has been a tremendous help at my job, and the skills I've learned have allowed me to take on many new responsibilities.

If you are like me, new to cocos2dx this is a very usefull book.


https://www.packtpub.com/game-development/cocos2d-x-game-development-essentials