Esempio n. 1
0
    permissions to permissionsgroup group

    """

    can_add = Permission.objects.get(codename="add_" + classname, content_type__app_label=app_label)
    can_change = Permission.objects.get(codename="change_" + classname, content_type__app_label=app_label)
    can_delete = Permission.objects.get(codename="delete_" + classname, content_type__app_label=app_label)

    group.permissions.add(can_add, can_change, can_delete)


# when a user activates account, set permissions. dispatch_uid makes sure the receiver is only
# registered once.  see https://docs.djangoproject.com/en/dev/topics/signals/
signup_complete.connect(
    set_project_admin_permissions,
    dispatch_uid="set_project_\
                            admin_permissions_reveiver",
)


# ======================================= sending notification emails ====================


def send_existing_project_link_submission_notification_email(request, obj):
    """ When someone has completed the form to submit a new existing challenge 
    site for the overview, let this know to all admins of the main project    
    params:
    obj:         a ProjectMetaData object, which is the database object which 
                 has just been created by submitting the form 
                     
    """
Esempio n. 2
0
from userena.signals import signup_complete
from django.contrib.auth.models import User
from django.contrib.auth.models import Group
from django.contrib.auth.models import Permission

def usuario_registrado(sender, **kwargs):
	user = kwargs['user']
	grupo=Group.objects.get_or_create(name="Licitantes")
	perm = Permission.objects.get(codename='add_licitacion')
	grupo[0].permissions.add(perm)
	perm = Permission.objects.get(codename='change_licitacion')
	grupo[0].permissions.add(perm)
	perm = Permission.objects.get(codename='delete_licitacion')
	grupo[0].user_set.add(user)
	print "Usuario registrado agregado al grupo Licitantes"

signup_complete.connect(usuario_registrado)