Skip to content

Commit

Permalink
Show LDAP DN in admin membership list
Browse files Browse the repository at this point in the history
  • Loading branch information
txels committed Apr 12, 2024
1 parent 1cb076d commit d00e329
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
15 changes: 8 additions & 7 deletions shipanaro/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,26 +81,27 @@ class MembershipAdmin(ShipanaroModelAdmin):
list_display = (
"uid",
"activated",
"drop_out",
"user__first_name",
"user__last_name",
"user__username",
"user__email",
"nid",
"ldap_dn",
"birthday",
# 'assigned_sex',
"gender",
"phone",
# "phone",
# 'phone_2',
# 'user__date_joined',
# 'date_left',
"nid",
# 'nid_type',
"province",
"city",
# "city",
# 'address',
# 'nationality',
# 'notes',
"postal_code",
"drop_out",
# "postal_code",
"user__date_joined",
"date_left",
)
ordering = ("-uid",)
list_filter = (
Expand Down
7 changes: 7 additions & 0 deletions shipanaro/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from django.utils.translation import gettext as _
from shipanaro import settings
from shipanaro.auth.models import User, Group
from humans.directory import Directory

# Based on ISO 5218
SEXES = (
Expand Down Expand Up @@ -142,6 +143,12 @@ def save(self, *args, **kwargs):
def __str__(self):
return self.user.first_name

@property
def ldap_dn(self):
directory = Directory()
dn, attrs = directory.get_user(self.user.username)
return dn if attrs else None


SUBSCRIPTION_SERVICES = (("newsletter", _("Newsletter")),)

Expand Down

0 comments on commit d00e329

Please sign in to comment.