Revision 9f8ad4c5 invitations/invitations.py
b/invitations/invitations.py | ||
---|---|---|
238 | 238 |
) |
239 | 239 |
|
240 | 240 |
|
241 |
def get_invitee_level(source): |
|
242 |
return get_user_inv_level(source) + 1 |
|
243 |
|
|
244 |
|
|
245 |
def get_user_inv_level(u): |
|
246 |
inv = Invitations.objects.filter(target = u) |
|
247 |
|
|
248 |
if inv is None: |
|
249 |
raise Exception("User without invitation", u) |
|
250 |
|
|
251 |
return inv[0].level |
|
252 |
|
|
253 |
|
|
241 | 254 |
@transaction.commit_on_success |
242 | 255 |
def add_invitation(source, name, email): |
243 | 256 |
""" |
... | ... | |
263 | 276 |
if not r: |
264 | 277 |
raise Exception("Invited user cannot be added") |
265 | 278 |
|
279 |
u = target[0] |
|
280 |
invitee_level = get_invitee_level(source) |
|
281 |
|
|
282 |
u.max_invitations = settings.INVITATIONS_PER_LEVEL[invitee_level] |
|
283 |
u.save() |
|
284 |
|
|
266 | 285 |
inv = Invitations() |
267 | 286 |
inv.source = source |
268 |
inv.target = target[0] |
|
287 |
inv.target = u |
|
288 |
inv.level = invitee_level |
|
269 | 289 |
inv.save() |
270 | 290 |
return inv |
271 | 291 |
|
Also available in: Unified diff