signals
imperial_coldfront_plugin.signals
¤
Django signals.
Signals are a rather blunt instrument but are useful for hooking into models defined by Coldfront. Here we use them to enforce some constraints on attributes and to manage LDAP group membership.
Functions¤
ensure_no_existing_gid(sender, instance, **kwargs)
¤
Prevent saving of GID attribute if it is already in use.
This checks both existing allocation attributes and LDAP (if enabled).
Note that this makes all operations that create or modify GID attributes potentially slow as they involve a network call to the LDAP server. GID attributes should ideally be created in background tasks rather than in the request/response cycle.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sender
|
object
|
The model class. |
required |
instance
|
AllocationAttribute
|
The instance being saved. |
required |
**kwargs
|
object
|
Additional keyword arguments. |
{}
|
Source code in imperial_coldfront_plugin/signals.py
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | |
ensure_unique_group_id(sender, instance, **kwargs)
¤
Prevent saving of project group name if it is not unique.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sender
|
object
|
The model class. |
required |
instance
|
ProjectAttribute
|
The instance being saved. |
required |
**kwargs
|
object
|
Additional keyword arguments. |
{}
|
Source code in imperial_coldfront_plugin/signals.py
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | |
ensure_unique_shortname(sender, instance, **kwargs)
¤
Prevent saving of shortname attribute if it is not unique.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sender
|
object
|
The model class. |
required |
instance
|
AllocationAttribute
|
The instance being saved. |
required |
**kwargs
|
object
|
Additional keyword arguments. |
{}
|
Source code in imperial_coldfront_plugin/signals.py
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | |
remove_ldap_group_membership(sender, instance, **kwargs)
¤
Remove an ldap group member if the associated AllocationUser is deleted.
This isn't expected to come up in the usual course of things as removing a user via the UI does not delete the AllocationUser object. Just covering it for completeness.
Note this signal invokes a background task to do the actual LDAP operation. This leaves the potential for the database and LDAP to get out of sync if the task fails, but avoids making the request/response cycle slow.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sender
|
object
|
The model class. |
required |
instance
|
AllocationUser
|
The instance being deleted. |
required |
**kwargs
|
object
|
Additional keyword arguments. |
{}
|
Source code in imperial_coldfront_plugin/signals.py
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 | |
sync_ldap_group_membership(sender, instance, **kwargs)
¤
Add or remove members from an ldap group based on AllocationUser.status.
Note this signal invokes a background task to do the actual LDAP operation. This leaves the potential for the database and LDAP to get out of sync if the task fails, but avoids making the request/response cycle slow.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sender
|
object
|
The model class. |
required |
instance
|
AllocationUser
|
The instance being saved. |
required |
**kwargs
|
object
|
Additional keyword arguments. |
{}
|
Source code in imperial_coldfront_plugin/signals.py
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 | |