Skip to content

Commit de5a560

Browse files
committed
Actually toggle active membership
1 parent bca115c commit de5a560

File tree

2 files changed

+18
-10
lines changed

2 files changed

+18
-10
lines changed

conditional/blueprints/member_management.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
from conditional.util.ldap import ldap_is_financial_director
2626
from conditional.util.ldap import ldap_set_roomnumber
2727
from conditional.util.ldap import ldap_set_active
28+
from conditional.util.ldap import ldap_set_inactive
2829
from conditional.util.ldap import ldap_set_housingpoints
2930
from conditional.util.ldap import ldap_get_room_number
3031
from conditional.util.ldap import ldap_get_housing_points
@@ -242,7 +243,10 @@ def member_management_edituser(uid):
242243
# Only update if there's a diff
243244
logger.info('backend', action="edit %s active: %s" % (uid, active_member))
244245
if ldap_is_active(uid) != active_member:
245-
ldap_set_active(uid)
246+
if active_member:
247+
ldap_set_active(uid)
248+
else:
249+
ldap_set_inactive(uid)
246250

247251
if active_member:
248252
db.session.add(SpringEval(uid))

conditional/util/ldap.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ def __ldap_remove_member_from_group__(username, group):
119119
ldap_conn.modify_s(groupdn, ldap_modlist)
120120

121121

122-
@ldap_init_required
122+
# @ldap_init_required
123123
def __ldap_is_member_of_committee__(username, committee):
124124
ldap_results = ldap_conn.search_s(committee_search_ou, ldap.SCOPE_SUBTREE,
125125
"(cn=%s)" % committee)
@@ -130,51 +130,51 @@ def __ldap_is_member_of_committee__(username, committee):
130130
[x.decode('ascii') for x in ldap_results[0][1]['head']]
131131

132132

133-
@lru_cache(maxsize=1024)
133+
# @lru_cache(maxsize=1024)
134134
def ldap_get_housing_points(username):
135135
return int(__ldap_get_field__(username, 'housingPoints'))
136136

137137

138-
@lru_cache(maxsize=1024)
138+
# @lru_cache(maxsize=1024)
139139
def ldap_get_room_number(username):
140140
roomno = __ldap_get_field__(username, 'roomNumber')
141141
if roomno is None:
142142
return "N/A"
143143
return roomno.decode('utf-8')
144144

145145

146-
@lru_cache(maxsize=1024)
146+
# @lru_cache(maxsize=1024)
147147
def ldap_get_active_members():
148148
return [x for x in ldap_get_current_students()
149149
if ldap_is_active(x['uid'][0].decode('utf-8'))]
150150

151151

152-
@lru_cache(maxsize=1024)
152+
# @lru_cache(maxsize=1024)
153153
def ldap_get_intro_members():
154154
return [x for x in ldap_get_current_students()
155155
if ldap_is_intromember(x['uid'][0].decode('utf-8'))]
156156

157157

158-
@lru_cache(maxsize=1024)
158+
# @lru_cache(maxsize=1024)
159159
def ldap_get_non_alumni_members():
160160
return [x for x in ldap_get_current_students()
161161
if ldap_is_alumni(x['uid'][0].decode('utf-8'))]
162162

163163

164-
@lru_cache(maxsize=1024)
164+
# @lru_cache(maxsize=1024)
165165
def ldap_get_onfloor_members():
166166
return [x for x in ldap_get_current_students()
167167
if ldap_is_onfloor(x['uid'][0].decode('utf-8'))]
168168

169169

170-
@lru_cache(maxsize=1024)
170+
# @lru_cache(maxsize=1024)
171171
def ldap_get_current_students():
172172
return [x[1]
173173
for x in __ldap_get_members__()[1:]
174174
if ldap_is_current_student(str(str(x[0]).split(",")[0]).split("=")[1])]
175175

176176

177-
@lru_cache(maxsize=1024)
177+
# @lru_cache(maxsize=1024)
178178
def ldap_is_active(username):
179179
return __ldap_is_member_of_group__(username, 'active')
180180

@@ -226,6 +226,10 @@ def ldap_set_active(username):
226226
__ldap_add_member_to_group__(username, 'active')
227227

228228

229+
def ldap_set_inactive(username):
230+
__ldap_remove_member_from_group__(username, 'active')
231+
232+
229233
@lru_cache(maxsize=1024)
230234
def ldap_get_name(username):
231235
first = __ldap_get_field__(username, 'givenName')

0 commit comments

Comments
 (0)