Пример #1
0
def realm_multiple_user_delete_inactive(request, realm_id):
    realm = Realm.objects.get(id=realm_id)
    if request.method == 'POST':
        form = UserDeleteListForm(request.POST)
        if form.is_valid():
            ldap_users = form.cleaned_data['ldap_users']
            blocked_users, deletable_users = get_deletable_blocked_users(
                ldap_users, realm)
            return render(
                request, 'realm/realm_user_multiple_delete.jinja2', {
                    'form': form,
                    'realm': realm,
                    'deletable_users': deletable_users,
                    'blocked_users': blocked_users,
                    'confirm': True
                })
    inactive_users = LdapUser.get_inactive_users(realm=realm)

    # TODO: Form not valid
    form = UserDeleteListForm()
    return render(request, 'realm/realm_user_multiple_delete_confirm.jinja2', {
        'form': form,
        'realm': realm,
        'users': inactive_users,
    })
Пример #2
0
def render_realm_detail_view(request,
                             realm_id,
                             success_headline=None,
                             success_text=None,
                             error_headline=None,
                             error_text=None,
                             status_code=200):
    realm = Realm.objects.get(id=realm_id)
    LdapUser.base_dn = realm.ldap_base_dn
    inactive_users = LdapUser.get_inactive_users().count()
    ldap_admin_group, ldap_default_group = get_default_admin_group(realm)
    return render(request,
                  'realm/realm_detailed.jinja2', {
                      'realm': realm,
                      'ldap_admin_group': ldap_admin_group,
                      'ldap_default_group': ldap_default_group,
                      'inactive_user_count': inactive_users,
                      'users_count': LdapUser.objects.all().count(),
                      'success_headline': success_headline,
                      'success_text': success_text,
                      'error_headline': error_headline,
                      'error_text': error_text
                  },
                  status=status_code)