Exemplo n.º 1
0
def handle_profile_group(event):
    request = event.request
#    session = request.registry.getUtility(ISUSession)
#    session.commit()

    if has_permission('group:admin', request.context, request):
        group_pk = event.values.get('group', None)

        if group_pk:
            group = Group.get_by_pk(request, group_pk)

            if not group in event.user.groups:
                event.user.groups.append(group)
        else:
            event.user.groups.pop()
Exemplo n.º 2
0
def choices_widget(node, kw):
    request = kw.get('request')

    if request.context:
        is_admin = has_permission('group:admin', request.context, request)
        groups = Group.get_all(request)

        if is_admin:
            choices = [
                ('', '- None -'),
            ]

            for group in groups:
                choices.append((str(group.pk), group.name))

            return deform.widget.SelectWidget(values=choices)

    return deform.widget.HiddenWidget()